remove dependency on perl script
authorLaurent MAZET <laurent.mazet@thalesgroup.com>
Wed, 12 Jun 2024 10:32:05 +0000 (12:32 +0200)
committerLaurent MAZET <laurent.mazet@thalesgroup.com>
Wed, 12 Jun 2024 10:32:05 +0000 (12:32 +0200)
makefile

index bcdc9c6a0aa8f6ed5da2a08967afd601b6a41b6e..36cd2a81ca851da6ff7c6f30ca60b356ec7ad76d 100644 (file)
--- a/makefile
+++ b/makefile
@@ -46,6 +46,9 @@ INSTALL = test -d `dirname $(2)` || $(call MKDIR, `dirname $(2)`) && cp -pa $(1)
 
 VALID = $(call TITLE, $(1)) && $(2) && $(call PASS, SUCCESS) || { $(call FAIL, FAILED); test; }
 
+GETCOMMENTS = awk '/\/\*\s*$(1):/,/\*\// { sub(/.*\/\*\s*$(1):/, ""); sub (/\s*\*\/.*/, ""); print } /\/\/\s*$(1):/ {sub (/.*\/\/\s*$(1):/, ""); print }' $(2)
+#GETCOMMENTS = perl -- getcomments.pl -p='$(1):\s' -f='%' $(2)
+
 ## Generic rules
 
 all: depends
@@ -122,8 +125,7 @@ gprof_%:
 
 %.test: %.c
        $(call TITLE, "Building $@")
-#      awk '/\/\* *test:.*\*\// { sub(/^.*\/\* *test: */, ""); sub(/ *\*\/.*$$/, ""); print }' $< > $@
-       perl -- getcomments.pl -p='test:\s' -f='%' $< > $@
+       $(call GETCOMMENTS,test, $<) > $@
        $(call PASS, SUCCESS)
 
 test_%: %.test %.exe
@@ -144,24 +146,24 @@ valgrind_%: %.exe
 %.d: %.c
        $(call TITLE, "Building $@")
        $(CC) $(INCLUDES) -MM $< -o $@~
-       echo ${<:.c=.o}: $(shell perl -- getcomments.pl -p='depend:\s' -f='%' $<) >> $@~
+       echo ${<:.c=.o}: $(shell $(call GETCOMMENTS,depends, $<)) >> $@~
        mv $@~ $@
        $(call PASS, SUCCESS)
 
 %.ld: %.c
        $(call TITLE, "Building $@")
-       echo ${<:.c=.exe}: $(shell perl -- getcomments.pl -p='$(LDOPT):\s' -f='%' $< | awk '{for (i=1;i<=NF;i++) if ($$(i) ~ /.o$$/) printf " %s", $$(i)}') > $@
+       echo ${<:.c=.exe}: $(shell $(call GETCOMMENTS,$(LDOPT), $<) | 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 perl -- getcomments.pl -p='cflags:\s' -f='%' $<) -c $< -o $@
+       $(CC) $(CFLAGS) $(INCLUDES) $(shell $(call GETCOMMENTS,cflags, $<)) -c $< -o $@
        $(call PASS, SUCCESS)
 
 
 %.exe: %.o %.d
        $(call TITLE, "Building $@")
-       $(CC) $(LDFLAGS) $< $(shell perl -- getcomments.pl -p='$(LDOPT):\s' -f='%' ${<:.o=.c}) $(LDLIBS) -o $@
+       $(CC) $(LDFLAGS) $< $(shell $(call GETCOMMENTS,$(LDOPT), ${<:.o=.c})) $(LDLIBS) -o $@
        $(call PASS, SUCCESS)
 
 ## Phony