-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (40 loc) · 1.36 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
CXX = gcc
CXXFLAGS = -Wall -Wextra
DEBUG_FLAGS = -g -DDEBUG
SRC = $(wildcard cson/*.c)
SRC += $(wildcard cson/libs/*.c)
OBJ = $(SRC:.c=.o)
BASIC_OBJ = basic_example.o $(OBJ)
BASIC_TARGET = basic
ST_OBJ = st_example.o $(OBJ)
ST_TARGET = st
NESTED_OBJECTS_OBJ = nested_objects_example.o $(OBJ)
NESTED_OBJECTS_TARGET = nested_objects
NESTED_ARRAYS_OBJ = nested_arrays_example.o $(OBJ)
NESTED_ARRAYS_TARGET = nested_arrays
NESTED_STUFF_OBJ = nested_stuff_example.o $(OBJ)
NESTED_STUFF_TARGET = nested_stuff
REAL_JSON_OBJ = real_json_example.o $(OBJ)
REAL_JSON_TARGET = real_json
ifeq ($(DEBUG), 1)
CXXFLAGS += $(DEBUG_FLAGS)
endif
ifeq ($(SANITIZE), 1)
CXXFLAGS += -fsanitize=address
endif
$(ST_TARGET): $(ST_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^
$(BASIC_TARGET): $(BASIC_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^
$(NESTED_OBJECTS_TARGET): $(NESTED_OBJECTS_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^
$(NESTED_ARRAYS_TARGET): $(NESTED_ARRAYS_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^
$(NESTED_STUFF_TARGET): $(NESTED_STUFF_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^
$(REAL_JSON_TARGET): $(REAL_JSON_OBJ)
$(CXX) $(CXXFLAGS) -o $@ $^
%.o: %.c
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -rf $(ST_OBJ) $(ST_TARGET) $(BASIC_OBJ) $(BASIC_TARGET) $(NESTED_OBJECTS_OBJ) $(NESTED_OBJECTS_TARGET) $(NESTED_ARRAYS_OBJ) $(NESTED_ARRAYS_TARGET) $(NESTED_STUFF_OBJ) $(NESTED_STUFF_TARGET) $(REAL_JSON_OBJ) $(REAL_JSON_TARGET)