Add support for response files in wrapper script
[hsc2hs.git] / hsc2hs.wrapper
index 50116bb..ee1ad9d 100644 (file)
@@ -1,15 +1,29 @@
 #!/bin/sh
 
-tflag="--template=$datadir/template-hsc.h"
-Iflag="-I$datadir/../include/"
+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
-        -c*)          HSC2HS_EXTRA=;;
-        --cc=*)       HSC2HS_EXTRA=;;
         -t*)          tflag=;;
         --template=*) tflag=;;
+        @*)           read_response "${arg#"@"}" ;;
         --)           break;;
     esac
 done
 
-exec $executablename $tflag $HSC2HS_EXTRA ${1+"$@"} "$Iflag"
+exec "$executablename" ${tflag:+"$tflag"} $HSC2HS_EXTRA ${1+"$@"} "$Iflag"