X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=makefile;h=d5c8da526a2373b0da40b631ef8ceb607551cc4e;hb=807bdeba16ea9ed816ecf7d3900f601c37ffa204;hp=090167546568a9e47e12ff1688f0d3003d59d68c;hpb=55cfeafacf6d7b97cb361cd39e06a61c3041c740;p=calc.git diff --git a/makefile b/makefile index 0901675..d5c8da5 100644 --- a/makefile +++ b/makefile @@ -11,8 +11,8 @@ OFLAGS = -O4 -Os #OFLAGS += -malign-double CFLAGS += -W -Wall -Wextra -g CFLAGS += -std=c99 -D_XOPEN_SOURCE=500 -CFLAGS += $(OFLAGS) $(INCLUDES) $(GCOVER) -LDFLAGS += -g +CFLAGS += $(OFLAGS) $(INCLUDES) $(GCOV) +LDFLAGS += -g $(GCOV) # Targets @@ -24,6 +24,7 @@ SHELL = bash #MAKE = mingw32-make MAKEFLAGS += -s +include $(wildcard .makefile) # Functions @@ -63,10 +64,13 @@ purge: clean rm -f purge $(ALLEXE:%=%.exe) $(call PASS, SUCCESS) +valgrinds: + $(MAKE) $(addprefix valgrind_,$(ALLEXE)) + wipe: purge - $(call TITLE, "wiping") + $(call TITLE, "Wiping") touch wipe - rm -f wipe $(wildcard *.gcda *.gcno) + rm -f wipe $(wildcard *.gcda *.gcno *.gcov) $(call PASS, SUCCESS) tests: all @@ -78,56 +82,57 @@ include $(wildcard *.d) include $(wildcard *.ld) gcov_%: - make purge - CFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS="-fprofile-arcs -ftest-coverage" make - make test_$(@:gcov_%=%) + $(MAKE) purge + GCOV="-coverage -O0" $(MAKE) + $(MAKE) test_$(@:gcov_%=%) gcov `sed -e 's/\.exe:/.c/;s/\.o/.c/g' $(@:gcov_%=%.ld)` touch gcov rm -f gcov $(wildcard *.gcda *.gcno) - make purge + $(MAKE) purge + grep '#####' *.c.gcov || true %.test: %.c $(call TITLE, "Building $@") # awk '/\/\* *test:.*\*\// { sub(/^.*\/\* *test: */, ""); sub(/ *\*\/.*$$/, ""); print }' $< > $@ - ./getcomments.pl -p='test:\s' -f='%' $< > $@ + perl -- getcomments.pl -p='test:\s' -f='%' $< > $@ $(call PASS, SUCCESS) test_%: %.test %.exe IFS=$$'\n'; RC=0; \ - for test in `cat $< | sed 's,${<:.test=.exe},./${<:.test=.exe},g'`; do \ + for test in `cat $< | sed 's,${<:.test=.exe},$(VALGRIND) ./${<:.test=.exe},g'`; do \ echo "=== $$test ==="; \ - eval $(VALGRIND) $$test; \ + eval $$test; \ [ $$? -eq 0 ] && echo -e "\033[1;32mSUCCESS\033[0;0m" \ || { echo -e "\033[1;31mFAILED\033[0;0m"; RC=1; }; \ done; \ - test "$$RC" -ne 1 + test "$$RC" -ne 1 -valgrind_%: % - VALGRIND="valgrind -v --leak-check=full --show-reachable=yes --log-fd=2"; \ +valgrind_%: %.exe + VALGRIND="valgrind -v --leak-check=full --log-fd=3"; \ export VALGRIND; \ - $(MAKE) test_$< + $(MAKE) $(@:valgrind_%=test_%) 3>$@.log %.d: %.c $(call TITLE, "Building $@") $(CC) $(INCLUDES) -MM $< -o $@~ - echo ${<:.c=.o}: $(shell ./getcomments.pl -p='depend:\s' -f='%' $<) >> $@~ + echo ${<:.c=.o}: $(shell perl -- getcomments.pl -p='depend:\s' -f='%' $<) >> $@~ mv $@~ $@ $(call PASS, SUCCESS) %.ld: %.c $(call TITLE, "Building $@") - echo ${<:.c=.exe}: $(shell ./getcomments.pl -p='linker:\s' -f='%' $< | awk '{for (i=1;i<=NF;i++) if ($$(i) ~ /.o$$/) printf " %s", $$(i)}') > $@ + echo ${<:.c=.exe}: $(shell perl -- getcomments.pl -p='linker:\s' -f='%' $< | awk '{for (i=1;i<=NF;i++) if ($$(i) ~ /.o$$/) printf " %s", $$(i)}') > $@ $(call PASS, SUCCESS) %.o: %.c $(call TITLE, "Building $@") - $(CC) $(CFLAGS) $(INCLUDES) $(shell ./getcomments.pl -p='cflags:\s' -f='%' $<) -c $< -o $@ + $(CC) $(CFLAGS) $(INCLUDES) $(shell perl -- getcomments.pl -p='cflags:\s' -f='%' $<) -c $< -o $@ $(call PASS, SUCCESS) %.exe: %.o %.d $(call TITLE, "Building $@") - $(CC) $(LDFLAGS) $(shell ./getcomments.pl -p='linker:\s' -f='%' ${<:.o=.c}) $< -o $@ + $(CC) $(LDFLAGS) $< $(shell perl -- getcomments.pl -p='linker:\s' -f='%' ${<:.o=.c}) -o $@ $(call PASS, SUCCESS) ## Phony