version discovery magic
Malcolm Wallace
Malcolm.Wallace@cs.york.ac.uk
Wed, 7 Feb 2001 14:54:56 +0000
A year or two ago, someone (Simon M, I think) supplied me with some
magic shell code to discover the version of an installed GHC and the
location of its standard interface files. The interface discovery
bit relied on grepping through the perl driver script.
Now that the perl driver is dead (hurrah!) in GHC 5.x, is there another
way for me to discover where the interfaces reside? (I believe the
version-discovery is still valid regardless of the driver.)
To jog your memory, here is the original shell code
whichGHC=`which ghc`
# discover the version number
GHCVER=`${whichGHC} --version 2>&1 | sed 's/^.*version[ ]*\([0-9.]*\).*/\1/'`
# discover the location of interface files
GHCDIR=`grep '^\$libdir=' ${whichGHC} | head -1 | sed 's/^\$libdir=[^/]*\(.*\).;/\1/'`
if [ -d $GHCDIR/imports ]
then GHCINCDIR=$GHCDIR/imports
elif [ -d $GHCDIR/lib/imports ]
then GHCINCDIR=$GHCDIR/lib/imports
else GHCDIR=""
fi
Thanks.
Malcolm