5cc7cb
diff -up ghc-7.0.1/compiler/ghc.cabal.in.libffi ghc-7.0.1/compiler/ghc.cabal.in
5cc7cb
--- ghc-7.0.1/compiler/ghc.cabal.in.libffi	2010-11-13 04:10:03.000000000 +1000
5cc7cb
+++ ghc-7.0.1/compiler/ghc.cabal.in	2010-11-16 19:04:28.000000000 +1000
5cc7cb
@@ -83,7 +83,7 @@ Library
5cc7cb
     if flag(ghci)
5cc7cb
         Build-Depends: template-haskell
5cc7cb
         CPP-Options: -DGHCI
5cc7cb
-        Include-Dirs: ../libffi/build/include
5cc7cb
+        pkgconfig-depends: libffi
5cc7cb
 
5cc7cb
     if !flag(ncg)
5cc7cb
         CPP-Options: -DOMIT_NATIVE_CODEGEN
5cc7cb
diff -up ghc-7.0.1/ghc.mk.libffi ghc-7.0.1/ghc.mk
5cc7cb
--- ghc-7.0.1/ghc.mk.libffi	2010-11-13 04:10:05.000000000 +1000
5cc7cb
+++ ghc-7.0.1/ghc.mk	2010-11-16 19:04:28.000000000 +1000
5cc7cb
@@ -437,7 +437,6 @@ utils/runghc/dist/package-data.mk: compi
5cc7cb
 # add the final two package.conf dependencies: ghc-prim depends on RTS,
5cc7cb
 # and RTS depends on libffi.
5cc7cb
 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
5cc7cb
-rts/package.conf.inplace : libffi/package.conf.inplace
5cc7cb
 endif
5cc7cb
 
5cc7cb
 # --------------------------------
