omni-makefile
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Fri, 20 Jun 2025 06:49:36 +0000 (08:49 +0200)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Fri, 20 Jun 2025 06:49:36 +0000 (08:49 +0200)
.gitignore
makefile

index 2b71b233aecbf8fe4df58baaa40663b980b60cb7..435e061e70e44b61a4432974257a7623263614b0 100644 (file)
@@ -2,5 +2,23 @@
 *.ld
 *.lld
 *.o
+
 *.exe
 *.a
+
+*.gcda
+*.gcno
+*.gcov
+*.glog
+*.log
+*.test
+
+*~
+*.bak
+
+.exec_*
+gmon.out
+
+.depends
+documentation
+changelog.txt
index 873bd42f60587520741d28653b2ac5fd9dad406d..85e3b4dfd733199c6945542efe932812f91108f4 100644 (file)
--- a/makefile
+++ b/makefile
@@ -84,7 +84,8 @@ DATE = $(shell git log -1 HEAD --format=%ai|awk '{print $$1}')
 ## Generic rules
 
 all: depends
-       [ "$(ALLEXE)" ] || { $(call FAIL,no exec to proceed); test; } && $(MAKE) $(ALLEXE:%=%.exe)
+       [ -z "$(ALLEXE)" ] || $(MAKE) $(ALLEXE:%=%.exe)
+       [ -z "$(ALLDLL)" ] || $(MAKE) $(ALLDLL:%=%.a)
 
 analyze:
        make purge
@@ -100,13 +101,21 @@ clean:
        rm -f clean $(wildcard *.d *.ld *.lld *.log *.o *.test *~ .exec_* gmon.out _)
        $(call PASS, SUCCESS)
 
-depends: $(patsubst %.c, %.d, $(wildcard *.c)) $(patsubst %, %.ld, $(ALLEXE)) $(patsubst %, %.lld, $(ALLDLL))
+depends: .depends $(patsubst %.c, %.d, $(wildcard *.c)) $(patsubst %, %.ld, $(ALLEXE)) $(patsubst %, %.lld, $(ALLDLL))
+
+.depends:
+       [ "$(ALLEXE)" ] || $(call WARN,no exec to proceed)
+       [ "$(ALLDLL)" ] || $(call WARN,no library to proceed)
+       touch $@
 
-documentation: doxygen.conf $(shell awk '{sub(/#.*/,"")} /^FILE_PATTERNS/,!/\\$$/ {sub(/\\$$/,"");sub(/.*=/,"");print}' doxygen.conf)
+documentation: doxygen.conf $(shell test -f doxygen.conf && awk '{sub(/#.*/,"")} /^FILE_PATTERNS/,!/\\$$/ {sub(/\\$$/,"");sub(/.*=/,"");print}' doxygen.conf)
        doxygen $<; true
        sed -i s/__BEGIN_DECLS//g documentation/html/*.html
        sed -i s/\\_\\-\\_BEGIN\\_\\-DECLS//g documentation/latex/*.tex
 
+exe: depends
+       [ "$(ALLEXE)" ] || { $(call FAIL,no exec to proceed); test; } && $(MAKE) $(ALLEXE:%=%.exe)
+
 gcovs: wipe
        $(MAKE) $(addprefix gcov_,$(ALLEXE))
 
@@ -119,7 +128,7 @@ lib: depends
 purge: clean
        $(call TITLE, "Purging")
        touch purge
-       rm -f purge $(ALLEXE:%=%.exe) $(ALLDLL:%=%.a)
+       rm -f purge $(wildcard .depends) $(ALLEXE:%=%.exe) $(ALLDLL:%=%.a)
        $(call PASS, SUCCESS)
 
 valgrinds:
@@ -137,7 +146,8 @@ tests:
        $(MAKE) all
        $(MAKE) $(addprefix test_,$(ALLEXE))
 
-archive: wipe changelog documentation
+archive: wipe changelog
+       [ \! -f doxygen.conf ] || make documentation
        name=`basename "$$(pwd)"`; cd ..; tar cvz --exclude='.git*' -f $$name-$(DATE).tgz $$name
 
 ## Main rules
@@ -257,7 +267,7 @@ changelog:
 
 ## Phony
 
-.PHONY: all analyze changelog clean count depends documentation gcovs purge tests
+.PHONY: all analyze archive changelog clean count depends documentation exe gcovs gprofs install_lib install_exe lib purge tests valgrinds wipe
 
 ## Precious