aboutsummaryrefslogtreecommitdiff
path: root/lang/ghc
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
parent32ca3ee61e3889801319024959589312eb652bfa (diff)
downloadports-c731105b7f8e403a3db33599a7d7f1ce9257f375.tar.gz
ports-c731105b7f8e403a3db33599a7d7f1ce9257f375.zip
Notes
Diffstat (limited to 'lang/ghc')
-rw-r--r--lang/ghc/Makefile14
-rw-r--r--lang/ghc/bsd.cabal.mk4
-rw-r--r--lang/ghc/bsd.hackage.mk20
-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
10 files changed, 313 insertions, 125 deletions
diff --git a/lang/ghc/Makefile b/lang/ghc/Makefile
index 6a3c01ede6ea..502c08e9dfaa 100644
--- a/lang/ghc/Makefile
+++ b/lang/ghc/Makefile
@@ -3,6 +3,7 @@
PORTNAME= ghc
PORTVERSION= 7.4.2
+PORTREVISION= 1
CATEGORIES= lang haskell
MASTER_SITES= http://www.haskell.org/ghc/dist/${PORTVERSION}/:source \
${MASTER_SITE_LOCAL:S/$/:boot/}
@@ -26,6 +27,7 @@ CONFLICTS= ghc-6.8.* ghc-6.10.* ghc-6.12.* ghc-7.0.* ghc-7.2.*
USE_BZIP2= yes
LIB_DEPENDS+= gmp.10:${PORTSDIR}/math/gmp
+USE_AUTOTOOLS= autoconf autoheader
USE_PERL5_BUILD= yes
USE_GMAKE= yes
USE_ICONV= yes
@@ -36,6 +38,7 @@ USE_NCURSES= yes
LICENSE= BSD
LICENSE_FILE= ${WRKSRC}/LICENSE
+MAKE_JOBS_SAFE= yes
MAKE_ENV= LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
# The configure process accepts,filters and canonicalises
@@ -66,6 +69,10 @@ OPTIONS_DEFINE+= BOOTH
.include <bsd.port.options.mk>
+.if ${PORT_OPTIONS:MDYNAMIC}
+LIB_DEPENDS+= ffi.6:${PORTSDIR}/devel/libffi
+.endif
+
.if empty(PORT_OPTIONS:MBOOT)
EXTRA_PATCHES= ${PATCHDIR}/nopatch-.._ghc-${BOOT_GHC_VERSION}-boot_rts_package.conf.in
@@ -108,11 +115,18 @@ HACKAGE_SITE?= http://hackage.haskell.org/
HACKAGE_ARCH?= packages/archive/
CONFIGURE_ARGS= --with-gcc=${CC} \
+ --with-ld=${LD} \
--with-gmp-includes=${LOCALBASE}/include \
--with-gmp-libraries=${LOCALBASE}/lib \
--with-iconv-includes=${LOCALBASE}/include \
--with-iconv-libraries=${LOCALBASE}/lib
+.if ${PORT_OPTIONS:MDYNAMIC}
+CONFIGURE_ARGS+= --with-system-libffi \
+ --with-ffi-includes=${LOCALBASE}/include \
+ --with-ffi-libraries=${LOCALBASE}/lib
+.endif
+
.if empty(PORT_OPTIONS:MBOOT)
BOOT_DIR= ${WRKDIR}/ghc-${BOOT_GHC_VERSION}-boot
diff --git a/lang/ghc/bsd.cabal.mk b/lang/ghc/bsd.cabal.mk
index 55efc4943188..107dda7a3b31 100644
--- a/lang/ghc/bsd.cabal.mk
+++ b/lang/ghc/bsd.cabal.mk
@@ -80,10 +80,6 @@ BUILD_DEPENDS+= ghc>=${GHC_VERSION}:${PORTSDIR}/lang/ghc
USE_BINUTILS= yes
USE_GCC= 4.6+
-.if ${PORT_OPTIONS:MDYNAMIC}
-LIB_DEPENDS+= ffi:${PORTSDIR}/devel/libffi
-.endif
-
CONFIGURE_ARGS+= --with-gcc=${CC} --with-ld=${LD} --with-ar=${AR} \
--with-ranlib=${RANLIB}
diff --git a/lang/ghc/bsd.hackage.mk b/lang/ghc/bsd.hackage.mk
index 4e5a4ab72fee..749258a2e05b 100644
--- a/lang/ghc/bsd.hackage.mk
+++ b/lang/ghc/bsd.hackage.mk
@@ -34,7 +34,9 @@ authenticate_port= www/hs-authenticate
base-unicode-symbols_port= devel/hs-base-unicode-symbols
base16-bytestring_port= devel/hs-base16-bytestring
base64-bytestring_port= devel/hs-base64-bytestring
+base64-conduit_port= devel/hs-base64-conduit
basic-prelude_port= devel/hs-basic-prelude
+bifunctors_port= devel/hs-bifunctors
bio_port= science/hs-bio
bits-atomic_port= devel/hs-bits-atomic
blaze-builder_port= devel/hs-blaze-builder
@@ -61,6 +63,7 @@ certificate_port= security/hs-certificate
cgi_port= www/hs-cgi
checkers_port= devel/hs-checkers
cipher-aes_port= security/hs-cipher-aes
+cipher-rc4_port= security/hs-cipher-rc4
citeproc-hs_port= textproc/hs-citeproc-hs
classy-prelude_port= devel/hs-classy-prelude
classy-prelude-conduit_port= devel/hs-classy-prelude-conduit
@@ -68,6 +71,7 @@ clientsession_port= security/hs-clientsession
cmdargs_port= devel/hs-cmdargs
comonad_port= math/hs-comonad
comonad-transformers_port= math/hs-comonad-transformers
+comonads-fd_port= math/hs-comonads-fd
conduit_port= devel/hs-conduit
ConfigFile_port= devel/hs-ConfigFile
configurator_port= devel/hs-configurator
@@ -81,7 +85,10 @@ criterion_port= benchmarks/hs-criterion
Crypto_port= security/hs-Crypto
crypto-api_port= security/hs-crypto-api
crypto-conduit_port= security/hs-crypto-conduit
+crypto-numbers_port= security/hs-crypto-numbers
+crypto-pubkey_port= security/hs-crypto-pubkey
crypto-pubkey-types_port= security/hs-crypto-pubkey-types
+crypto-random-api_port= security/hs-crypto-random-api
cryptocipher_port= security/hs-cryptocipher
cryptohash_port= security/hs-cryptohash
css-text_port= www/hs-css-text
@@ -105,11 +112,13 @@ distributive_port= math/hs-distributive
dlist_port= devel/hs-dlist
double-conversion_port= textproc/hs-double-conversion
edit-distance_port= devel/hs-edit-distance
+either_port= devel/hs-either
email-validate_port= mail/hs-email-validate
entropy_port= security/hs-entropy
enumerator_port= devel/hs-enumerator
epic_port= lang/hs-epic # executable
erf_port= math/hs-erf
+errors_port= devel/hs-errors
failure_port= devel/hs-failure
fast-logger_port= devel/hs-fast-logger
fastcgi_port= www/hs-fastcgi # lib_depends
@@ -121,6 +130,7 @@ filestore_port= devel/hs-filestore
filesystem-conduit_port= devel/hs-filesystem-conduit
fsnotify_port= devel/hs-fsnotify
gconf_port= devel/hs-gconf
+generic-deriving_port= devel/hs-generic-deriving
ghc-events_port= devel/hs-ghc-events # executable
ghc-mtl_port= devel/hs-ghc-mtl
ghc-paths_port= devel/hs-ghc-paths
@@ -130,6 +140,7 @@ gitit_port= www/hs-gitit # executable
glade_port= devel/hs-glade
glib_port= devel/hs-glib
GLUT_port= x11-toolkits/hs-GLUT
+groupoids_port= math/hs-groupoids
gstreamer_port= multimedia/hs-gstreamer
gtk_port= x11-toolkits/hs-gtk
gtk2hs-buildtools_port= devel/hs-gtk2hs-buildtools # executable
@@ -189,6 +200,7 @@ language-c_port= devel/hs-language-c
language-javascript_port= devel/hs-language-javascript
largeword_port= devel/hs-largeword
lazysmallcheck_port= devel/hs-lazysmallcheck
+lens_port= devel/hs-lens
lhs2tex_port= textproc/hs-lhs2tex
libmpd_port= audio/hs-libmpd
libxml_port= textproc/hs-libxml
@@ -210,11 +222,13 @@ monad-par-extras_port= devel/hs-monad-par-extras
MonadCatchIO-mtl_port= devel/hs-MonadCatchIO-mtl
MonadCatchIO-transformers_port= devel/hs-MonadCatchIO-transformers
monadcryptorandom_port= security/hs-monadcryptorandom
+MonadRandom_port= devel/hs-MonadRandom
mtl_port= devel/hs-mtl
mueval_port= devel/hs-mueval # executable
murmur-hash_port= devel/hs-murmur-hash
mwc-random_port= math/hs-mwc-random
mysql_port= databases/hs-mysql
+nats_port= math/hs-nats
network_port= net/hs-network
network-conduit_port= net/hs-network-conduit
network-info_port= net/hs-network-info
@@ -243,6 +257,8 @@ pool-conduit_port= devel/hs-pool-conduit
porte_port= ports-mgmt/hs-porte # executable
primitive_port= devel/hs-primitive
probability_port= math/hs-probability
+profunctor-extras_port= devel/hs-profunctor-extras
+profunctors_port= devel/hs-profunctors
project-template_port= devel/hs-project-template
PSQueue_port= devel/hs-PSQueue
pureMD5_port= security/hs-pureMD5
@@ -254,6 +270,7 @@ reactive_port= devel/hs-reactive
ReadArgs_port= devel/hs-ReadArgs
readline_port= devel/hs-readline
recaptcha_port= www/hs-recaptcha
+reflection_port= devel/hs-reflection
regex-base_port= textproc/hs-regex-base
regex-compat_port= textproc/hs-regex-compat
regex-pcre-builtin_port= textproc/hs-regex-pcre-builtin
@@ -265,6 +282,7 @@ safe_port= devel/hs-safe
SafeSemaphore_port= devel/hs-SafeSemaphore
scgi_port= www/hs-scgi
sendfile_port= net/hs-sendfile
+semigroupoid-extras_port= math/hs-semigroupoid-extras
semigroupoids_port= math/hs-semigroupoids
semigroups_port= math/hs-semigroups
setenv_port= devel/hs-setenv
@@ -314,6 +332,8 @@ text_port= devel/hs-text
threads_port= devel/hs-threads
threadscope_port= devel/hs-threadscope # executable
time-compat_port= devel/hs-time-compat
+timezone-olson_port= devel/hs-timezone-olson
+timezone-series_port= devel/hs-timezone-series
tls_port= security/hs-tls
tls-extra_port= security/hs-tls-extra
transformers_port= devel/hs-transformers
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.