-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
78 lines (60 loc) · 1.21 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
DEBUG := 0
DEBUG_UTF8 := 0
USE_CAPABILITIES := 1
CFLAGS := $(CFLAGS) -Wall -Wextra -Wshadow -Wstrict-prototypes -pedantic -Os
LDFLAGS := -lrt
KERNEL := $(shell uname -s)
ifeq ($(origin CC), default)
ifeq ($(KERNEL), Darwin)
CC := clang
else
CC := gcc
endif
endif
ifeq ($(DEBUG_UTF8), 1)
DEBUG := 1
CFLAGS := $(CFLAGS) -DDEBUG_UTF8
endif
ifeq ($(DEBUG), 1)
CFLAGS := $(CFLAGS) -g
endif
ifeq ($(KERNEL), Linux)
ifeq ($(USE_CAPABILITIES), 1)
LDFLAGS := $(LDFLAGS) -lcap
CFLAGS := $(CFLAGS) -DUSE_CAPABILITIES
endif
endif
SRC := \
main.c \
server.c \
worker.c \
log.c \
net.c \
request.c
ifeq ($(KERNEL), Darwin)
SRC := $(SRC) clock.c
endif
TARGETS := mekdotlu
SRC := $(addprefix src/, $(SRC))
OBJ := $(SRC:%.c=%.o)
DEP := $(OBJ:%.o=%.d)
.PHONY : all fall clean
all : $(TARGETS)
fall :
$(MAKE) clean
$(MAKE) all
clean :
$(RM) $(OBJ)
$(RM) $(DEP)
$(RM) $(TARGETS)
%.o : %.c
$(CC) $(CFLAGS) -MD -c $< -o $@
@cp -f $*.d $*.d.tmp
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
@$(RM) $*.d.tmp
mekdotlu : $(OBJ)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
test: src/test.c src/request.o src/log.o
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
-include $(DEP)