Haskell + automake?

Axel Simon A.Simon@ukc.ac.uk
Mon, 5 Aug 2002 09:27:22 +0100


On Mon, Aug 05, 2002 at 01:58:30PM +1000, Andrew J Bromage wrote:
> G'day all.
> 
> Has anyone come up with some magic to let automake play nice with
> Haskell compilers (ghc 5 or nhc 98 preferred)?
gtk+hs and gtk2hs use the macro written by Michael Weber for his hMPI 
binding to check for a sufficient large version number. Otherwise, the 
normal AC_PATH_PROG is your best bet. This is how I look for ghc and 
ghc-pkg:

dnl Check for GHC-5.00 or greater.
dnl (The next command is not executed, if $HC is already set.)
AC_PATH_PROG(HC, ghc, ghc-not-found)
if test $HC = ghc-not-found; then
 AC_MSG_ERROR([
Could not find GHC!  This is the only supported compiler.
You need GHC 5.00 upwards.])
fi

GHC=$HC

dnl Check GHC details.
AC_MSG_CHECKING([version of GHC])
GHC_VERSION=`$GHC --version | $SED "s/[[a-zA-Z ,]*\([0-9.]*\)[a-zA-Z 
]]*/\1/"`
AC_MSG_RESULT([$GHC_VERSION])

GTKHS_PROG_CHECK_VERSION($GHC_VERSION, -lt, 5.0.0, [
  AC_MSG_ERROR([I need the FFI of GHC 5.00 upwards!])])

AC_MSG_CHECKING([new module system])
NEW_MODULE_SYSTEM=no;
GTKHS_PROG_CHECK_VERSION($GHC_VERSION, -ge, 
5.04.0,[NEW_MODULE_SYSTEM=yes;]);
AC_MSG_RESULT([$NEW_MODULE_SYSTEM])

GHCBARE=`basename $GHC`
GHCDIR=`dirname $GHC`
GHCPKGNAME=ghc-pkg`echo $GHCBARE | $SED s/ghc//`

dnl Check for ghc-pkg. Use the one that is in the same directory and
dnl version suffix as the specified compiler.
AC_PATH_PROGS(GHCPKG, $GHCPKGNAME ghc-pkg, ghcpkg-not-found, $GHCDIR)

if test $GHCPKG = ghcpkg-not-found; then
  AC_MSG_ERROR([ghc-pkg not found. (But ghc exists!?)]);
fi


Cheers,
Axel.