Skip to content
Snippets Groups Projects
Commit 41ffbf76 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Going one step further and completely overwriting any -rpath settings

specified in environment. This is to support local development, so that
exes can be executed from $FSLDIR/src/<project>/<exe> and that libs in
$FSLDIR/src/<project>/ will take precedence over those in $FSLDIR/lib/
parent 6da93f41
No related branches found
No related tags found
1 merge request!27MNT: rpath
Pipeline #11430 passed
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
# get system type (Darwin, Linux) # get system type (Darwin, Linux)
SYSTYPE := $(shell uname -s) SYSTYPE := $(shell uname -s)
# For string substitution
COMMA := ,
##################################################################### #####################################################################
# #
# Standard commands # Standard commands
...@@ -77,6 +80,21 @@ ARCHNVCCLDFLAGS = ...@@ -77,6 +80,21 @@ ARCHNVCCLDFLAGS =
# macOS. # macOS.
# #
##################################################################### #####################################################################
# 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/).
_LDFLAGS := $(patsubst -Wl${COMMA}-rpath%,,${LDFLAGS})
LDFLAGS = ${_LDFLAGS}
ifeq ($(SYSTYPE), Darwin) ifeq ($(SYSTYPE), Darwin)
# CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS # CC, CXX, CFLAGS, CXXFLAGS, and LDFLAGS
...@@ -85,14 +103,7 @@ ifeq ($(SYSTYPE), Darwin) ...@@ -85,14 +103,7 @@ ifeq ($(SYSTYPE), Darwin)
CXX ?= clang++ CXX ?= clang++
CFLAGS ?= -arch x86_64 -Wall -pedantic CFLAGS ?= -arch x86_64 -Wall -pedantic
CXXFLAGS ?= -arch x86_64 -Wall -pedantic CXXFLAGS ?= -arch x86_64 -Wall -pedantic
LDFLAGS += -Wl,-rpath,"@executable_path/" \
# Set rpath so that executables will be
# able to find libs in $FSLDIR/lib, and
# in $(pwd) (for execution from project
# source dir). Same below for linux.
LDFLAGS ?=
LDFLAGS += -Wl,-rpath,"@executable_path/" \
-Wl,-rpath,"@executable_path/../lib" \
-Wl,-rpath,"${FSLDIR}/lib" -Wl,-rpath,"${FSLDIR}/lib"
ARCHLIBS += -llapack -lblas -lz -lm ARCHLIBS += -llapack -lblas -lz -lm
...@@ -121,10 +132,8 @@ ifeq ($(SYSTYPE), Linux) ...@@ -121,10 +132,8 @@ ifeq ($(SYSTYPE), Linux)
-Wall -pedantic -Wno-long-long -Wall -pedantic -Wno-long-long
CXXFLAGS ?= -fexpensive-optimizations \ CXXFLAGS ?= -fexpensive-optimizations \
-Wall -pedantic -Wno-long-long -Wall -pedantic -Wno-long-long
LDFLAGS ?= LDFLAGS += -Wl,-rpath,'$$ORIGIN:${FSLDIR}/lib' \
LDFLAGS += -Wl,-rpath='$$ORIGIN' \ -Wl,-rpath-link,'$$ORIGIN:${FSLDIR}/lib'
-Wl,-rpath='$$ORIGIN/../lib' \
-Wl,-rpath="${FSLDIR}/lib"
ARCHLIBS += -lopenblas -lz -lm ARCHLIBS += -lopenblas -lz -lm
endif endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment