|
1 | | -CPPFLAGS?=-Wall -Wextra -Werror -I. |
2 | | -OPT_DEBUG=$(CPPFLAGS) -O0 -g -DHTTP_PARSER_STRICT=1 |
3 | | -OPT_FAST=$(CPPFLAGS) -O3 -DHTTP_PARSER_STRICT=0 |
4 | | - |
5 | 1 | CC?=gcc |
6 | 2 | AR?=ar |
7 | 3 |
|
| 4 | +CPPFLAGS += -I. |
| 5 | +CPPFLAGS_DEBUG = $(CPPFLAGS) -DHTTP_PARSER_STRICT=1 -DHTTP_PARSER_DEBUG=1 |
| 6 | +CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA) |
| 7 | +CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0 -DHTTP_PARSER_DEBUG=0 |
| 8 | +CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA) |
| 9 | + |
| 10 | +CFLAGS += -Wall -Wextra -Werror |
| 11 | +CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA) |
| 12 | +CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA) |
| 13 | + |
8 | 14 |
|
9 | 15 | test: test_g test_fast |
10 | 16 | ./test_g |
11 | 17 | ./test_fast |
12 | 18 |
|
13 | 19 | test_g: http_parser_g.o test_g.o |
14 | | - $(CC) $(OPT_DEBUG) http_parser_g.o test_g.o -o $@ |
| 20 | + $(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@ |
15 | 21 |
|
16 | 22 | test_g.o: test.c http_parser.h Makefile |
17 | | - $(CC) $(OPT_DEBUG) -c test.c -o $@ |
18 | | - |
19 | | -test.o: test.c http_parser.h Makefile |
20 | | - $(CC) $(OPT_FAST) -c test.c -o $@ |
| 23 | + $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@ |
21 | 24 |
|
22 | 25 | http_parser_g.o: http_parser.c http_parser.h Makefile |
23 | | - $(CC) $(OPT_DEBUG) -c http_parser.c -o $@ |
| 26 | + $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c http_parser.c -o $@ |
24 | 27 |
|
25 | | -test-valgrind: test_g |
26 | | - valgrind ./test_g |
| 28 | +test_fast: http_parser.o test.o http_parser.h |
| 29 | + $(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@ |
27 | 30 |
|
28 | | -http_parser.o: http_parser.c http_parser.h Makefile |
29 | | - $(CC) $(OPT_FAST) -c http_parser.c |
| 31 | +test.o: test.c http_parser.h Makefile |
| 32 | + $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@ |
30 | 33 |
|
31 | | -test_fast: http_parser.o test.c http_parser.h |
32 | | - $(CC) $(OPT_FAST) http_parser.o test.c -o $@ |
| 34 | +http_parser.o: http_parser.c http_parser.h Makefile |
| 35 | + $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c |
33 | 36 |
|
34 | 37 | test-run-timed: test_fast |
35 | 38 | while(true) do time ./test_fast > /dev/null; done |
36 | 39 |
|
| 40 | +test-valgrind: test_g |
| 41 | + valgrind ./test_g |
| 42 | + |
37 | 43 | package: http_parser.o |
38 | 44 | $(AR) rcs libhttp_parser.a http_parser.o |
39 | 45 |
|
|
0 commit comments