From 7fbb1940e489a9b2c85a4feee7cc981d798a3a8f Mon Sep 17 00:00:00 2001 From: Avril Date: Sat, 20 Apr 2024 14:04:12 +0100 Subject: [PATCH] Changed test build targeting shared libraries to build with a `./` soname. If the target library already exists however, it is not rebuilt and the normal soname configuration used when the target was built will be used. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for memfd_secret-shim's current commit: Middle blessing − 中吉 --- Makefile | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 39ffdd7..c556377 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,12 @@ STATIC_FLAGS+= STATIC_RELEASE_FLAGS+=-ffat-lto-objects STATIC_DEBUG_FLAGS+= +SHARED_LDFLAGS+= +STATIC_LDFLAGS+= + +SHARED_BINFLAGS+= +STATIC_BINFLAGS+= + # Features application ## Tell program which features are enabled via `FEATURE_`. @@ -298,30 +304,32 @@ prof/cxx/%.o: %.cpp $(PCH_OUTPUT) lib$(PROJECT)-release.a: CFLAGS+= $(RELEASE_CFLAGS) $(STATIC_FLAGS) $(STATIC_RELEASE_FLAGS) lib$(PROJECT)-release.a: CXXFLAGS += $(RELEASE_CXXFLAGS) $(STATIC_FLAGS) $(STATIC_RELEASE_FLAGS) -lib$(PROJECT)-release.a: LDFLAGS += $(RELEASE_LDFLAGS) +lib$(PROJECT)-release.a: LDFLAGS += $(RELEASE_LDFLAGS) $(STATIC_LDFLAGS) +lib$(PROJECT)-release.a: BINFLAGS += $(RELEASE_BINFLAGS) $(STATIC_BINFLAGS) lib$(PROJECT)-release.a: $(OBJ) - $(AR) rcs $@ $^ + $(AR) rcs $@ $^ $(RANLIB) $@ lib$(PROJECT)-debug.a: CFLAGS+= $(DEBUG_CFLAGS) $(STATIC_FLAGS) $(STATIC_DEBUG_FLAGS) lib$(PROJECT)-debug.a: CXXFLAGS += $(DEBUG_CXXFLAGS) $(STATIC_FLAGS) $(STATIC_DEBUG_FLAGS) -lib$(PROJECT)-debug.a: LDFLAGS += $(DEBUG_LDFLAGS) +lib$(PROJECT)-debug.a: LDFLAGS += $(DEBUG_LDFLAGS) $(STATIC_LDFLAGS) +lib$(PROJECT)-debug.a: BINFLAGS += $(DEBUG_BINFLAGS) $(STATIC_BINFLAGS) lib$(PROJECT)-debug.a: $(OBJ) $(AR) rcs $@ $^ $(RANLIB) $@ lib$(PROJECT)-release.so: CFLAGS+= $(RELEASE_CFLAGS) $(SHARED_FLAGS) $(SHARED_RELEASE_FLAGS) lib$(PROJECT)-release.so: CXXFLAGS += $(RELEASE_CXXFLAGS) $(SHARED_FLAGS) $(SHARED_RELEASE_FLAGS) -lib$(PROJECT)-release.so: LDFLAGS += $(RELEASE_LDFLAGS) -lib$(PROJECT)-release.so: BINFLAGS += $(RELEASE_BINFLAGS) +lib$(PROJECT)-release.so: LDFLAGS += $(RELEASE_LDFLAGS) $(SHARED_LDFLAGS) +lib$(PROJECT)-release.so: BINFLAGS += $(RELEASE_BINFLAGS) $(SHARED_BINFLAGS) lib$(PROJECT)-release.so: $(OBJ) $(CXX) -shared $^ $(BINFLAGS) $(CXXFLAGS) -o $@ $(LDFLAGS) $(STRIP) $@ lib$(PROJECT)-debug.so: CFLAGS+= $(DEBUG_CFLAGS) $(SHARED_FLAGS) $(SHARED_DEBUG_FLAGS) lib$(PROJECT)-debug.so: CXXFLAGS += $(DEBUG_CXXFLAGS) $(SHARED_FLAGS) $(SHARED_DEBUG_FLAGS) -lib$(PROJECT)-debug.so: LDFLAGS += $(DEBUG_LDFLAGS) -lib$(PROJECT)-debug.so: BINFLAGS += $(DEBUG_BINFLAGS) +lib$(PROJECT)-debug.so: LDFLAGS += $(DEBUG_LDFLAGS) $(SHARED_LDFLAGS) +lib$(PROJECT)-debug.so: BINFLAGS += $(DEBUG_BINFLAGS) $(SHARED_BINFLAGS) lib$(PROJECT)-debug.so: $(OBJ) $(CXX) -shared $^ $(BINFLAGS) $(CXXFLAGS) -o $@ $(LDFLAGS) @@ -363,5 +371,6 @@ 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: SHARED_LDFLAGS+=-Wl,-soname,./lib$(PROJECT)-$(TARGET) $(PROJECT)-test: lib$(PROJECT)-$(TARGET) - $(CC) $(CFLAGS) $(TEST_CFLAGS) src/test/*.c -o $@ -L. -l:$< $(LDFLAGS) $(TEST_LDFLAGS) + $(CC) $(CFLAGS) $(TEST_CFLAGS) src/test/*.c -o $@ -L./ -l:$< $(LDFLAGS) $(TEST_LDFLAGS)