valgrinds rule depends on all
authorLaurent Mazet <mazet@softndesign.org>
Fri, 29 Dec 2023 21:09:55 +0000 (22:09 +0100)
committerLaurent Mazet <mazet@softndesign.org>
Fri, 29 Dec 2023 21:09:55 +0000 (22:09 +0100)
makefile

index 0f8ca5f8f65d9e86bb4d28defccfa5bfd31b6b77..abcb7b0fe1a1b7523b9df1fffa9cff44c0297481 100644 (file)
--- a/makefile
+++ b/makefile
@@ -2,7 +2,8 @@
 
 CC = gcc
 
-INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
+#INCLUDES = -I../debug -D__MEMORY_ALLOCATION__
+INCLUDES =
 OFLAGS  = -O4 -Os
 #OFLAGS  = -O4 -ffast-math -finline-functions
 #OFLAGS  = -O4 -finline-functions
@@ -10,7 +11,7 @@ OFLAGS  = -O4 -Os
 #OFLAGS += -minline-all-stringops -fsingle-precision-constant
 #OFLAGS += -malign-double
 CFLAGS += -W -Wall -Wextra -g
-CFLAGS += -std=c99 -D_XOPEN_SOURCE=500
+#CFLAGS += -std=c99 -D_XOPEN_SOURCE=500
 CFLAGS += $(OFLAGS) $(INCLUDES) $(GCOV)
 LDFLAGS += -g $(GCOV)
 
@@ -18,7 +19,6 @@ LDFLAGS += -g $(GCOV)
 
 ALLEXE  =
 ALLEXE += ascii
-#ALLEXE += skel
 
 SHELL = bash
 
@@ -64,7 +64,7 @@ purge: clean
        rm -f purge $(ALLEXE:%=%.exe)
        $(call PASS, SUCCESS)
 
-valgrinds:
+valgrinds: all
        $(MAKE) $(addprefix valgrind_,$(ALLEXE))
 
 wipe: purge
@@ -83,55 +83,56 @@ include $(wildcard *.ld)
 
 gcov_%:
        $(MAKE) purge
-       GCOV="-fprofile-arcs -ftest-coverage -O0" $(MAKE)
+       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
+       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
 
 valgrind_%: %.exe
-       VALGRIND="valgrind -v --leak-check=full --show-reachable=yes --log-fd=2"; \
+       VALGRIND="valgrind -v --leak-check=full --log-fd=3"; \
        export VALGRIND; \
-       $(MAKE) $(@:valgrind_%=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