Fix specification of -z origin for gold.
[ghc.git] / rules / relative-dynlib-references.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 # http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13
14 # Make dynlib references use relative paths, so that everything works
15 # without the build tree.
16
17 define relative-dynlib-references
18 # $1 = dir
19 # $2 = distdir
20 # $3 = GHC stage to use (0 == bootstrapping compiler)
21 # $4 = RTSway
22
23 ifeq "$$(TargetOS_CPP)" "darwin"
24 ifneq "$3" "0"
25 # Use relative paths for all the libraries
26 ifneq "$$($1_$2_TRANSITIVE_DEP_NAMES)" ""
27 install_name_tool $$(foreach d,$$($1_$2_TRANSITIVE_DEP_NAMES), -change $$(TOP)/$$($$($$d_INSTALL_INFO)_dyn_LIB) @rpath/$$d-$$($$($$d_INSTALL_INFO)_VERSION)/$$($$($$d_INSTALL_INFO)_dyn_LIB_NAME)) $$@
28 endif
29 # Change absolute library name/path to a relative name/path
30 ifeq "$$($1_$2_PROGNAME)" ""
31 ifeq "$1" "rts"
32 install_name_tool -id @rpath/rts-$$(rts_VERSION)/$$(rts_$4_LIB_NAME) $$@
33 else
34 install_name_tool -id @rpath/$$($1_PACKAGE)-$$($1_$2_VERSION)/$$($1_$2_dyn_LIB_NAME) $$@
35 endif
36 endif
37 # Use relative paths for the RTS. Rather than try to work out which RTS
38 # way is being linked, we just change it for all ways
39 install_name_tool $$(foreach w,$$(rts_WAYS), -change $$(TOP)/$$(rts_$$w_LIB) @rpath/rts-$$(rts_VERSION)/$$(rts_$$w_LIB_NAME)) $$@
40 install_name_tool -change $$(TOP)/$$(wildcard libffi/build/inst/lib/libffi.*.dylib) @rpath/rts-$$(rts_VERSION)/libffi.dylib $$@
41 endif
42 endif
43
44 endef
45
46 define relative-dynlib-path
47 # $1 = GHC stage to use (0 == bootstrapping compiler)
48
49 ifeq "$$(TargetOS_CPP)" "darwin"
50 ifneq "$1" "0"
51 install_name_tool -rpath $$(TOP)/inplace/lib @loader_path/.. $$@
52 endif
53 endif
54
55 endef