diff --git a/CHANGELOG.md b/CHANGELOG.md index 07a0075ff018c69017abc408adbdbbf8d9863322..ef0873df006c602e2f1a32b7b50e518d9a98cbd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # FSL base project changelog +## 2111.3 (Wednesday 17th November 2021) + +* The `$FSLDEVDIR/lib` directory is now added to the `rpath` entry for shared + libraries and executables, if `$FSLDEVDIR` is different from `$FSLDIR`. + + ## 2111.2 (Monday 15th November 2021) * Added the `FSL_GE_606` `Makefile` flag for use by projects which need to diff --git a/config/buildSettings.mk b/config/buildSettings.mk index 8ce6319b596b36e26467c67b96db86022315af83..4ecc214eaa02221105cbb687c9c6987967fb2ac7 100644 --- a/config/buildSettings.mk +++ b/config/buildSettings.mk @@ -78,17 +78,19 @@ ARCHNVCCLDFLAGS = # ##################################################################### -# Drop -rpath flags from LDFLAGS if it is -# set in the environment - we explicitly -# add them below such that executables -# will be able to find libs in $(pwd) and -# in $FSLDIR/lib *in that order*. This is -# so that executables located in the -# project source dir can be executed in -# place with sensible behaviour (i.e. any -# shared libs located in the same dir will -# take precedence over libs of the same -# name in $FSLDIR/lib/). +# Drop -rpath flags from LDFLAGS if it is set in +# the environment - we explicitly add them below +# such that executables will be able to find libs +# in $(pwd), $FSLDEVDIR/lib, and $FSLDIR/lib *in +# that order*. This is so that executables +# located in the project source dir can be +# executed in place with sensible behaviour (i.e. +# any shared libs located in the same dir will +# take precedence over libs of the same name in +# $FSLDIR/lib/). +# +# Fortunately -Wl,-rpath is used for both g++ and +# clang, so we can cover both with one substitution. COMMA := , _LDFLAGS := $(patsubst -Wl${COMMA}-rpath%,,${LDFLAGS}) LDFLAGS = ${_LDFLAGS} @@ -101,8 +103,12 @@ ifeq ($(SYSTYPE), Darwin) CXX ?= clang++ CFLAGS ?= -arch x86_64 -Wall -pedantic CXXFLAGS ?= -arch x86_64 -Wall -pedantic - LDFLAGS += -Wl,-rpath,"@executable_path/" \ - -Wl,-rpath,"${FSLDIR}/lib" + LDFLAGS += -Wl,-rpath,"@executable_path/" + # Only add FSLDEVDIR if different to FSLDIR + ifneq (${FSLDEVDIR}, ${FSLDIR}) + LDFLAGS += -Wl,-rpath,"${FSLDEVDIR}/lib" + endif + LDFLAGS += -Wl,-rpath,"${FSLDIR}/lib" ARCHLIBS += -llapack -lblas -lz -lm # On macOS, we need to change the install @@ -131,8 +137,15 @@ ifeq ($(SYSTYPE), Linux) -Wall -pedantic -Wno-long-long CXXFLAGS ?= -fexpensive-optimizations \ -Wall -pedantic -Wno-long-long - LDFLAGS += -Wl,-rpath,'$$ORIGIN:${FSLDIR}/lib' \ - -Wl,-rpath-link,'$$ORIGIN:${FSLDIR}/lib' + LDFLAGS += -Wl,-rpath,'$$ORIGIN' \ + -Wl,-rpath-link,'$$ORIGIN' + # Only add FSLDEVDIR if different to FSLDIR + ifneq (${FSLDEVDIR}, ${FSLDIR}) + LDFLAGS += -Wl,-rpath,'${FSLDEVDIR}/lib' \ + -Wl,-rpath-link,'${FSLDEVDIR}/lib' + endif + LDFLAGS += -Wl,-rpath,'${FSLDIR}/lib' \ + -Wl,-rpath-link,'${FSLDIR}/lib' ARCHLIBS += -lopenblas -lz -lm endif