summaryrefslogtreecommitdiff
path: root/rules/build-prog.mk
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2012-10-14 13:36:08 +0100
committerIan Lynagh <igloo@earth.li>2012-10-14 15:31:07 +0100
commit0271742138ffc55d992be549c027ae690fde5080 (patch)
treefa99b538693da25f282f0e2752083c95d2f3e427 /rules/build-prog.mk
parent8c24ab98cde96ce20dea6a9280231d978ffc7690 (diff)
downloadhaskell-0271742138ffc55d992be549c027ae690fde5080.tar.gz
Get dynamic-by-default mostly working on OS X
Diffstat (limited to 'rules/build-prog.mk')
-rw-r--r--rules/build-prog.mk15
1 files changed, 15 insertions, 0 deletions
diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index a0cb9e64ce..df96598586 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -173,9 +173,13 @@ endif
ifneq "$3" "0"
ifeq "$$(DYNAMIC_BY_DEFAULT)" "YES"
+ifeq "$$(TargetOS_CPP)" "linux"
$1_$2_GHC_LD_OPTS = \
-fno-use-rpaths \
$$(foreach d,$$($1_$2_TRANSITIVE_DEPS),-optl-Wl$$(comma)-rpath -optl-Wl$$(comma)'$$$$ORIGIN/../$$d')
+else ifeq "$$(TargetOS_CPP)" "darwin"
+$1_$2_GHC_LD_OPTS = -optl-Wl,-headerpad_max_install_names
+endif
endif
endif
@@ -194,6 +198,17 @@ $1/$2/build/tmp/$$($1_$2_PROG) : \
ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
$$(call cmd,$1_$2_HC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_GHC_LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))
+ifeq "$$(TargetOS_CPP)" "darwin"
+ifneq "$3" "0"
+ifeq "$$($1_$2_PROGRAM_WAY)" "dyn"
+# Use relative paths for all the libraries
+ install_name_tool $$(foreach d,$$($1_$2_TRANSITIVE_DEP_NAMES), -change $$(TOP)/$$($$($$d_INSTALL_INFO)_dyn_LIB) @loader_path/../$$d-$$($$($$d_INSTALL_INFO)_VERSION)/$$($$($$d_INSTALL_INFO)_dyn_LIB_NAME)) $$@
+# Use relative paths for the RTS. Rather than try to work out which RTS
+# way is being linked, we just change it for all ways
+ install_name_tool $$(foreach w,$$(rts_WAYS), -change $$(TOP)/$$(rts_$$w_LIB) @loader_path/../$$d-$$(rts_VERSION)/$$(rts_$$w_LIB_NAME)) $$@
+endif
+endif
+endif
else
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
$$(call cmd,$1_$2_CC) -o $$@ $$($1_$2_$$($1_$2_PROGRAM_WAY)_ALL_CC_OPTS) $$(LD_OPTS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_C_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_S_OBJS) $$($1_$2_OTHER_OBJS) $$($1_$2_$$($1_$2_PROGRAM_WAY)_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES))