-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
88 lines (65 loc) · 2.02 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.PHONY: all libs clean example objs doxygen benchmark install test
.ONESHELL:
TARGET_DIR ?=
DEST ?= /usr/
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
ifeq ($(TARGET_DIR),)
TARGET_DIR = $(ROOT_DIR)/target
endif
$(shell mkdir -p $(TARGET_DIR))
ifneq ($(JSON_DEBUG),)
DEBUG_FLAGS = -DJSON_DEBUG
SANITIZER_FLAGS = -fsanitize=address -lasan
endif
ifneq ($(JSON_SANITIZE),)
SANITIZER_FLAGS = -fsanitize=address -lasan
endif
COMMON_FLAGS += -Wall -Wextra -Werror -ggdb -Wno-unused-result \
-I$(ROOT_DIR)/src \
-I/usr/include \
$(SANITIZER_FLAGS) $(DEBUG_FLAGS)
CFLAGS += -std=c11 $(COMMON_FLAGS)
CXXFLAGS += -std=c++17 $(COMMON_FLAGS)
LDFLAGS ?=
export
all: json-gen-c
libs: $(TARGET_DIR)/libutils.a $(TARGET_DIR)/libstruct.a $(TARGET_DIR)/gencode.a
$(TARGET_DIR)/libutils.a:
make -C src/utils
$(TARGET_DIR)/libstruct.a:
make -C src/struct
$(TARGET_DIR)/gencode.a:
make -C src/gencode
libs_mmm = $(TARGET_DIR)/gencode.a $(TARGET_DIR)/libstruct.a $(TARGET_DIR)/libutils.a
$(TARGET_DIR)/main.o: src/main/main.c
make -C src/main
$(CC) $(CFLAGS) -I$(TARGET_DIR) -c $< -o $@
json-gen-c: $(TARGET_DIR)/json-gen-c
$(TARGET_DIR)/json-gen-c: libs $(TARGET_DIR)/main.o
$(CC) $(CFLAGS) $(TARGET_DIR)/main.o $(libs_mmm) -o $@
install: $(TARGET_DIR)/json-gen-c
@cp -f $(TARGET_DIR)/json-gen-c $(DEST)/bin/json-gen-c
@cp -f $(ROOT_DIR)/doc/json-gen-c.1 $(DEST)/share/man/man1/
@gzip -f $(DEST)/share/man/man1/json-gen-c.1
@echo json-gen-c has been installed on your device
uninstall:
@rm -rf $(DEST)/bin/json-gen-c
@rm -rf $(DEST)/share/man/man1/json-gen-c.1.gz
@echo json-gen-c has been removed from your device
clean:
rm -rf $(TARGET_DIR)
make clean -C example
make clean -C benchmark
make clean -C test
doxygen:
if [ ! -d target/doxygen-awesome-css ]; then
mkdir -p target
git clone --depth=1 https://github.com/jothepro/doxygen-awesome-css.git target/doxygen-awesome-css
fi
doxygen doc/Doxyfile
example: json-gen-c
make -C example
benchmark: json-gen-c
make -C benchmark
test: json-gen-c
make -C test