aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorCarlo Cabrera <30379873+carlocab@users.noreply.github.com>2022-02-06 15:25:11 +0800
committerCarlo Cabrera <30379873+carlocab@users.noreply.github.com>2022-02-06 15:25:11 +0800
commit10000626e1b8b7e823140f4f3f08c729deb543ea (patch)
treebc46b5c55f9885b6edf370f95977886092244a7b /Makefile
parentFix blksize adjustment when exceeding alloca limit in libkeccak_generalised_sum_fd (diff)
downloadlibkeccak-10000626e1b8b7e823140f4f3f08c729deb543ea.tar.gz
libkeccak-10000626e1b8b7e823140f4f3f08c729deb543ea.tar.bz2
libkeccak-10000626e1b8b7e823140f4f3f08c729deb543ea.tar.xz
Fix library install name in `install` target on macOS
On macOS, libraries have "install names" which the linker records in a binary that links against the library. At runtime, the dynamic loader uses this install name to work out where to find the linked library. Currently, the Makefile passes no information about the install name to the linker, and so the DSO has an install name of `libkeccak.dylib`. This is a problem when you link something against `libkeccak` but install it outside the default linker search path, because the dynamic loader won't be able to find it. This change fixes that by making sure the dynamic loader will always be able to find `libkeccak.dylib` regardless of where it's been installed. We use `LIBMAJOREXT` since this is the typical convention for library install names. For example, the system libc++ has an install name of `libc++.1.dylib`, in the same way that `SONAME` also typically includes the library major version on Linux.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile3
1 files changed, 3 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index a6aa425..c52fe9e 100644
--- a/Makefile
+++ b/Makefile
@@ -175,6 +175,9 @@ run-benchmark: benchmark benchfile
for i in $$(seq 7) ; do ./benchmark ; done | median
install: libkeccak.$(LIBEXT) libkeccak.a
+ifeq ($(shell uname),Darwin)
+ install_name_tool -id "$(PREFIX)/lib/libkeccak.$(LIBMAJOREXT)" libkeccak.$(LIBEXT)
+endif
mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
cp -- libkeccak.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBMINOREXT)"
ln -sf -- libkeccak.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libkeccak.$(LIBMAJOREXT)"