Re-jigger Makefile.

- Uses more standard $CFLAGS and $CPPFLAGS variables to populate the set
  of flags to build with.
- Allow extending compilation and linking flags with
  $CPPFLAGS_DEBUG_EXTRA, $CPPFLAGS_FAST_EXTRA, $CFLAGS_DEBUG_EXTRA, and
  $CFLAGS_FAST_EXTRA.

Closes #40.
v0.6
Peter Griess 14 years ago
parent 0aa3e522eb
commit 8e8344518e

@ -1,39 +1,45 @@
CPPFLAGS?=-Wall -Wextra -Werror -I.
OPT_DEBUG=$(CPPFLAGS) -O0 -g -DHTTP_PARSER_STRICT=1 -DHTTP_PARSER_DEBUG=1
OPT_FAST=$(CPPFLAGS) -O3 -DHTTP_PARSER_STRICT=0 -DHTTP_PARSER_DEBUG=0
CC?=gcc CC?=gcc
AR?=ar AR?=ar
CPPFLAGS += -I.
CPPFLAGS_DEBUG = $(CPPFLAGS) -DHTTP_PARSER_STRICT=1 -DHTTP_PARSER_DEBUG=1
CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA)
CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0 -DHTTP_PARSER_DEBUG=0
CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA)
CFLAGS += -Wall -Wextra -Werror
CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
test: test_g test_fast test: test_g test_fast
./test_g ./test_g
./test_fast ./test_fast
test_g: http_parser_g.o test_g.o test_g: http_parser_g.o test_g.o
$(CC) $(OPT_DEBUG) http_parser_g.o test_g.o -o $@ $(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@
test_g.o: test.c http_parser.h Makefile test_g.o: test.c http_parser.h Makefile
$(CC) $(OPT_DEBUG) -c test.c -o $@ $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@
test.o: test.c http_parser.h Makefile
$(CC) $(OPT_FAST) -c test.c -o $@
http_parser_g.o: http_parser.c http_parser.h Makefile http_parser_g.o: http_parser.c http_parser.h Makefile
$(CC) $(OPT_DEBUG) -c http_parser.c -o $@ $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c http_parser.c -o $@
test-valgrind: test_g test_fast: http_parser.o test.o http_parser.h
valgrind ./test_g $(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@
http_parser.o: http_parser.c http_parser.h Makefile test.o: test.c http_parser.h Makefile
$(CC) $(OPT_FAST) -c http_parser.c $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@
test_fast: http_parser.o test.c http_parser.h http_parser.o: http_parser.c http_parser.h Makefile
$(CC) $(OPT_FAST) http_parser.o test.c -o $@ $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c
test-run-timed: test_fast test-run-timed: test_fast
while(true) do time ./test_fast > /dev/null; done while(true) do time ./test_fast > /dev/null; done
test-valgrind: test_g
valgrind ./test_g
package: http_parser.o package: http_parser.o
$(AR) rcs libhttp_parser.a http_parser.o $(AR) rcs libhttp_parser.a http_parser.o

Loading…
Cancel
Save