-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
74 lines (51 loc) · 1.56 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
TARGET=netKeyboard
OBJ=obj
OBJD=objd
SRC=src
TESTS=testing
CC=gcc
WARN=-Wall -Wextra -Wpedantic -Wconversion -Wunused-variable -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wdouble-promotion -Wunused-function -Wunused-result
CDEFFLAGS=-std=c11 $(WARN)
CFLAGS=-O3 -Wl,--strip-all,--build-id=none,--gc-sections -fno-ident -D NDEBUG
CFLAGSD=-g -O0 -D LOGGING_ENABLE=1
LIB=-lws2_32
default: debug
$(OBJ):
mkdir $@
$(OBJD):
mkdir $@
$(TESTS)/bin:
mkdir $@
srcs = $(wildcard $(SRC)/*.c)
srcs := $(subst $(SRC)/,,$(srcs))
tests = $(wildcard $(TESTS)/*.c)
tests := $(subst $(TESTS)/,,$(tests))
TESTBINS = $(tests:%.c=$(TESTS)/bin/%)
bulk_srcs = $(wildcard $(SRC)/bulk/*.c)
objs_d = $(srcs:%=$(OBJD)/%.o)
objs_r = $(srcs:%=$(OBJ)/%.o)
objs_test = $(subst $(OBJD)/main.c.o,,$(objs_d))
$(OBJ)/%.c.o: $(SRC)/%.c $(OBJ)
$(CC) -c $< -o $@ $(CDEFFLAGS) $(CFLAGS)
$(OBJD)/%.c.o: $(SRC)/%.c $(OBJD)
$(CC) -c $< -o $@ $(CDEFFLAGS) $(CFLAGSD)
debug: $(objs_d)
$(CC) $^ -o deb$(TARGET).exe $(CDEFFLAGS) $(CFLAGSD) $(LIB)
bulkd: bulkd_impl
bulkd_impl: $(bulk_srcs)
$(CC) $^ -o deb$(TARGET).exe $(CDEFFLAGS) $(CFLAGSD) $(LIB)
release: $(objs_r)
$(CC) $^ -o $(TARGET).exe $(CDEFFLAGS) $(CFLAGS) $(LIB)
bulkr: bulkr_impl
bulkr_impl: $(bulk_srcs)
$(CC) $^ -o $(TARGET).exe $(CDEFFLAGS) $(CFLAGS) $(LIB)
$(TESTS)/bin/%: $(TESTS)/%.c $(objs_test)
$(CC) $(CDEFFLAGS) $^ -o $@ $(LIB) $(CFLAGSD)
test: $(TESTS)/bin $(TESTBINS)
for test in $(TESTBINS) ; do ./$$test ; done
clean:
rm -r -f $(OBJ)
rm -r -f $(OBJD)
rm -f $(TARGET).exe
rm -f deb$(TARGET).exe
rm -r -f $(TESTS)/bin