From 7d182704b9a30a22658034cd1255feaeb1063df9 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 15 Apr 2024 21:14:55 +0100 Subject: [PATCH] Improved `test` make target: Added phony: `test`, builds and runs the test program against the debug static lib target. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for memfd_secret-shim's current commit: Half blessing − 半吉 --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8aeaefe..51be391 100644 --- a/Makefile +++ b/Makefile @@ -234,6 +234,11 @@ all: | clean @$(MAKE) clean-rebuild @$(MAKE) debug +.PHONY: test +test: $(PROJECT)-test + -strace ./$< + -valgrind ./$< + # Targets .PHONY: pch @@ -345,8 +350,8 @@ uninstall: cd $(INCLUDE) && find . -type f | xargs -I {} rm "$(DESTDIR)$(PREFIX)/include/$(PROJECT)/{}" rmdir $(DESTDIR)$(PREFIX)/include/$(PROJECT) +#TODO: We can make the target between `{debug,release}{.a,.so}` configurable by call. e.g. `TARGET=release.a make test` $(PROJECT)-test: LDFLAGS+= -lfmt -lstdc++ $(PROJECT)-test: CFLAGS+= -Og -g $(PROJECT)-test: lib$(PROJECT)-debug.a - $(CC) $(CFLAGS) src/test/*.c -o $@ -l:$< $(LDFLAGS) - -valgrind ./$@ + $(CC) $(CFLAGS) -fwhole-program src/test/*.c -o $@ -l:$< $(LDFLAGS)