-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
44 lines (34 loc) · 893 Bytes
/
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
# Define the command of tool
CC := gcc
AR := ar
MD := mkdir -p
RM := rm -rf
# Define the JSON parsing library used (cjson or jansson supported)
JSON_LIB = cjson
#JSON_LIB = jansson
# output files
OUT_DIR := ./output
TARGET := $(OUT_DIR)/libcson.a
# source files
SRC_DIR = ./src
SRC_FILES += $(wildcard $(SRC_DIR)/*.c)
ADP_SRC_DIR = ./adapter/$(JSON_LIB)
ADP_SRC_FILES += $(wildcard $(ADP_SRC_DIR)/*.c)
# *.o
OBJS += $(patsubst $(SRC_DIR)/%.c, $(OUT_DIR)/%.o, $(SRC_FILES))
OBJS += $(patsubst $(ADP_SRC_DIR)/%.c, $(OUT_DIR)/%.o, $(ADP_SRC_FILES))
# include path
INC_PATH += -I./inc/
INC_PATH += -I./3rd/inc/
$(TARGET):$(OBJS)
@$(MD) $(OUT_DIR)
@$(AR) rc $(TARGET) $(OBJS)
$(OUT_DIR)/%.o:$(SRC_DIR)/%.c
@$(MD) $(OUT_DIR)
@$(CC) $(INC_PATH) -c $< -o $@
$(OUT_DIR)/%.o:$(ADP_SRC_DIR)/%.c
@$(MD) $(OUT_DIR)
@$(CC) $(INC_PATH) -c $< -o $@
.PHONY:clean
clean:
@$(RM) $(OUT_DIR)