aboutsummaryrefslogtreecommitdiff
path: root/lang/ghc/files
diff options
context:
space:
mode:
authorGabor Pali <pgj@FreeBSD.org>2013-02-05 22:26:31 +0000
committerGabor Pali <pgj@FreeBSD.org>2013-02-05 22:26:31 +0000
commitc731105b7f8e403a3db33599a7d7f1ce9257f375 (patch)
tree23d3f49a5183d8fbc5324dad9a1ae399f457b1d7 /lang/ghc/files
parent32ca3ee61e3889801319024959589312eb652bfa (diff)
downloadports-c731105b7f8e403a3db33599a7d7f1ce9257f375.tar.gz
ports-c731105b7f8e403a3db33599a7d7f1ce9257f375.zip
- Fix breakage in the DYNAMIC-enabled ports triggered by the recent
devel/libffi update - Enable multithreaded build for lang/ghc (i.e. mark MAKE_JOBS_SAFE) Please note that port revision for all the Haskell ports without version changes are bumped. New ports (20): devel/hs-MonadRandom 0.1.8 devel/hs-base64-conduit 0.5.1 devel/hs-bifunctors 3.2 devel/hs-either 3.1 devel/hs-errors 1.3.1 devel/hs-generic-deriving 1.4.0 devel/hs-lens 3.8.5 devel/hs-profunctor-extras 3.3 devel/hs-profunctors 3.2 devel/hs-reflection 1.1.6 devel/hs-timezone-olson 0.1.2 devel/hs-timezone-series 0.1.2 math/hs-comonads-fd 3.0.1 math/hs-groupoids 3.0.1.1 math/hs-nats 0.1 math/hs-semigroupoid-extras 3.0.1 security/hs-cipher-rc4 0.1.2 security/hs-crypto-numbers 0.1.3 security/hs-crypto-pubkey 0.1.2 security/hs-crypto-random-api 0.2.0 Updated ports (107): archivers/hs-zip-archive 0.1.2.1 --> 0.1.3.3 archivers/hs-zlib-bindings 0.1.1.2 --> 0.1.1.3 audio/hs-libmpd 0.8.0.1 --> 0.8.0.2 benchmarks/hs-criterion 0.6.2.0 --> 0.6.2.1 converters/hs-aeson 0.6.0.2_2 --> 0.6.1.0 converters/hs-dataenc 0.14.0.4 --> 0.14.0.5 databases/hs-persistent 1.0.2.2 --> 1.1.4 databases/hs-persistent-sqlite 1.0.1 --> 1.1.2 databases/hs-persistent-template 1.0.0.2 --> 1.1.2.1 devel/hs-BNFC 2.4.2.1_1 --> 2.6.0.3 devel/hs-Boolean 0.1.1 --> 0.1.2 devel/hs-TypeCompose 0.9.7 --> 0.9.9 devel/hs-ansi-terminal 0.5.5_5 --> 0.5.5.1 devel/hs-ansi-wl-pprint 0.6.4_3 --> 0.6.6 devel/hs-basic-prelude 0.3.1.0 --> 0.3.2.0 devel/hs-checkers 0.2.9_2 --> 0.3.1 devel/hs-classy-prelude 0.4.1 --> 0.4.3 devel/hs-classy-prelude-conduit 0.4.1 --> 0.4.3 devel/hs-conduit 0.5.5 --> 0.5.6 devel/hs-configurator 0.2.0.1 --> 0.2.0.2 devel/hs-cpphs 1.15 --> 1.16 devel/hs-edit-distance 0.2.1.1 --> 0.2.1.2 devel/hs-file-embed 0.0.4.6 --> 0.0.4.7 devel/hs-filestore 0.5.0.1 --> 0.6 devel/hs-fsnotify 0.0.4 --> 0.0.6 devel/hs-ghc-paths 0.1.0.8_5 --> 0.1.0.9 devel/hs-git-annex 3.20121211 --> 3.20130124 devel/hs-hashable 1.1.2.5 --> 1.2.0.5 devel/hs-hastache 0.4.2 --> 0.5.0 devel/hs-hlint 1.8.39 --> 1.8.43 devel/hs-hoogle 4.2.14 --> 4.2.15 devel/hs-hspec 1.4.2 --> 1.4.3 devel/hs-largeword 1.0.3 --> 1.0.4 devel/hs-lifted-base 0.2 --> 0.2.0.2 devel/hs-monad-logger 0.2.3 --> 0.2.3.2 devel/hs-optparse-applicative 0.4.2 --> 0.5.2.1 devel/hs-pool-conduit 0.1.0.3 --> 0.1.1 devel/hs-project-template 0.1.0.1 --> 0.1.1 devel/hs-silently 1.2.4 --> 1.2.4.1 devel/hs-smallcheck 0.6.1_2 --> 0.6.2 devel/hs-system-fileio 0.3.10 --> 0.3.11 devel/hs-unix-compat 0.4.0.0 --> 0.4.1.0 devel/hs-unordered-containers 0.2.2.1 --> 0.2.3.0 devel/hs-vault 0.2.0.1 --> 0.2.0.4 devel/hs-void 0.5.8 --> 0.5.11 devel/hs-word8 0.0.2 --> 0.0.3 mail/hs-mime-types 0.1.0.0 --> 0.1.0.2 math/hs-categories 1.0.4 --> 1.0.5 math/hs-comonad 3.0.0.2 --> 3.0.1.1 math/hs-comonad-transformers 3.0 --> 3.0.1 math/hs-distributive 0.2.2_2 --> 0.3 math/hs-pointed 3.0.1 --> 3.0.2 math/hs-semigroupoids 3.0.0.1 --> 3.0.2 math/hs-semigroups 0.8.4.1 --> 0.9 net/hs-network-conduit 0.6.1.1 --> 0.6.2.2 net/hs-simple-sendfile 0.2.8 --> 0.2.10 print/hs-hscolour 1.20.3,1 --> 1.20.3_1,1 security/hs-certificate 1.3.3 --> 1.3.5 security/hs-cipher-aes 0.1.5 --> 0.1.7 security/hs-clientsession 0.8.0.1 --> 0.8.1 security/hs-cprng-aes 0.2.4 --> 0.3.4 security/hs-crypto-conduit 0.4.1 --> 0.4.3 security/hs-cryptocipher 0.3.6 --> 0.4.0 security/hs-cryptohash 0.7.9 --> 0.8.3 security/hs-pem 0.1.1_2 --> 0.1.2 security/hs-skein 0.1.0.10 --> 0.1.0.11 security/hs-tls 1.0.2 --> 1.1.1 security/hs-tls-extra 0.5.0 --> 0.6.1 sysutils/hs-angel 0.3.3 --> 0.3.4 textproc/hs-Diff 0.1.3_3 --> 0.2.0 textproc/hs-attoparsec 0.10.2.0_2 --> 0.10.3.0 textproc/hs-blaze-html 0.5.1.1 --> 0.5.1.3 textproc/hs-blaze-markup 0.5.1.2 --> 0.5.1.4 textproc/hs-case-insensitive 0.4.0.3 --> 0.4.0.4 textproc/hs-citeproc-hs 0.3.6 --> 0.3.7 textproc/hs-double-conversion 0.2.0.5 --> 0.2.0.6 textproc/hs-highlighting-kate 0.5.3.3 --> 0.5.3.5 textproc/hs-hs-bibutils 4.15 --> 4.16 textproc/hs-regex-pcre-builtin 0.94.4.3.8.31 --> 0.94.4.5.8.31 textproc/hs-texmath 0.6.1.1 --> 0.6.1.3 textproc/hs-yaml 0.8.1.1 --> 0.8.2 www/hs-gitit 0.10.0.2 --> 0.10.1.2 www/hs-hamlet 1.1.1.1 --> 1.1.3.1 www/hs-heist 0.8.2 --> 0.11.0 www/hs-hjsmin 0.1.3 --> 0.1.4 www/hs-http-conduit 1.8.4.3 --> 1.8.7 www/hs-http-date 0.0.3 --> 0.0.4 www/hs-http-reverse-proxy 0.1.0.6 --> 0.1.1.1 www/hs-shakespeare-js 1.1.0 --> 1.1.1 www/hs-snap 0.9.2.2 --> 0.11.0 www/hs-wai-app-static 1.3.0.4 --> 1.3.1_1 www/hs-wai-extra 1.3.0.4 --> 1.3.2 www/hs-warp 1.3.5 --> 1.3.7.1 www/hs-xss-sanitize 0.3.2_2 --> 0.3.3 www/hs-yesod 1.1.4.1 --> 1.1.7.2 www/hs-yesod-auth 1.1.2 --> 1.1.3 www/hs-yesod-core 1.1.6.1 --> 1.1.7.1 www/hs-yesod-default 1.1.2 --> 1.1.3 www/hs-yesod-form 1.2.0.1 --> 1.2.0.2 www/hs-yesod-persistent 1.1.0 --> 1.1.0.1 www/hs-yesod-platform 1.1.5 --> 1.1.7.2 www/hs-yesod-static 1.1.1.1 --> 1.1.1.2 www/hs-yesod-test 0.3.1.1 --> 0.3.3 x11-wm/hs-xmonad 0.10_4 --> 0.11 x11-wm/hs-xmonad-contrib 0.10_4 --> 0.11 x11/hs-X11 1.5.0.1_3 --> 1.6.0.2 x11/hs-xmobar 0.14_3 --> 0.16 Obtained from: FreeBSD Haskell
Notes
Notes: svn path=/head/; revision=311736
Diffstat (limited to 'lang/ghc/files')
-rw-r--r--lang/ghc/files/patch-aclocal.m447
-rw-r--r--lang/ghc/files/patch-configure103
-rw-r--r--lang/ghc/files/patch-configure.ac70
-rw-r--r--lang/ghc/files/patch-ghc.mk32
-rw-r--r--lang/ghc/files/patch-mk-config.mk.in15
-rw-r--r--lang/ghc/files/patch-rts-ghc.mk104
-rw-r--r--lang/ghc/files/patch-rts_package.conf.in29
7 files changed, 279 insertions, 121 deletions
diff --git a/lang/ghc/files/patch-aclocal.m4 b/lang/ghc/files/patch-aclocal.m4
new file mode 100644
index 000000000000..f288e6b77221
--- /dev/null
+++ b/lang/ghc/files/patch-aclocal.m4
@@ -0,0 +1,47 @@
+--- aclocal.m4.orig 2012-06-06 19:10:25.000000000 +0200
++++ aclocal.m4 2013-02-03 01:28:58.024638318 +0100
+@@ -19,6 +19,8 @@
+ # In bindists, we haven't called AC_CANONICAL_{BUILD,HOST,TARGET}
+ # so this justs uses $bootstrap_target.
+
++ bootstrap_target=`echo "$bootstrap_target" | sed -e 's/-unknown-/-portbld-/g'`
++
+ if test "$build_alias" = ""
+ then
+ if test "$bootstrap_target" != ""
+@@ -157,7 +159,7 @@
+ i386)
+ test -z "[$]2" || eval "[$]2=ArchX86"
+ ;;
+- x86_64)
++ x86_64|amd64)
+ GET_ARM_ISA()
+ test -z "[$]2" || eval "[$]2=ArchX86_64"
+ ;;
+@@ -186,7 +188,7 @@
+
+ checkVendor() {
+ case [$]1 in
+- dec|unknown|hp|apple|next|sun|sgi|ibm)
++ dec|unknown|hp|apple|next|sun|sgi|ibm|portbld)
+ ;;
+ *)
+ echo "Unknown vendor [$]1"
+@@ -1835,7 +1837,7 @@
+ vax)
+ $2="vax"
+ ;;
+- x86_64)
++ x86_64|amd64)
+ $2="x86_64"
+ ;;
+ *)
+@@ -1875,7 +1877,7 @@
+ freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|cygwin32|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|aix|haiku)
+ $2="$1"
+ ;;
+- freebsd8) # like i686-gentoo-freebsd8
++ freebsd*) # like i686-gentoo-freebsd8
+ $2="freebsd"
+ ;;
+ *)
diff --git a/lang/ghc/files/patch-configure b/lang/ghc/files/patch-configure
deleted file mode 100644
index 3383b16e1a76..000000000000
--- a/lang/ghc/files/patch-configure
+++ /dev/null
@@ -1,103 +0,0 @@
---- configure.orig 2012-06-06 18:11:19.000000000 +0100
-+++ configure 2012-08-25 06:03:00.000000000 +0100
-@@ -3372,8 +3372,8 @@
- vax)
- BuildArch="vax"
- ;;
-- x86_64)
-- BuildArch="x86_64"
-+ x86_64|amd64)
-+ BuildArch="amd64"
- ;;
- *)
- echo "Unknown CPU $build_cpu"
-@@ -3404,7 +3404,7 @@
- freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|cygwin32|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|aix|haiku)
- BuildOS="$build_os"
- ;;
-- freebsd8) # like i686-gentoo-freebsd8
-+ freebsd*) # like i686-gentoo-freebsd8
- BuildOS="freebsd"
- ;;
- *)
-@@ -3486,8 +3486,8 @@
- vax)
- HostArch="vax"
- ;;
-- x86_64)
-- HostArch="x86_64"
-+ x86_64|amd64)
-+ HostArch="amd64"
- ;;
- *)
- echo "Unknown CPU $host_cpu"
-@@ -3600,8 +3600,8 @@
- vax)
- TargetArch="vax"
- ;;
-- x86_64)
-- TargetArch="x86_64"
-+ x86_64|amd64)
-+ TargetArch="amd64"
- ;;
- *)
- echo "Unknown CPU $target_cpu"
-@@ -3711,6 +3711,8 @@
-
-
-
-+bootstrap_target=`echo "$bootstrap_target" |sed -e 's/-unknown-/-portbld-/g' -e 's/x86_64/amd64/g'`
-+build=`echo "$build" |sed -e 's/\(freebsd\)[[:digit:].]*$/\1/g'`
-
- # Verify that the installed (bootstrap) GHC is capable of generating
- # code for the requested build platform.
-@@ -5772,7 +5774,7 @@
- i386)
- test -z "$2" || eval "$2=ArchX86"
- ;;
-- x86_64)
-+ x86_64|amd64)
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-@@ -5953,7 +5955,7 @@
-
- checkVendor() {
- case $1 in
-- dec|unknown|hp|apple|next|sun|sgi|ibm)
-+ dec|unknown|hp|apple|next|sun|sgi|ibm|portbld)
- ;;
- *)
- echo "Unknown vendor $1"
-@@ -5976,7 +5978,7 @@
- mingw32)
- test -z "$2" || eval "$2=OSMinGW32"
- ;;
-- freebsd)
-+ freebsd*)
- test -z "$2" || eval "$2=OSFreeBSD"
- ;;
- kfreebsdgnu)
-@@ -9990,7 +9992,7 @@
- $as_echo_n "(cached) " >&6
- else
- ac_check_lib_save_LIBS=$LIBS
--LIBS="-lrt $LIBS"
-+LIBS="$LIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h. */
-
-@@ -10021,12 +10023,7 @@
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
- $as_echo "$ac_cv_lib_rt_clock_gettime" >&6; }
- if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then :
-- cat >>confdefs.h <<_ACEOF
--#define HAVE_LIBRT 1
--_ACEOF
--
-- LIBS="-lrt $LIBS"
--
-+ LIBS="$LIBS"
- fi
-
- for ac_func in clock_gettime timer_create timer_settime
diff --git a/lang/ghc/files/patch-configure.ac b/lang/ghc/files/patch-configure.ac
new file mode 100644
index 000000000000..11139a3aa71d
--- /dev/null
+++ b/lang/ghc/files/patch-configure.ac
@@ -0,0 +1,70 @@
+--- configure.ac.orig 2012-06-06 19:10:25.000000000 +0200
++++ configure.ac 2013-02-02 17:31:55.193634655 +0100
+@@ -89,6 +89,59 @@
+ fi
+ WithGhc="$GHC"])
+
++# system libffi
++
++AC_ARG_WITH([system-libffi],
++[AC_HELP_STRING([--with-system-libffi],
++ [Use system provided libffi for RTS [default=no]])
++])
++
++AS_IF([test "x$with_system_libffi" = "xyes"],
++ [UseSystemLibFFI="YES"], [UseSystemLibFFI="NO"]
++)
++
++AC_SUBST(UseSystemLibFFI)
++
++AC_ARG_WITH([ffi-includes],
++[AC_HELP_STRING([--with-ffi-includes=ARG]
++ [Find includes for libffi in ARG [default=system default]])
++],
++[
++ if test "x$UseSystemLibFFI" != "xYES"; then
++ AC_MSG_WARN([--with-ffi-includes will be ignored, --with-system-libffi not set])
++ else
++ FFIIncludeDir="$withval" LIBFFI_CFLAGS="-I $withval"
++ fi
++])
++
++AC_SUBST(FFIIncludeDir)
++
++AC_ARG_WITH([ffi-libraries],
++[AC_HELP_STRING([--with-ffi-libraries=ARG]
++ [Find libffi in ARG [default=system default]])
++],
++[
++ if test "x$UseSystemLibFFI" != "xYES"; then
++ AC_MSG_WARN([--with-ffi-libraries will be ignored, --with-system-libffi not set])
++ else
++ FFILibDir="$withval" LIBFFI_LDFLAGS="-L$withval"
++ fi
++])
++
++AC_SUBST(FFILibDir)
++
++AS_IF([test "$UseSystemLibFFI" = "YES"], [
++ CFLAGS2="$CFLAGS"
++ CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
++ LDFLAGS2="$LDFLAGS"
++ LDFLAGS="$LIBFFI_LDFLAGS $LDFLAGS"
++ AC_CHECK_LIB(ffi, ffi_call,
++ [AC_CHECK_HEADERS([ffi.h], [break], [])
++ AC_DEFINE([HAVE_LIBFFI], [1], [Define to 1 if you have libffi.])],
++ [UseSystemLibFFI="NO"])
++ CFLAGS="$CFLAGS2"
++ LDFLAGS="$LDFLAGS2"
++])
+
+ dnl ** Tell the make system which OS we are using
+ dnl $OSTYPE is set by the operating system to "msys" or "cygwin" or something
+@@ -717,7 +770,6 @@
+ FP_VISIBILITY_HIDDEN
+
+ dnl ** check for librt
+-AC_CHECK_LIB(rt, clock_gettime)
+ AC_CHECK_FUNCS(clock_gettime timer_create timer_settime)
+ FP_CHECK_TIMER_CREATE
+
diff --git a/lang/ghc/files/patch-ghc.mk b/lang/ghc/files/patch-ghc.mk
index 00eeed367856..81f97ee717ea 100644
--- a/lang/ghc/files/patch-ghc.mk
+++ b/lang/ghc/files/patch-ghc.mk
@@ -1,5 +1,5 @@
---- ghc.mk.orig 2012-06-06 18:10:25.000000000 +0100
-+++ ghc.mk 2012-08-25 12:57:51.000000000 +0100
+--- ghc.mk.orig 2012-06-06 19:10:25.000000000 +0200
++++ ghc.mk 2013-01-30 16:24:02.000000000 +0100
@@ -81,6 +81,7 @@
# Catch make if it runs away into an infinite loop
ifeq "$(MAKE_RESTARTS)" ""
@@ -8,3 +8,31 @@
else
$(error Make has restarted itself $(MAKE_RESTARTS) times; is there a makefile bug?)
endif
+@@ -574,12 +575,18 @@
+ $(GHC_GENPRIMOP_DIR)
+ endif
+
++ifeq "$(UseSystemLibFFI)" "YES"
++MAYBE_LIBFFI=
++else
++MAYBE_LIBFFI=libffi
++endif
++
+ BUILD_DIRS += \
+ driver \
+ driver/ghci \
+ driver/ghc \
+ driver/haddock \
+- libffi \
++ $(MAYBE_LIBFFI) \
+ includes \
+ rts
+
+@@ -971,6 +978,7 @@
+ echo "BUILD_DOCBOOK_PDF = $(BUILD_DOCBOOK_PDF)" >> $(BIN_DIST_MK)
+ echo "BUILD_MAN = $(BUILD_MAN)" >> $(BIN_DIST_MK)
+ echo "GHC_CABAL_INPLACE = utils/ghc-cabal/dist-install/build/tmp/ghc-cabal" >> $(BIN_DIST_MK)
++ echo "UseSystemLibFFI = $(UseSystemLibFFI)" >> $(BIN_DIST_MK)
+ cd $(BIN_DIST_PREP_DIR) && autoreconf
+ $(call removeFiles,$(BIN_DIST_PREP_TAR))
+ # h means "follow symlinks", e.g. if aclocal.m4 is a symlink to a source
diff --git a/lang/ghc/files/patch-mk-config.mk.in b/lang/ghc/files/patch-mk-config.mk.in
new file mode 100644
index 000000000000..ff8f0071f82f
--- /dev/null
+++ b/lang/ghc/files/patch-mk-config.mk.in
@@ -0,0 +1,15 @@
+--- ./mk/config.mk.in.orig 2012-06-06 19:10:25.000000000 +0200
++++ ./mk/config.mk.in 2013-01-30 16:24:53.000000000 +0100
+@@ -363,6 +363,12 @@
+ PapiLibDir=
+ PapiIncludeDir=
+
++# Configuration for libffi
++UseSystemLibFFI=@UseSystemLibFFI@
++# Flags to go into package.conf for rts
++FFILibDir=@FFILibDir@
++FFIIncludeDir=@FFIIncludeDir@
++
+ ################################################################################
+ #
+ # Paths (see paths.mk)
diff --git a/lang/ghc/files/patch-rts-ghc.mk b/lang/ghc/files/patch-rts-ghc.mk
new file mode 100644
index 000000000000..c03e03dea09a
--- /dev/null
+++ b/lang/ghc/files/patch-rts-ghc.mk
@@ -0,0 +1,104 @@
+--- ./rts/ghc.mk.orig 2012-06-06 19:10:25.000000000 +0200
++++ ./rts/ghc.mk 2013-01-30 16:40:21.000000000 +0100
+@@ -105,8 +105,10 @@
+ endif
+
+ ifneq "$(BINDIST)" "YES"
++ifneq "$(UseSystemLibFFI)" "YES"
+ rts_ffi_objs_stamp = rts/dist/ffi/stamp
+ rts_ffi_objs = rts/dist/ffi/*.o
++
+ $(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) $(TOUCH_DEP) | $$(dir $$@)/.
+ cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB)
+ "$(TOUCH_CMD)" $@
+@@ -119,6 +121,7 @@
+ rts/dist/build/libffi-5.dll: libffi/build/inst/bin/libffi-5.dll
+ cp $< $@
+ endif
++endif
+
+ #-----------------------------------------------------------------------------
+ # Building one way
+@@ -169,6 +172,12 @@
+
+ rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
+
++ifneq "$(UseSystemLibFFI)" "YES"
++rts_dist_FFI_SO = rts/dist/build/libffi$(soext)
++else
++rts_dist_FFI_SO =
++endif
++
+ # Making a shared library for the RTS.
+ ifneq "$$(findstring dyn, $1)" ""
+ ifeq "$$(HOSTPLATFORM)" "i386-unknown-mingw32"
+@@ -177,10 +186,15 @@
+ "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
+ -no-auto-link-packages -Lrts/dist/build -lffi-5 `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/dist/build/libffi$$(soext)
++ifneq "$(UseSystemLibFFI)" "YES"
++ LIBFFI_LIBS= -Lrts/dist/build -lffi
++else
++ LIBFFI_LIBS= -L$(FFILibDir)
++endif
++$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend $$(rts_dist_FFI_SO)
+ "$$(RM)" $$(RM_OPTS) $$@
+ "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
+- -no-auto-link-packages -Lrts/dist/build -lffi `cat rts/libs.depend` $$(rts_$1_OBJS) \
++ -no-auto-link-packages $$(LIBFFI_LIBS) `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.
+@@ -370,9 +384,14 @@
+ endif
+
+ # ffi.h triggers prototype warnings, so disable them here:
+-rts/Interpreter_CC_OPTS += -Wno-strict-prototypes
+-rts/Adjustor_CC_OPTS += -Wno-strict-prototypes
+-rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes
++ifeq "$(UseSystemLibFFI)" "YES"
++LIBFFI_CFLAGS = $(addprefix -I,$(FFIIncludeDir))
++else
++LIBFFI_CFLAGS =
++endif
++rts/Interpreter_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
++rts/Adjustor_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
++rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
+
+ # inlining warnings happen in Compact
+ rts/sm/Compact_CC_OPTS += -Wno-inline
+@@ -430,6 +449,21 @@
+
+ endif
+
++#-----------------------------------------------------------------------------
++# Use system provided libffi
++
++ifeq "$(UseSystemLibFFI)" "YES"
++
++rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=$(FFIIncludeDir)
++rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=$(FFILibDir)
++
++else # UseSystemLibFFI==YES
++
++rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=""
++rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=""
++
++endif
++
+ # -----------------------------------------------------------------------------
+ # dependencies
+
+@@ -507,7 +541,11 @@
+ INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
+ INSTALL_LIBS += $(wildcard rts/dist/build/libffi-5.dll)
+
++ifneq "$(UseSystemLibFFI)" "YES"
+ install: install_libffi_headers
++else
++install:
++endif
+
+ .PHONY: install_libffi_headers
+ install_libffi_headers :
diff --git a/lang/ghc/files/patch-rts_package.conf.in b/lang/ghc/files/patch-rts_package.conf.in
index e3f4f73239ea..de5040db75e7 100644
--- a/lang/ghc/files/patch-rts_package.conf.in
+++ b/lang/ghc/files/patch-rts_package.conf.in
@@ -1,23 +1,20 @@
-
-$FreeBSD$
-
---- rts/package.conf.in.orig
-+++ rts/package.conf.in
-@@ -31,9 +31,6 @@
- #ifdef HAVE_LIBM
- "m" /* for ldexp() */
- #endif
--#ifdef HAVE_LIBRT
-- , "rt"
--#endif
+--- ./rts/package.conf.in.orig 2012-06-06 19:10:25.000000000 +0200
++++ ./rts/package.conf.in 2013-01-30 19:04:28.000000000 +0100
+@@ -33,6 +33,9 @@
#ifdef HAVE_LIBDL
, "dl"
#endif
-@@ -141,6 +138,7 @@
- , "-u", "base_GHCziConc_runSparks_closure"
- , "-u", "base_GHCziConc_runHandlers_closure"
++#ifdef HAVE_LIBFFI
++ , "ffi"
++#endif
+ #ifdef mingw32_HOST_OS
+ ,"wsock32" /* for the linker */
+ #endif
+@@ -138,6 +141,7 @@
+ , "-u", "base_GHCziConcziSync_runSparks_closure"
+ , "-u", "base_GHCziConcziSignal_runHandlers_closure"
#endif
-+ , "-L%%LOCALBASE%%/lib"
++ , "-L%%LOCALBASE%%/lib"
/* Pick up static libraries in preference over dynamic if in earlier search
* path. This is important to use the static gmp in preference on Mac OS.