-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (42 loc) · 1.37 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
TARGET=ln-network-daemon
DEBUG=1
OPTIMIZE=-O2
VERBOSE=1
CC=gcc -std=gnu99 -D_DEFAULT_SOURCE -D_GNU_SOURCE
LINKER=gcc -std=gnu99 -D_DEFAULT_SOURCE -D_GNU_SOURCE
AR=ar crf
SRC_DIR=src
OBJ_DIR=obj
BIN_DIR=bin
LIB_DIR=lib
CFLAGS = -Wall -Iinclude -D_VERBOSE=$(VERBOSE)
LIBS = -lm -lpthread -ljson-c -lcurl -luuid
ifeq ($(DEBUG),1)
CFLAGS += -g
OPTIMIZE = -O0
endif
SOURCES := $(wildcard $(SRC_DIR)/*.c)
OBJECTS := $(SOURCES:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o)
BASE_SRC_DIR := $(SRC_DIR)/base
BASE_OBJ_DIR := $(OBJ_DIR)/base
UTILS_SRC_DIR := $(SRC_DIR)/utils
UTILS_OBJ_DIR := $(OBJ_DIR)/utils
BASE_SOURCES := $(wildcard $(BASE_SRC_DIR)/*.c)
BASE_OBJECTS := $(BASE_SOURCES:$(BASE_SRC_DIR)/%.c=$(BASE_OBJ_DIR)/%.o)
UTILS_SOURCES := $(wildcard $(UTILS_SRC_DIR)/*.c)
UTILS_OBJECTS := $(UTILS_SOURCES:$(UTILS_SRC_DIR)/%.c=$(UTILS_OBJ_DIR)/%.o)
all: do_init $(OBJECTS) $(BASE_OBJECTS) $(UTILS_OBJECTS)
$(OBJECTS): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -o $@ -c $< $(CFLAGS)
$(BASE_OBJECTS): $(BASE_OBJ_DIR)/%.o : $(BASE_SRC_DIR)/%.c
$(CC) -o $@ -c $< $(CFLAGS)
$(UTILS_OBJECTS): $(UTILS_OBJ_DIR)/%.o : $(UTILS_SRC_DIR)/%.c
$(CC) -o $@ -c $< $(CFLAGS)
.PHONY: do_init clean tests
do_init:
mkdir -p obj/base obj/utils bin lib tests
clean:
rm -rf obj/* $(TARGET)
tests: json-rpc
json-rpc: src/rpc/json-rpc.c $(OBJECTS)
$(CC) -o tests/$@ src/rpc/json-rpc.c $(CFLAGS) $(LIBS) -D_TEST -D_STAND_ALONE