Commit 3e18f8be authored by Ian Lynagh's avatar Ian Lynagh

Link all dynamic libraries with the correct install_name on Mac OS/X.

This is a rerecord of
    Stephen Blackheath <oversensitive.pastors.stephen@blacksapphire.com>**20090930222855
to avoid conflicts.
parent 5c2220aa
......@@ -751,9 +751,6 @@ install_bins: $(INSTALL_BINS)
$(INSTALL_DIR) "$(DESTDIR)$(bindir)"
for i in $(INSTALL_BINS); do \
$(INSTALL_PROGRAM) $(INSTALL_BIN_OPTS) $$i "$(DESTDIR)$(bindir)" ; \
if test "$(darwin_TARGET_OS)" = "1"; then \
sh mk/fix_install_names.sh $(ghclibdir) "$(DESTDIR)$(bindir)/$$i" ; \
fi ; \
done
install_libs: $(INSTALL_LIBS)
......@@ -768,8 +765,7 @@ install_libs: $(INSTALL_LIBS)
*.so) \
$(INSTALL_SHLIB) $(INSTALL_OPTS) $$i "$(DESTDIR)$(ghclibdir)" ;; \
*.dylib) \
$(INSTALL_SHLIB) $(INSTALL_OPTS) $$i "$(DESTDIR)$(ghclibdir)"; \
install_name_tool -id "$(DESTDIR)$(ghclibdir)/`basename $$i`" "$(DESTDIR)$(ghclibdir)/`basename $$i`" ;; \
$(INSTALL_SHLIB) $(INSTALL_OPTS) $$i "$(DESTDIR)$(ghclibdir)";; \
*) \
$(INSTALL_DATA) $(INSTALL_OPTS) $$i "$(DESTDIR)$(ghclibdir)"; \
esac; \
......@@ -930,7 +926,6 @@ $(eval $(call bindist,.,\
$(wildcard libraries/*/dist-install/doc/) \
$(filter-out extra-gcc-opts,$(INSTALL_LIBS)) \
$(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \
mk/fix_install_names.sh \
mk/project.mk \
mk/install.mk.in \
bindist.mk \
......
......@@ -84,10 +84,14 @@ libffi_DYNAMIC_PROG = $(libffi_HS_DYN_LIB).a
libffi_DYNAMIC_LIBS = $(libffi_HS_DYN_LIB)
else
libffi_DYNAMIC_PROG =
ifeq "$(darwin_TARGET_OS)" "1"
libffi_DYNAMIC_LIBS = libffi/libffi$(soext) libffi/libffi.5$(soext) libffi/libffi.5.0.9$(soext)
else
libffi_DYNAMIC_LIBS = libffi/dist-install/build/libffi.so \
libffi/dist-install/build/libffi.so.5 \
libffi/dist-install/build/libffi.so.5.0.9
endif
endif
ifeq "$(BuildSharedLibs)" "YES"
libffi_EnableShared=yes
......@@ -200,6 +204,10 @@ $(libffi_DYNAMIC_LIBS): $(libffi_STAMP_BUILD)
# Rename libffi.so to libHSffi...so
$(libffi_HS_DYN_LIB): $(libffi_DYNAMIC_LIBS) | $$(dir $$@)/.
"$(CP)" $(word 1,$(libffi_DYNAMIC_LIBS)) $(libffi_HS_DYN_LIB)
ifeq "$(darwin_TARGET_OS)" "1"
# Ensure library's install name is correct before anyone links with it.
install_name_tool -id $(ghclibdir)/$(libffi_HS_DYN_LIB_NAME) $(libffi_HS_DYN_LIB)
endif
$(eval $(call all-target,libffi,$(libffi_HS_DYN_LIB)))
endif
......
# Darwin / Mac OS X only
# sh fix_install_names.sh directory binary
#
# Changes 'binary' to assume that all libHS*_dyn.dylib libraries
# are to be found in 'directory'.
prefix=$1
file=$2
type=`file "$file"`
if `test "${type/Mach-O}" == "$type"`
then
exit
fi
if `test x${prefix%/} != x"" `
then
prefix=${prefix%/}/
fi
for i in `otool -L $file \
| grep 'libHS.*_dyn.dylib' \
| sed 's/.\(.*libHS.*_dyn.dylib\).*/\1/'`
do
install_name_tool -change $i "$prefix`basename $i`" $file
done
if `test "${file%.dylib}" != "${file}"`
then
install_name_tool -id "$prefix`basename $file`" $file
fi
......@@ -141,7 +141,8 @@ $(call cmm-suffix-rules,rts,dist,$1)
$(call hs-suffix-rules-srcdir,rts,dist,$1,$$(dir))
# hs-suffix-rules-srcdir is needed when BootingFromHc to get the .hc rules
rts_$1_LIB = rts/dist/build/libHSrts$$($1_libsuf)
rts_$1_LIB_NAME = libHSrts$$($1_libsuf)
rts_$1_LIB = rts/dist/build/$$(rts_$1_LIB_NAME)
rts_$1_C_OBJS = $$(patsubst rts/%.c,rts/dist/build/%.$$($1_osuf),$$(rts_C_SRCS)) $$(patsubst %.c,%.$$($1_osuf),$$(rts_$1_EXTRA_C_SRCS))
rts_$1_S_OBJS = $$(patsubst rts/%.S,rts/dist/build/%.$$($1_osuf),$$(rts_S_SRCS))
......@@ -158,6 +159,10 @@ $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend
"$$(RM)" $$(RM_OPTS) $$@
"$$(rts_dist_HC)" -shared -dynamic -dynload deploy \
-no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
ifeq "$(darwin_TARGET_OS)" "1"
# Ensure library's install name is correct before anyone links with it.
install_name_tool -id $(ghclibdir)/$$(rts_$1_LIB_NAME) $$@
endif
else
$$(rts_$1_LIB) : $$(rts_$1_OBJS) rts/libs.depend
"$$(RM)" $$(RM_OPTS) $$@
......
......@@ -67,6 +67,7 @@ $$($1_$2_$3_LIB) : $$($1_$2_$3_ALL_OBJS) $$(ALL_RTS_LIBS) $$($1_$2_$3_DEPS_LIBS)
"$$($1_$2_HC)" $$($1_$2_$3_ALL_OBJS) \
`$$($1_$2_$3_MKSTUBOBJS)` \
-shared -dynamic -dynload deploy \
-dylib-install-name $(ghclibdir)/`basename "$$@" | sed 's/^libHS//;s/[-]ghc.*//'`/`basename "$$@"` \
-no-auto-link-packages $$(addprefix -package,$$($1_$2_DEPS)) \
-o $$@
endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment