#!/bin/sh
exedir="/usr/pkg/lib/ghc-9.2.1/bin"
exeprog="hsc2hs"
executablename="$exedir/$exeprog"
datadir="/usr/pkg/share"
bindir="/usr/pkg/bin"
topdir="/usr/pkg/lib/ghc-9.2.1"
HSC2HS_EXTRA="--cflag=-O2 --cflag=-I/usr/include --cflag=-I/usr/pkg/include --cflag=-fPIC --lflag=-Wl,-zrelro --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/"

read_response() {
    response_file=$1
    if [ -f "$response_file" ]; then
        while read -r arg; do
            case "$arg" in
                -t*)          tflag=;;
                --template=*) tflag=;;
                @*)           read_response "${arg#"@"}" ;;
                --)           break;;
            esac
        done < "$response_file"
    fi
}

for arg do
    case "$arg" in
        -t*)          tflag=;;
        --template=*) tflag=;;
        @*)           read_response "${arg#"@"}" ;;
        --)           break;;
    esac
done

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