From 166b73d5abde8070196e9798554d2521c60e6aad Mon Sep 17 00:00:00 2001 From: Gabor Adam Toth Date: Sat, 30 Apr 2011 15:42:48 +0200 Subject: [PATCH] Makefile improvements --- Makefile | 9 +++++---- src/Makefile | 34 +++++++++++++++++++--------------- test/Makefile | 45 ++++++++++++++++++++++++++++----------------- 3 files changed, 52 insertions(+), 36 deletions(-) diff --git a/Makefile b/Makefile index c446fe6..86f7430 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,18 @@ .PHONY: doc .PHONY: test +.PHONY: lib default: @/bin/echo -e "Usage:\n\tmake diet - compile with diet libc\n\tmake glibc - compile with normal gnu libc\n\tmake test\n\tmake doc" -glibc: - make -C src glibc +lib: + ${MAKE} -C src lib diet: - make -C src diet + ${MAKE} -C src diet test: - make -C test + ${MAKE} -C test doc: doxygen diff --git a/src/Makefile b/src/Makefile index 6447d44..c8a0f88 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,24 +1,28 @@ -CFLAGS=-I../include -DDEBUG=2 -DPSYC_COMPILE_LIBRARY -g -O0 -Wall -CC=cc -# CC=clang +OPT = -O2 +DEBUG = 2 +CFLAGS = -I../include -Wall ${OPT} +DIET = diet +WRAPPER = -test -z "$DIET" || DIET=diet +S = packet.c misc.c parser.c match.c render.c memmem.c itoa.c variable.c +O = packet.o misc.o parser.o match.o render.o memmem.o itoa.o variable.o -S=packet.c misc.c parser.c match.c render.c memmem.c itoa.c variable.c -O=packet.o misc.o parser.o match.o render.o memmem.o itoa.o variable.o +all: lib -default: +help: @/bin/echo -e "Usage:\n\tmake diet - compile with diet libc\n\tmake lib - compile with normal gnu libc" -diet: - ${DIET} ${CC} -static -c -Os $S ${CFLAGS} - @test -d ../lib || mkdir ../lib - ${DIET} ar rcs ../lib/libpsyc.a $O +debug: CFLAGS += -DDEBUG=${DEBUG} -g +debug: CFLAGS := $(subst ${OPT},-O0,${CFLAGS}) +debug: lib -glibc: $S - ${CC} -static -c -g -O0 $S -lc ${CFLAGS} - @test -d ../lib || mkdir ../lib - ar rcs ../lib/libpsyc.a $O +diet: WRAPPER = ${DIET} +diet: lib + +lib: CC := ${WRAPPER} ${CC} +lib: $O + @mkdir -p ../lib + ${WRAPPER} ar rcs ../lib/libpsyc.a $O match: match.c ${CC} -o $@ -DDEBUG=4 -DCMDTOOL -DTEST $< diff --git a/test/Makefile b/test/Makefile index d3f2324..d2f2796 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,40 +1,51 @@ -CFLAGS=-I../include -DDEBUG -g -O0 -Wall -LDFLAGS=-L../lib -LOADLIBES=-lpsyc -lm -TARGETS=testServer testParser testMatch testRender isRoutingVar getVarType -PORT=4440 +OPT = -O2 +DEBUG = 2 +CFLAGS = -I../include -Wall ${OPT} +LDFLAGS = -L../lib +LOADLIBES = -lpsyc -lm +TARGETS = testServer testParser testMatch testRender isRoutingVar getVarType +WRAPPER = +DIET = diet +PORT = 4440 -all: $(TARGETS) +all: test + +diet: WRAPPER = ${DIET} +diet: all + +debug: CFLAGS += -DDEBUG=${DEBUG} -g +debug: CFLAGS := $(subst ${OPT},-O0,${CFLAGS}) +debug: all + +test: ${TARGETS} ./testRender ./testMatch ./isRoutingVar ./getVarType - -test: $(TARGETS) - for f in packets/full-* packets/error-*; do echo ">> $$f"; ./testParser $$f; done + for f in packets/full-*; do echo ">> $$f"; ./testParser $$f; done netstart: - ./testServer $(PORT) + ./testServer ${PORT} netstartv: - ./testServer $(PORT) -v + ./testServer ${PORT} -v nettest: - for f in packets/full-*; do echo ">> $$f"; cat $$f | nc localhost $(PORT) | diff -u $$f -; done + for f in packets/full-*; do echo ">> $$f"; cat $$f | nc localhost ${PORT} | diff -u $$f -; done nettesterr: - for f in packets/error-*; do echo ">> $$f"; cat $$f | nc localhost $(PORT); done + for f in packets/error-*; do echo ">> $$f"; cat $$f | nc localhost ${PORT}; done splittest: - for f in packets/full-*; do echo ">> $$f"; ./splittest.pl $$f $(PORT) | diff -u $$f -; done + for f in packets/full-*; do echo ">> $$f"; ./splittest.pl $$f ${PORT} | diff -u $$f -; done nettestp1: - (for f in packets/part-1-p*; do cat $$f; done) | nc localhost $(PORT) | diff -u packets/full-1 - + (for f in packets/part-1-p*; do cat $$f; done) | nc localhost ${PORT} | diff -u packets/full-1 - nettestp2: - (for f in packets/part-1-length-p*; do cat $$f; done) | nc localhost $(PORT) | diff -u packets/full-1-length - + (for f in packets/part-1-length-p*; do cat $$f; done) | nc localhost ${PORT} | diff -u packets/full-1-length - clean: - rm -f $(TARGETS) + rm -f ${TARGETS} it: all