-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
46 lines (37 loc) · 1.18 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
SRC = lib.c table.c
HEADER = $(wildcard include/**/*.h)
OBJS = $(SRC:%.c=build/obj/%.o)
CC ?= clang
TESTS = $(wildcard test/*.c)
CFLAGS += -std=c99 -I . -I cake_libs/ \
-Wall -Wextra -Wformat=2 -Wshadow \
-Wwrite-strings -Wstrict-prototypes -Wold-style-definition \
-Wredundant-decls -Wnested-externs -Wmissing-include-dirs \
-Wno-unused-parameter -Wno-unused-command-line-argument \
-Wno-missing-braces -Wno-unused-function \
-Wno-strict-prototypes -Wno-old-style-definition \
-Wimplicit-fallthrough=1 -Wno-address-of-packed-member -pg
LDFLAGS += -lcunit -lxxhash
ifeq ($(MODE),debug)
CFLAGS += -DDEBUG -O0 -ggdb
else
CFLAGS += -Ofast
endif
.PHONY: all lib_test clean
%.o: build/obj/%.o
all: $(OBJS)
$(EXEC): $(OBJS)
@mkdir -p build/bin
$(CC) -o build/bin/$@ $^ $(LDFLAGS)
build/obj/%_test.o: test/%_test.c
@mkdir -p build/obj
$(CC) $(CFLAGS) -c $^ -o $@
build/obj/%.o: %.c
@mkdir -p build/obj
$(CC) $(CFLAGS) -c $^ -o $@
lib_test: build/obj/lib_test.o build/obj/lib.o build/obj/table.o
@mkdir -p build/bin
$(CC) -o build/bin/$@ $^ $(LDFLAGS)
tree build
clean:
@if [ -d build ]; then rm -rf build; fi