Link all dynamic libraries with the correct install_name on Mac OS/X.
[ghc-hetmet.git] / libffi / ghc.mk
index 7104d04..92e11dd 100644 (file)
@@ -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