From eacf1747c63848b8492f3201cc071095910c7289 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Sat, 19 Feb 2022 22:03:16 +0800 Subject: Set install name in `LIBFLAGS` My previous PR (#16) deliberately set the install name at install time instead of at build time, since this is the correct time to determine the library's install name. However, if you prefer to do this during build time instead, then there is no need to call `install_name_tool`. We can pass the appropriate flags to the linker instead. --- Makefile | 1 - linux.mk | 2 -- macos.mk | 5 ++--- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 4f26280..a6aa425 100644 --- a/Makefile +++ b/Makefile @@ -139,7 +139,6 @@ $(OBJ): $(HDR) libkeccak.$(LIBEXT): $(OBJ) $(CC) $(LIBFLAGS) -o $@ $(OBJ) $(LDFLAGS) - $(FIX_INSTALL_NAME) libkeccak.a: $(OBJ) -rm -f -- $@ diff --git a/linux.mk b/linux.mk index d617684..c9f74a0 100644 --- a/linux.mk +++ b/linux.mk @@ -3,5 +3,3 @@ LIBFLAGS = -shared -Wl,-soname,libkeccak.$(LIBEXT).$(LIB_MAJOR) LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR) LIBMINOREXT = $(LIBEXT).$(LIB_VERSION) - -FIX_INSTALL_NAME = : diff --git a/macos.mk b/macos.mk index 25c308b..58afc20 100644 --- a/macos.mk +++ b/macos.mk @@ -1,7 +1,6 @@ LIBEXT = dylib -LIBFLAGS = -dynamiclib -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION) +LIBFLAGS = -dynamiclib -Wl,-install_name,"$(PREFIX)/lib/libkeccak.$(LIBMAJOREXT)" \ + -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION) LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) - -FIX_INSTALL_NAME = install_name_tool -id "$(PREFIX)/lib/libkeccak.$(LIBMAJOREXT)" "libkeccak.$(LIBEXT)" -- cgit v1.2.3-70-g09d2 From bda62bccc3f99a41c830a00114d255473e8da5a8 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Sat, 19 Feb 2022 22:46:57 +0800 Subject: Set install name for installed library --- Makefile | 1 + linux.mk | 2 ++ macos.mk | 5 +++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a6aa425..10926cb 100644 --- a/Makefile +++ b/Makefile @@ -177,6 +177,7 @@ run-benchmark: benchmark benchfile install: libkeccak.$(LIBEXT) libkeccak.a mkdir -p -- "$(DESTDIR)$(PREFIX)/lib" cp -- libkeccak.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBMINOREXT)" + $(FIX_INSTALL_NAME) ln -sf -- libkeccak.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBMAJOREXT)" ln -sf -- libkeccak.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBEXT)" cp -- libkeccak.a "$(DESTDIR)$(PREFIX)/lib/libkeccak.a" diff --git a/linux.mk b/linux.mk index c9f74a0..d617684 100644 --- a/linux.mk +++ b/linux.mk @@ -3,3 +3,5 @@ LIBFLAGS = -shared -Wl,-soname,libkeccak.$(LIBEXT).$(LIB_MAJOR) LIBMAJOREXT = $(LIBEXT).$(LIB_MAJOR) LIBMINOREXT = $(LIBEXT).$(LIB_VERSION) + +FIX_INSTALL_NAME = : diff --git a/macos.mk b/macos.mk index 58afc20..83b6515 100644 --- a/macos.mk +++ b/macos.mk @@ -1,6 +1,7 @@ LIBEXT = dylib -LIBFLAGS = -dynamiclib -Wl,-install_name,"$(PREFIX)/lib/libkeccak.$(LIBMAJOREXT)" \ - -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION) +LIBFLAGS = -dynamiclib -Wl,-compatibility_version,$(LIB_MAJOR) -Wl,-current_version,$(LIB_VERSION) LIBMAJOREXT = $(LIB_MAJOR).$(LIBEXT) LIBMINOREXT = $(LIB_VERSION).$(LIBEXT) + +FIX_INSTALL_NAME = install_name_tool -id "$(PREFIX)/lib/libkeccak.$(LIBMAJOREXT)" "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBEXT)" -- cgit v1.2.3-70-g09d2