summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ghc.mk5
-rw-r--r--rules/build-package-way.mk1
-rw-r--r--rules/build-prog.mk14
-rw-r--r--rules/relative-dynlib-references.mk35
4 files changed, 43 insertions, 12 deletions
diff --git a/ghc.mk b/ghc.mk
index e337ddd35f..87b6ac884c 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -283,6 +283,11 @@ include rules/build-dependencies.mk
include rules/include-dependencies.mk
# -----------------------------------------------------------------------------
+# Dynamic library references
+
+include rules/relative-dynlib-references.mk
+
+# -----------------------------------------------------------------------------
# Build package-data.mk files
include rules/build-package-data.mk
diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk
index b772317bdd..780b8b0f48 100644
--- a/rules/build-package-way.mk
+++ b/rules/build-package-way.mk
@@ -91,6 +91,7 @@ $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
$$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) $$(addprefix -L,$$($1_$2_EXTRA_LIBDIRS)) \
-no-auto-link-packages \
-o $$@
+ $(call relative-dynlib-references,$1,$2,$4)
endif
else
# Build the ordinary .a library
diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index 17d64da1c9..8c49946f1c 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -260,19 +260,9 @@ else
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_$$($1_$2_PROGRAM_WAY)_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
-ifneq "$$($1_$2_TRANSITIVE_DEP_NAMES)" ""
- 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)) $$@
-endif
-# 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/../rts-$$(rts_VERSION)/$$(rts_$$w_LIB_NAME)) $$@
- install_name_tool -change $$(TOP)/$$(wildcard libffi/build/inst/lib/libffi.*.dylib) @loader_path/../rts-$$(rts_VERSION)/libffi.dylib $$@
-endif
-endif
+ $(call relative-dynlib-references,$1,$2,$3)
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 $$$$@)/.
diff --git a/rules/relative-dynlib-references.mk b/rules/relative-dynlib-references.mk
new file mode 100644
index 0000000000..03dabc1453
--- /dev/null
+++ b/rules/relative-dynlib-references.mk
@@ -0,0 +1,35 @@
+# -----------------------------------------------------------------------------
+#
+# (c) 2009 The University of Glasgow
+#
+# This file is part of the GHC build system.
+#
+# To understand how the build system works and how to modify it, see
+# http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
+# http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
+#
+# -----------------------------------------------------------------------------
+
+
+# Make dynlib references use relative paths, so that everything works
+# without the build tree.
+
+define relative-dynlib-references
+# $1 = dir
+# $2 = distdir
+# $3 = GHC stage to use (0 == bootstrapping compiler)
+
+ifeq "$$(TargetOS_CPP)" "darwin"
+ifneq "$3" "0"
+# Use relative paths for all the libraries
+ifneq "$$($1_$2_TRANSITIVE_DEP_NAMES)" ""
+ 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)) $$@
+endif
+# 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/../rts-$$(rts_VERSION)/$$(rts_$$w_LIB_NAME)) $$@
+ install_name_tool -change $$(TOP)/$$(wildcard libffi/build/inst/lib/libffi.*.dylib) @loader_path/../rts-$$(rts_VERSION)/libffi.dylib $$@
+endif
+endif
+
+endef