Skip to content
Browse files

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

Closes #40.
  • Loading branch information...
1 parent 0aa3e52 commit 8e8344518e7f3592d8a780c4359ec32425e661e9 @pgriess pgriess committed
Showing with 22 additions and 16 deletions.
  1. +22 −16 Makefile
38 Makefile
@@ -1,39 +1,45 @@
-CPPFLAGS?=-Wall -Wextra -Werror -I.
+CFLAGS += -Wall -Wextra -Werror
test: test_g test_fast
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
- $(CC) $(OPT_DEBUG) -c test.c -o $@
-test.o: test.c http_parser.h Makefile
- $(CC) $(OPT_FAST) -c test.c -o $@
+ $(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@
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
- valgrind ./test_g
+test_fast: http_parser.o test.o http_parser.h
+ $(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@
-http_parser.o: http_parser.c http_parser.h Makefile
- $(CC) $(OPT_FAST) -c http_parser.c
+test.o: test.c http_parser.h Makefile
+ $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@
-test_fast: http_parser.o test.c http_parser.h
- $(CC) $(OPT_FAST) http_parser.o test.c -o $@
+http_parser.o: http_parser.c http_parser.h Makefile
+ $(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c
test-run-timed: test_fast
while(true) do time ./test_fast > /dev/null; done
+test-valgrind: test_g
+ valgrind ./test_g
package: http_parser.o
$(AR) rcs libhttp_parser.a http_parser.o

0 comments on commit 8e83445

Please sign in to comment.
Something went wrong with that request. Please try again.