Index: ghc6-6.12.1/ghc.mk
===================================================================
--- ghc6-6.12.1.orig/ghc.mk	2010-01-09 20:17:29.000000000 +0200
+++ ghc6-6.12.1/ghc.mk	2010-01-09 20:18:15.000000000 +0200
@@ -367,11 +367,6 @@
 endif
 BOOT_LIBS = $(foreach lib,$(BOOT_PKGS),$(libraries/$(lib)_dist-boot_v_LIB))
 
-OTHER_LIBS = libffi/dist-install/build/libHSffi$(v_libsuf) libffi/dist-install/build/HSffi.o
-ifeq "$(BuildSharedLibs)" "YES"
-OTHER_LIBS  += libffi/dist-install/build/libHSffi$(dyn_libsuf)
-endif
-
 # We cannot run ghc-cabal to configure a package until we have
 # configured and registered all of its dependencies.  So the following
 # hack forces all the configure steps to happen in exactly the order
@@ -404,7 +399,6 @@
 # add the final two package.conf dependencies: ghc-prim depends on RTS,
 # and RTS depends on libffi.
 libraries/ghc-prim/dist-install/package-data.mk : rts/package.conf.inplace
-rts/package.conf.inplace : libffi/package.conf.inplace
 endif
 
 # -----------------------------------------------------------------------------
@@ -515,7 +509,6 @@
    driver \
    driver/ghci \
    driver/ghc \
-   libffi \
    includes \
    rts
 
@@ -865,11 +858,10 @@
                          $(addprefix libraries/,$(PACKAGES_STAGE2))
 
 install_packages: install_libexecs
-install_packages: libffi/package.conf.install rts/package.conf.install
+install_packages: rts/package.conf.install
 	$(INSTALL_DIR) "$(DESTDIR)$(topdir)"
 	"$(RM)" -r $(RM_OPTS) "$(INSTALLED_PACKAGE_CONF)"
 	$(INSTALL_DIR) "$(INSTALLED_PACKAGE_CONF)"
-	"$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update libffi/package.conf.install
 	"$(INSTALLED_GHC_PKG_REAL)" --force --global-conf "$(INSTALLED_PACKAGE_CONF)" update rts/package.conf.install
 	$(foreach p, $(ALL_INSTALLED_PACKAGES),\
 	    "$(GHC_CABAL_INPLACE)" install \
@@ -943,7 +935,7 @@
 unix-binary-dist-prep:
 	"$(RM)" $(RM_OPTS) -r bindistprep/
 	"$(MKDIRHIER)" $(BIN_DIST_PREP_DIR)
-	set -e; for i in 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
+	set -e; for i in 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
 	echo "HADDOCK_DOCS       = $(HADDOCK_DOCS)"       >> $(BIN_DIST_MK)
 	echo "LATEX_DOCS         = $(LATEX_DOCS)"         >> $(BIN_DIST_MK)
 	echo "BUILD_DOCBOOK_HTML = $(BUILD_DOCBOOK_HTML)" >> $(BIN_DIST_MK)
@@ -1009,7 +1001,7 @@
 #
 # Files to include in source distributions
 #
-SRC_DIST_DIRS = mk rules docs distrib bindisttest libffi includes utils docs rts compiler ghc driver libraries ghc-tarballs
+SRC_DIST_DIRS = mk rules docs distrib bindisttest includes utils docs rts compiler ghc driver libraries ghc-tarballs
 SRC_DIST_FILES += \
 	configure.ac config.guess config.sub configure \
 	aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh \
Index: ghc6-6.12.1/rts/ghc.mk
===================================================================
--- ghc6-6.12.1.orig/rts/ghc.mk	2010-01-09 20:17:29.000000000 +0200
+++ ghc6-6.12.1/rts/ghc.mk	2010-01-09 20:18:15.000000000 +0200
@@ -322,15 +322,13 @@
 
 $(eval $(call build-dependencies,rts,dist))
 
-$(rts_dist_depfile) : libffi/dist-install/build/ffi.h
-
 #-----------------------------------------------------------------------------
 # libffi stuff
 
-rts_CC_OPTS     += -Ilibffi/build/include
-rts_HC_OPTS     += -Ilibffi/build/include
-rts_HSC2HS_OPTS += -Ilibffi/build/include
-rts_LD_OPTS     += -Llibffi/build/include
+rts_CC_OPTS     += $(shell pkg-config --cflags libffi)
+rts_HC_OPTS     += $(shell pkg-config --cflags libffi)
+rts_HSC2HS_OPTS += $(shell pkg-config --cflags libffi)
+rts_LD_OPTS     += $(shell pkg-config --libs libffi)
 
 # -----------------------------------------------------------------------------
 # compile generic patchable dyn-wrapper
Index: ghc6-6.12.1/rts/package.conf.in
===================================================================
--- ghc6-6.12.1.orig/rts/package.conf.in	2010-01-09 20:17:29.000000000 +0200
+++ ghc6-6.12.1/rts/package.conf.in	2010-01-09 20:19:26.000000000 +0200
@@ -28,6 +28,7 @@
 hs-libraries:   "HSrts"
 
 extra-libraries:		"m"		/* for ldexp() */
+			      , "ffi"
 #ifdef HAVE_LIBRT
 			      , "rt"
 #endif
@@ -56,7 +57,6 @@
 #endif
 
 includes:		Stg.h
-depends:	 	builtin_ffi
 hugs-options:
 cc-options:
 
