--- Portfile.orig	2008-01-15 05:10:40.000000000 -0700
+++ Portfile	2008-03-17 15:02:54.000000000 -0700
@@ -1,72 +1,59 @@
-# $Id: Portfile 32946 2008-01-15 12:10:40Z ryandesign@macports.org $
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
+# $Id$
 
 PortSystem 1.0
+
 name		nhc98
-version		1.18
-revision	4
+version		1.20
 categories	lang
 maintainers	nomaintainer
 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
-
-build		{	if {${os.platform} == "darwin" && ${os.arch} == "i386"} {
-				ui_error "nhc98 is not supported on OS X i386 yet"
-				return 1
-			}
-			
-			system "cd ${worksrcpath} && 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.
-#
-		  reinplace "s|${prefix}/bin/harch|${prefix}/bin/harch\-nhc98|"     ${destroot}${prefix}/bin/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
+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}
+
+checksums \
+    md5 55c102408da8085aa56984af4151eb9c \
+    sha1 5bcfa0e8cc192afc5a54aab0bd4c1812dafa7b45 \
+    rmd160 011e723a956f2fb9029357d00ddb705c350309af
+
+depends_lib port:readline port:ncurses
+
+configure.args \
+    --buildwith=gcc \
+    +docs \
+    --docdir=${prefix}/share/doc/${name} \
+    --mandir=${prefix}/share/man/man1 \
+    --heap=8M
+
+patchfiles Makefile.nhc98.diff 
+
+post-patch {
+    reinplace "s|-\$(CC)|-\${BUILDCOMP}|g" ${worksrcpath}/Makefile
+}
+
+post-destroot {
+    set rexp1 "'s|${worksrcpath}/script|${prefix}/bin|g'"
+    set rexp2 "'s|${worksrcpath}/include|${prefix}/include/nhc98|g'"
+    set rfile "${destroot}${prefix}/lib/hmake/`${worksrcpath}/script/harch`/hmakerc"
+    system "sed -i '' -e ${rexp1} -e ${rexp2} ${rfile}"
 }
 
-post-activate	{ system "find ${prefix}/lib/${name} -name \"*.a\" -exec ranlib -s {} \\;"
-		}
+livecheck.check  regex
+livecheck.regex  "Version (.*) released"