5cc7cb
@@ -452,11 +451,6 @@ ALL_STAGE1_LIBS += $(foreach lib,$(PACKA
5cc7cb
 endif
5cc7cb
 BOOT_LIBS = $(foreach lib,$(STAGE0_PACKAGES),$(libraries/$(lib)_dist-boot_v_LIB))
5cc7cb
 
5cc7cb
-OTHER_LIBS = libffi/dist-install/build/libHSffi$(v_libsuf) libffi/dist-install/build/HSffi.o
5cc7cb
-ifeq "$(BuildSharedLibs)" "YES"
5cc7cb
-OTHER_LIBS  += libffi/dist-install/build/libHSffi$(dyn_libsuf)
5cc7cb
-endif
5cc7cb
-
5cc7cb
 # ----------------------------------------
5cc7cb
 # Special magic for the ghc-prim package
5cc7cb
 
5cc7cb
@@ -581,7 +575,6 @@ BUILD_DIRS += \
5cc7cb
    driver/ghci \
5cc7cb
    driver/ghc \
5cc7cb
    driver/haddock \
5cc7cb
-   libffi \
5cc7cb
    includes \
5cc7cb
    rts
5cc7cb
 
5cc7cb
@@ -937,11 +930,10 @@ INSTALL_DISTDIR_compiler = stage2
5cc7cb
 
5cc7cb
 # Now we can do the installation
5cc7cb
 install_packages: install_libexecs
5cc7cb
-install_packages: libffi/package.conf.install rts/package.conf.install
5cc7cb
+install_packages: rts/package.conf.install
5cc7cb
 	$(call INSTALL_DIR,"$(DESTDIR)$(topdir)")
5cc7cb
 	"$(RM)" $(RM_OPTS_REC) "$(INSTALLED_PACKAGE_CONF)"
5cc7cb
 	$(call INSTALL_DIR,"$(INSTALLED_PACKAGE_CONF)")
5cc7cb
-	"$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update libffi/package.conf.install
5cc7cb
 	"$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install
5cc7cb
 	$(foreach p, $(INSTALLED_PKG_DIRS),                           \
5cc7cb
 	    $(call make-command,                                      \
5cc7cb
@@ -1024,7 +1016,7 @@ BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindi
5cc7cb
 unix-binary-dist-prep:
5cc7cb
 	"$(RM)" $(RM_OPTS_REC) bindistprep/
5cc7cb
 	"$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
5cc7cb
-	set -e; for i in packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh extra-gcc-opts.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
5cc7cb
+	set -e; for i in packages LICENSE compiler ghc rts libraries utils docs includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh extra-gcc-opts.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done
5cc7cb
 	echo "HADDOCK_DOCS       = $(HADDOCK_DOCS)"       >> $(BIN_DIST_MK)
5cc7cb
 	echo "LATEX_DOCS         = $(LATEX_DOCS)"         >> $(BIN_DIST_MK)
5cc7cb
 	echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
5cc7cb
@@ -1102,7 +1094,7 @@ SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAM
5cc7cb
 #
5cc7cb
 # Files to include in source distributions
5cc7cb
 #
5cc7cb
-SRC_DIST_DIRS = mk rules docs distrib bindisttest libffi includes utils docs rts compiler ghc driver libraries ghc-tarballs
5cc7cb
+SRC_DIST_DIRS = mk rules docs distrib bindisttest includes utils docs rts compiler ghc driver libraries ghc-tarballs
5cc7cb
 SRC_DIST_FILES += \
5cc7cb
 	configure.ac config.guess config.sub configure \
5cc7cb
 	aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
5cc7cb
diff -up ghc-7.0.1/rts/ghc.mk.libffi ghc-7.0.1/rts/ghc.mk
5cc7cb
--- ghc-7.0.1/rts/ghc.mk.libffi	2010-11-13 04:10:06.000000000 +1000
5cc7cb
+++ ghc-7.0.1/rts/ghc.mk	2010-11-16 19:06:09.000000000 +1000
5cc7cb
@@ -430,15 +430,15 @@ endif
5cc7cb
 
5cc7cb
 $(eval $(call build-dependencies,rts,dist,1))
5cc7cb
 
5cc7cb
-$(rts_dist_depfile_c_asm) : libffi/dist-install/build/ffi.h $(DTRACEPROBES_H)
5cc7cb
+$(rts_dist_depfile_c_asm) : $(DTRACEPROBES_H)
5cc7cb
 
5cc7cb
 #-----------------------------------------------------------------------------
5cc7cb
 # libffi stuff
5cc7cb
 
5cc7cb
-rts_CC_OPTS     += -Ilibffi/build/include
5cc7cb
-rts_HC_OPTS     += -Ilibffi/build/include
5cc7cb
-rts_HSC2HS_OPTS += -Ilibffi/build/include
5cc7cb
-rts_LD_OPTS     += -Llibffi/build/include
5cc7cb
+rts_CC_OPTS     += $(shell pkg-config --cflags libffi)
5cc7cb
+rts_HC_OPTS     += $(shell pkg-config --cflags libffi)
5cc7cb
+rts_HSC2HS_OPTS += $(shell pkg-config --cflags libffi)
5cc7cb
+rts_LD_OPTS     += $(shell pkg-config --libs libffi)
5cc7cb
 
5cc7cb
 # -----------------------------------------------------------------------------
5cc7cb
 # compile dtrace probes if dtrace is supported
5cc7cb
diff -up ghc-7.0.1/rts/package.conf.in.libffi ghc-7.0.1/rts/package.conf.in
5cc7cb
--- ghc-7.0.1/rts/package.conf.in.libffi	2010-11-13 04:10:06.000000000 +1000
5cc7cb
+++ ghc-7.0.1/rts/package.conf.in	2010-11-16 19:04:28.000000000 +1000
5cc7cb
@@ -24,8 +24,9 @@ library-dirs:		TOP"/rts/dist/build" PAPI
5cc7cb
 hs-libraries:   "HSrts"
5cc7cb
 
5cc7cb
 extra-libraries:
5cc7cb
+				"ffi"
5cc7cb
 #ifdef HAVE_LIBM
5cc7cb
-                		"m"		/* for ldexp() */
5cc7cb
+			      , "m"		/* for ldexp() */
5cc7cb
 #endif
5cc7cb
 #ifdef HAVE_LIBRT
5cc7cb
 			      , "rt"
5cc7cb
@@ -55,7 +56,6 @@ include-dirs:		TOP"/includes"
5cc7cb
 #endif
5cc7cb
 
5cc7cb
 includes:		Stg.h
5cc7cb
-depends:	 	builtin_ffi
5cc7cb
 hugs-options:
5cc7cb
 cc-options:
5cc7cb