GHC Installation Location

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Thu, 25 Oct 2001 13:20:55 +0100


> Is there an easy way to get 'ghc' or one of the other binaries to tell me 
> where the GHC installation directory is? I want to put the includes 
> directory in a gcc -I flag in my makefile.

For ghc >= 5.00, but not on Windows:

    #!/bin/sh
    GHCDIR=`grep '^libdir' ${whichGHC} | head -1 | sed 's/^libdir=.\(.*\)./\1/'`    if [ ! -d $GHCDIR/imports ]
    then GHCDIR=`grep '^TOPDIROPT' ${whichGHC} | head -1 | sed 's/^TOPDIROPT="*-B\([^";]*\).*/\1/'`
    fi
    echo $GHCDIR/imports

For ghc < 5.00, including on Windows:

    #!/bin/sh
    GHCDIR=`grep '^\$libdir=' ${whichGHC} | head -1 | sed 's/^\$libdir=[^/]*\(.*\).;/\1/'` 
    if [ -d $GHCDIR/imports ]
    then echo $GHCDIR/imports
    elif [ -d $GHCDIR/lib/imports ]
    then echo $GHCDIR/lib/imports
    echo echo unknown
    fi

Regards,
    Malcolm