#!/bin/sh
exedir="/usr/pkg/lib/ghc-7.10.2/bin"
exeprog="hsc2hs"
executablename="$exedir/$exeprog"
datadir="/usr/pkg/share"
bindir="/usr/pkg/bin"
topdir="/usr/pkg/lib/ghc-7.10.2"
HSC2HS_EXTRA="--cflag=-O2 --cflag=-g --cflag=-ggdb --cflag=-I/usr/include --cflag=-I/usr/pkg/include --cflag=-fno-stack-protector --lflag=-L/usr/lib --lflag=-Wl,-R/usr/lib --lflag=-L/usr/pkg/lib --lflag=-Wl,-R/usr/pkg/lib"
#!/bin/sh

tflag="--template=$topdir/template-hsc.h"
Iflag="-I$topdir/include/"
for arg do
    case "$arg" in
# On OS X, we need to specify -m32 or -m64 in order to get gcc to
# build binaries for the right target. We do that by putting it in
# HSC2HS_EXTRA. When cabal runs hsc2hs, it passes a flag saying which
# gcc to use, so if we set HSC2HS_EXTRA= then we don't get binaries
# for the right platform. So for now we just don't set HSC2HS_EXTRA=
# but we probably want to revisit how this works in the future.
#        -c*)          HSC2HS_EXTRA=;;
#        --cc=*)       HSC2HS_EXTRA=;;
        -t*)          tflag=;;
        --template=*) tflag=;;
        --)           break;;
    esac
done

exec "$executablename" ${tflag:+"$tflag"} $HSC2HS_EXTRA ${1+"$@"} "$Iflag"
