# $Id: Portfile,v 1.9 2006/06/06 18:18:29 gwright Exp $

PortSystem 1.0
name		nhc98
version		1.18
revision	4
categories	lang
maintainers	gwright@opendarwin.org
platforms	darwin
description	The nhc98 Haskell Compiler
long_description	\
		nhc98 is a small, easy to install, standards-compliant	\
		compiler for Haskell 98, the lazy functional		\
		programming language.  It is very portable, and aims to	\
		produce small executables that run in small amounts of	\
		memory. It produces medium-fast code, and compilation	\
		is itself quite fast. It also comes with extensive tool	\
		support for automatic compilation, foreign language	\
		interfacing, heap and time profiling, tracing, and	\
		debugging.  (Some of its advanced kinds of heap		\
		profiles are not found in any other Haskell compiler.)  

homepage	http://www.haskell.org/${name}/
master_sites	http://www.cs.york.ac.uk/fp/${name}/		\
		ftp://ftp.cs.york.ac.uk/pub/haskell/${name}/

distfiles	${name}src-${version}${extract.suffix}	\
		${name}-${version}-library-interfaces${extract.suffix}

checksums	${name}src-${version}${extract.suffix}                 md5 f38b74481ec01a066cc9314b7bd18c90	\
		${name}-${version}-library-interfaces${extract.suffix} md5 f99f413a85462fe719ea634fd319d94f

patchfiles	patch-cLowUnboxedArray.c	\
		patch-confhc			\
		patch-config-errno.c		\
		patch-errnogen.c

configure.args	--mandir=/${prefix}/share/man/man1	\
		--buildwith=gcc

platform darwin i386 {
		ui_msg "nhc98 is not supported on OS X i386 yet"
		exit 1
}

build		{ cd ${worksrcpath}
		  system "ulimit -s unlimited && make"
		}

post-destroot	{ file delete -force ${destroot}${prefix}/lib/hmake

		  file delete ${destroot}${prefix}/bin/cpphs
		  file delete ${destroot}${prefix}/bin/hi
		  file delete ${destroot}${prefix}/bin/hmake
		  file delete ${destroot}${prefix}/bin/hmake-config

		  file rename ${destroot}${prefix}/bin/harch ${destroot}${prefix}/bin/harch-${name}

#
# NB - The greencard-nhc98 and hp2graph scripts are hardlinks to
#      the same file. Change one, all are changed.
#
		  cd ${destroot}${prefix}/bin
		  reinplace "s|${prefix}/bin/harch|${prefix}/bin/harch\-nhc98|"     greencard\-nhc98
		  reinplace "s|\{NHC98BINDIR\}/harch|\{NHC98BINDIR\}/harch\-nhc98|" ${destroot}${prefix}/bin/hood
		  reinplace "s|NHC98BINDIR/harch|NHC98BINDIR/harch\-nhc98|"         ${destroot}${prefix}/bin/nhc98

		  file delete ${destroot}${prefix}/share/man/man1/harch.1
		  file delete ${destroot}${prefix}/share/man/man1/hi.1
		  file delete ${destroot}${prefix}/share/man/man1/hmake.1
}

post-activate	{ cd ${prefix}/lib/${name}
		  system "find . -name \"*.a\" -exec ranlib -s {} \\;"
		}
