On non-Windows, go back to using the libffi dynlib for the dyn way
authorIan Lynagh <igloo@earth.li>
Sun, 16 Oct 2011 20:37:16 +0000 (21:37 +0100)
committerIan Lynagh <igloo@earth.li>
Sun, 16 Oct 2011 20:37:16 +0000 (21:37 +0100)
libffi/ghc.mk
rts/ghc.mk

index 22ce638..a693bcb 100644 (file)
 # -----------------------------------------------------------------------------
 
 
-libffi_STAMP_CONFIGURE = libffi/stamp.ffi.configure
-libffi_STAMP_BUILD     = libffi/stamp.ffi.build
-libffi_STAMP_INSTALL   = libffi/stamp.ffi.install
+libffi_STAMP_STATIC_CONFIGURE = libffi/stamp.ffi.static.configure
+libffi_STAMP_STATIC_BUILD     = libffi/stamp.ffi.static.build
+libffi_STAMP_STATIC_INSTALL   = libffi/stamp.ffi.static.install
+
+libffi_STAMP_STATIC_SHARED_CONFIGURE = libffi/stamp.ffi.static-shared.configure
+libffi_STAMP_STATIC_SHARED_BUILD     = libffi/stamp.ffi.static-shared.build
+libffi_STAMP_STATIC_SHARED_INSTALL   = libffi/stamp.ffi.static-shared.install
+
+ifeq "$(BuildSharedLibs)" "YES"
+libffi_STAMP_CONFIGURE = $(libffi_STAMP_STATIC_SHARED_CONFIGURE)
+libffi_STAMP_BUILD     = $(libffi_STAMP_STATIC_SHARED_BUILD)
+libffi_STAMP_INSTALL   = $(libffi_STAMP_STATIC_SHARED_INSTALL)
+libffi_EnableShared    = yes
+else
+libffi_STAMP_CONFIGURE = $(libffi_STAMP_STATIC_CONFIGURE)
+libffi_STAMP_BUILD     = $(libffi_STAMP_STATIC_BUILD)
+libffi_STAMP_INSTALL   = $(libffi_STAMP_STATIC_INSTALL)
+libffi_EnableShared    = no
+endif
 
 libffi_STATIC_LIB  = libffi/build/inst/lib/libffi.a
 ffi_HEADER         = rts/dist/build/ffi.h
 
 ifneq "$(BINDIST)" "YES"
 $(libffi_STAMP_CONFIGURE):
+       "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_CONFIGURE)
+       "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_BUILD)
+       "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_INSTALL)
+       "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_SHARED_CONFIGURE)
+       "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_SHARED_BUILD)
+       "$(RM)" $(RM_OPTS) $(libffi_STAMP_STATIC_SHARED_INSTALL)
        "$(RM)" $(RM_OPTS_REC) $(LIBFFI_DIR) libffi/build
        cat ghc-tarballs/libffi/libffi*.tar.gz | $(GZIP_CMD) -d | { cd libffi && $(TAR_CMD) -xf - ; }
        mv libffi/libffi-* libffi/build
@@ -43,9 +65,8 @@ $(libffi_STAMP_CONFIGURE):
         LDFLAGS="$(SRC_LD_OPTS) $(CONF_GCC_LINKER_OPTS_STAGE1) -w" \
         "$(SHELL)" configure \
                  --prefix=$(TOP)/libffi/build/inst \
-                 --with-pic \
                  --enable-static=yes \
-                 --enable-shared=no \
+                 --enable-shared=$(libffi_EnableShared) \
                  --host=$(HOSTPLATFORM) --build=$(BUILDPLATFORM)
 
        # wc on OS X has spaces in its output, which libffi's Makefile
index a007f1a..fa118c1 100644 (file)
@@ -21,7 +21,7 @@ rts_WAYS = $(GhcLibWays) $(filter-out $(GhcLibWays),$(GhcRTSWays))
 rts_dist_WAYS = $(rts_WAYS)
 
 ALL_RTS_LIBS = rts/dist/build/libHSrtsmain.a \
-              $(foreach way,$(rts_WAYS),rts/dist/build/libHSrts$($(way)_libsuf))
+             $(foreach way,$(rts_WAYS),rts/dist/build/libHSrts$($(way)_libsuf))
 all_rts : $(ALL_RTS_LIBS)
 
 # -----------------------------------------------------------------------------
@@ -119,6 +119,18 @@ rts/dist/build/win32/libHSffi.dll.a : rts/dist/build/win32/libHSffi.def
 endif
 endif
 
+ifneq "$(BINDIST)" "YES"
+rts_ffi_objs_stamp = rts/dist/ffi/stamp
+rts_ffi_objs       = rts/dist/ffi/*.o
+$(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) | $$(dir $$@)/.
+       cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB)
+       touch $@
+
+# This is a little hacky. We don't know the SO version, so we only
+# depend on libffi.so, but copy libffi.so*
+rts/dist/build/libffi$(soext): libffi/build/inst/lib/libffi$(soext)
+       cp libffi/build/inst/lib/libffi$(soext)* rts/dist/build
+endif
 
 #-----------------------------------------------------------------------------
 # Building one way
@@ -177,14 +189,14 @@ $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend
        "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
          -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
 else
-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend $$(rts_ffi_objs_stamp)
+$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend rts/dist/build/libffi$$(soext)
        "$$(RM)" $$(RM_OPTS) $$@
        "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
-         -no-auto-link-packages `cat rts/libs.depend` $$(rts_ffi_objs) $$(rts_$1_OBJS) \
+         -no-auto-link-packages -Lrts/dist/build -lffi `cat rts/libs.depend` $$(rts_$1_OBJS) \
          $$(rts_$1_DTRACE_OBJS) -o $$@
 ifeq "$$(darwin_HOST_OS)" "1"
        # Ensure library's install name is correct before anyone links with it.
-       install_name_tool -id $(ghclibdir)/$$(rts_$1_LIB_NAME) $$@
+       install_name_tool -id $$(ghclibdir)/$$(rts_$1_LIB_NAME) $$@
 endif
 endif
 else
@@ -198,12 +210,6 @@ endif
 
 endef
 
-rts_ffi_objs_stamp = rts/dist/ffi/stamp
-rts_ffi_objs       = rts/dist/ffi/*.o
-$(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) | $$(dir $$@)/.
-       cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB)
-       touch $@
-
 # And expand the above for each way:
 $(foreach way,$(rts_WAYS),$(eval $(call build-rts-way,$(way))))
 
@@ -519,6 +525,7 @@ endif
 # installing
 
 INSTALL_LIBS += $(ALL_RTS_LIBS)
+INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
 
 # -----------------------------------------------------------------------------
 # cleaning