a project to simplify installation of open source software
on Mac OS X and Darwin
# $Id: Portfile 22052 2007-02-16 04:10:19Z gwright@macports.org $
PortSystem 1.0
name ghc
version 6.6
revision 3
categories lang
maintainers gwright@macports.org
platforms darwin
description The Glorious Glasgow Haskell Compilation System
long_description \
The Glasgow Haskell Compiler is a robust, \
fully-featured, optimising compiler and interactive \
environment for Haskell 98, GHC compiles Haskell to \
either native code or C. It implements numerous \
experimental language extensions to Haskell 98, \
for example: concurrency, a foreign language interface, \
multi-parameter type classes, scoped type variables, \
existential and universal quantification, unboxed \
types, exceptions, weak pointers, and so on. \
GHC comes with a generational garbage collector, \
and a space and time profiler.
homepage http://www.haskell.org/ghc
master_sites ${homepage}/dist/${version}/
use_bzip2 yes
distfiles ${name}-${version}-src.tar.bz2 \
${name}-${version}-src-extralibs.tar.bz2
checksums ${name}-${version}-src.tar.bz2 md5 2427a8d7d14f86e0878df6b54938acf7 \
${name}-${version}-src-extralibs.tar.bz2 md5 14b22fce36caffa509046361724bc119
patchfiles patch-configure.ac \
patch-GHC.hs \
patch-Linker.c \
patch-package.conf.in
depends_lib port:readline \
port:gmp
# Yes, it some situations (-fvia-C) we really need perl
# to _run_ ghc, since the mangler (an assembly to assembly transformation)
# is a perl script. That's why it called the "Evil Mangler".
#
depends_run port:perl5.8
platform darwin 6 {
ui_msg "GHC is not supported on Jaguar (OS X 10.2.x)"
exit 1
}
platform darwin 7 powerpc {
global ghc_bootversion
set ghc_bootversion 6.4
master_sites-append ${homepage}/dist/${ghc_bootversion}/MacOSX/:bootstrap
distfiles-append ${name}-${ghc_bootversion}-darwin-bootstrap-v01.tar.bz2:bootstrap
checksums-append ${name}-${ghc_bootversion}-darwin-bootstrap-v01.tar.bz2 md5 3a0a79ed656cb619dd69a24cab32ba97
extract.only ${name}-${version}-src.tar.bz2 \
${name}-${version}-src-extralibs.tar.bz2 \
${name}-${ghc_bootversion}-darwin-bootstrap-v01.tar.bz2
# The following is required because ghc triggers a long-standing bug
# in make 3.79 and earlier. (3.79 is standard on Panther.) The bug causes
# make to fall into an infinite loop. (Not required on Tiger.)
depends_build port:gmake
# The bootstrap compiler requires version 5.0 of readline. Ugh.
depends_lib-append port:readline-5
pre-configure {
cd ${worksrcpath}
system "autoreconf"
set cfg [open "${worksrcpath}/mk/build.mk" w]
puts $cfg "#"
puts $cfg "# Local configuration overrides for MacPorts"
puts $cfg "#"
puts $cfg "SRC_CC_OPTS += -I${prefix}/include"
puts $cfg "SRC_HC_OPTS += -I${prefix}/include -I/usr/include -L${prefix}/lib -L/usr/lib"
puts $cfg "EXTRA_HSC2HS_OPTS += -I${prefix}/include"
puts $cfg "EXTRA_LD_OPTS += -L${prefix}/lib"
puts $cfg "EXTRA_LD_OPTS += -L/usr/lib"
close $cfg
reinplace "s|/opt/local|${workpath}/ghc-bootstrap|g" ${workpath}/ghc-bootstrap/lib/ghc-${ghc_bootversion}/package.conf
reinplace "s|GHCBIN=\"/opt/local|GHCBIN=\"${workpath}/${name}-bootstrap|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|TOPDIROPT=\"-B/opt/local|TOPDIROPT=\"-B${workpath}/${name}-bootstrap|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|-L/opt/local|-L${prefix}|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|-I/opt/local|-I${prefix}|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|/opt/local|${prefix}|" ${workpath}/${name}-bootstrap/lib/ghc-${ghc_bootversion}/ghc-asm
reinplace "s|/opt/local|${prefix}|" ${workpath}/${name}-bootstrap/lib/ghc-${ghc_bootversion}/ghc-split
}
configure.args-append --with-ghc='${workpath}/${name}-bootstrap/bin/ghc'
build.cmd gmake
build.target
}
platform darwin 8 powerpc {
global ghc_bootversion
set ghc_bootversion 6.4
master_sites-append ${homepage}/dist/${ghc_bootversion}/MacOSX/:bootstrap
distfiles-append ${name}-${ghc_bootversion}-darwin-bootstrap-tiger.tar.bz2:bootstrap
checksums-append ${name}-${ghc_bootversion}-darwin-bootstrap-tiger.tar.bz2 md5 1665720d4d35cf89b9efa7865d0228f6
extract.only ${name}-${version}-src.tar.bz2 \
${name}-${version}-src-extralibs.tar.bz2 \
${name}-${ghc_bootversion}-darwin-bootstrap-tiger.tar.bz2
pre-configure {
cd ${worksrcpath}
system "autoreconf"
set cfg [open "${worksrcpath}/mk/build.mk" w]
puts $cfg "#"
puts $cfg "# Local configuration overrides for MacPorts"
puts $cfg "#"
puts $cfg "SRC_CC_OPTS += -I${prefix}/include"
puts $cfg "SRC_HC_OPTS += -I${prefix}/include -I/usr/include -L${prefix}/lib -L/usr/lib"
puts $cfg "EXTRA_HSC2HS_OPTS += -I${prefix}/include"
puts $cfg "EXTRA_LD_OPTS += -L${prefix}/lib"
puts $cfg "EXTRA_LD_OPTS += -L/usr/lib"
close $cfg
reinplace "s|/opt/local|${workpath}/ghc-bootstrap|g" ${workpath}/ghc-bootstrap/lib/ghc-${ghc_bootversion}/package.conf
reinplace "s|GHCBIN=\"/opt/local|GHCBIN=\"${workpath}/${name}-bootstrap|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|TOPDIROPT=\"-B/opt/local|TOPDIROPT=\"-B${workpath}/${name}-bootstrap|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|-L/opt/local|-L${prefix}|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|-I/opt/local|-I${prefix}|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|/opt/local|${prefix}|" ${workpath}/${name}-bootstrap/lib/ghc-${ghc_bootversion}/ghc-asm
reinplace "s|/opt/local|${prefix}|" ${workpath}/${name}-bootstrap/lib/ghc-${ghc_bootversion}/ghc-split
}
configure.args-append --with-ghc='${workpath}/${name}-bootstrap/bin/ghc'
}
platform darwin 8 i386 {
global ghc_bootversion
set ghc_bootversion 6.6
master_sites-append ${homepage}/dist/${ghc_bootversion}/:bootstrap
distfiles-append ${name}-${ghc_bootversion}-i386-apple-darwin-bootstrap.tar.bz2:bootstrap
checksums-append ${name}-${ghc_bootversion}-i386-apple-darwin-bootstrap.tar.bz2 md5 0cb6d89efb0694a28b34bec0f04d8c62
extract.only ${name}-${version}-src.tar.bz2 \
${name}-${version}-src-extralibs.tar.bz2 \
${name}-${ghc_bootversion}-i386-apple-darwin-bootstrap.tar.bz2
pre-configure {
cd ${worksrcpath}
system "autoreconf"
set cfg [open "${worksrcpath}/mk/build.mk" w]
puts $cfg "#"
puts $cfg "# Local configuration overrides for MacPorts"
puts $cfg "#"
puts $cfg "SRC_CC_OPTS += -I${prefix}/include"
puts $cfg "SRC_HC_OPTS += -I${prefix}/include -I/usr/include -L${prefix}/lib -L/usr/lib"
puts $cfg "EXTRA_HSC2HS_OPTS += -I${prefix}/include"
puts $cfg "EXTRA_LD_OPTS += -L${prefix}/lib"
puts $cfg "EXTRA_LD_OPTS += -L/usr/lib"
close $cfg
reinplace "s|/opt/local|${workpath}/ghc-bootstrap|g" ${workpath}/ghc-bootstrap/lib/ghc-${ghc_bootversion}/package.conf
reinplace "s|GHCBIN=\"/opt/local|GHCBIN=\"${workpath}/${name}-bootstrap|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|TOPDIROPT=\"-B/opt/local|TOPDIROPT=\"-B${workpath}/${name}-bootstrap|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|-L/opt/local|-L${prefix}|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|-I/opt/local|-I${prefix}|" ${workpath}/${name}-bootstrap/bin/ghc
reinplace "s|/opt/local|${prefix}|" ${workpath}/${name}-bootstrap/lib/ghc-${ghc_bootversion}/ghc-asm
reinplace "s|/opt/local|${prefix}|" ${workpath}/${name}-bootstrap/lib/ghc-${ghc_bootversion}/ghc-split
}
configure.args-append --with-ghc='${workpath}/${name}-bootstrap/bin/ghc'
}
#bugs GHC does not support DESTDIR. Instead, we install \
# everything into ${destroot}/${prefix}, and then fix up \
# the five scripts which actually have the installation \
# path hard coded.
configure.env LDFLAGS="-L/usr/lib -L${prefix}/lib" \
CPPFLAGS="-I${prefix}/include" \
CFLAGS="-I${prefix}/include" \
DYLD_FALLBACK_LIBRARY_PATH=${prefix}/lib
configure.args --prefix=${destroot}/${prefix} \
--mandir=${destroot}/${prefix}/share/man/ \
--with-readline-includes=${prefix}/include \
--with-readline-libraries=${prefix}/lib \
--disable-openal \
--disable-alut
variant noopengl { configure.args-append --disable-hopengl }
build {
system "env DYLD_FALLBACK_LIBRARY_PATH=${prefix}/lib ${build.cmd} ${build.target}"
}
# Note the middle "/" in the ${destroot}/${prefix} pattern. It is required,
# because the actual text we are trying to match has a "//" between the
# destroot and the prefix pieces.
post-destroot {
reinplace s|${destroot}/${prefix}|${prefix}|g ${destroot}/${prefix}/bin/ghc
reinplace s|${destroot}/${prefix}|${prefix}|g ${destroot}/${prefix}/bin/ghci
reinplace s|${destroot}/${prefix}|${prefix}|g ${destroot}/${prefix}/bin/ghc-pkg
reinplace s|${destroot}/${prefix}|${prefix}|g ${destroot}/${prefix}/bin/ghcprof
reinplace s|${destroot}/${prefix}|${prefix}|g ${destroot}/${prefix}/bin/hsc2hs
reinplace "s|\\\$@\"\}|\\\$@\"\} -L${prefix}/lib -I${prefix}/include |" ${destroot}/${prefix}/bin/ghc
reinplace s|${destroot}/${prefix}|${prefix}|g ${destroot}${prefix}/lib/${name}-${version}/package.conf
cd ${destroot}${prefix}/lib/ghc-${version}
system "ranlib *.a"
}