From 94562877e018ddc66176982a6062273406ef5542 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 15 Apr 2024 23:43:58 +0100 Subject: [PATCH] Added `TARGET` var for `test` - {debug,release}.{a,so} (which build of lib to link to,) and configurable `TEST_{C,LD}FLAGS`. Fixed bug of adding test flags to dep build when it doesn"t already exist. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for memfd_secret-shim's current commit: Blessing − 吉 --- Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 806c70c..8844055 100644 --- a/Makefile +++ b/Makefile @@ -49,6 +49,13 @@ FEATURES?= # Build constants CONSTANTS+=_GNU_SOURCE +# Testing +# Can be {release,debug}.{a,so} +TARGET?=debug.a + +TEST_LDFLAGS+= -lfmt -lstdc++ -Wl,-z,now -Wl,-z -Wl,relro +TEST_CFLAGS+= -Og -g -fwhole-program + override __COMMA=, override __VERSION_SPLIT:= $(subst ., ,$(VERSION)) override __VERSION_REVISION:=$(word 3,$(__VERSION_SPLIT)) 0 @@ -354,7 +361,5 @@ uninstall: rmdir $(DESTDIR)$(PREFIX)/include/$(INCLUDE_PREFIX) || : #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) -fwhole-program src/test/*.c -o $@ -l:$< $(LDFLAGS) +$(PROJECT)-test: lib$(PROJECT)-$(TARGET) + $(CC) $(CFLAGS) $(TEST_CFLAGS) src/test/*.c -o $@ -l:$< $(LDFLAGS) $(TEST_LDFLAGS)