Add a -I flag with the path to HsFFI.h
authorIan Lynagh <igloo@earth.li>
Tue, 17 Feb 2009 20:24:07 +0000 (20:24 +0000)
committerIan Lynagh <igloo@earth.li>
Tue, 17 Feb 2009 20:24:07 +0000 (20:24 +0000)
This can still be overridden by adding a -I flag to the commandline,
but it means that hsc2hs will work if no flags are given.

Main.hs
hsc2hs.wrapper

diff --git a/Main.hs b/Main.hs
index 3a50071..cb6f6d0 100644 (file)
--- a/Main.hs
+++ b/Main.hs
@@ -144,12 +144,14 @@ main = do
                    -- Paths_hsc2hs isn't too useful for a
                    -- relocatable binary, though.
                      let templ1 = path ++ "/hsc2hs-" ++ showVersion Main.version ++ "/template-hsc.h"
+                         incl = path ++ "/include/"
                      exists1 <- doesFileExist templ1
                      if exists1
-                        then return (Just templ1)
+                        then return $ Just (Template templ1,
+                                            CompFlag ("-I" ++ incl))
                         else return Nothing
                 case mb_templ1 of
-                    Just templ1 -> return (Template templ1 : flags)
+                    Just (templ1, incl) -> return (templ1 : flags ++ [incl])
                     Nothing -> do
                         templ2 <- getDataFileName "template-hsc.h"
                         exists2 <- doesFileExist templ2
index ec6b06a..50116bb 100644 (file)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 tflag="--template=$datadir/template-hsc.h"
+Iflag="-I$datadir/../include/"
 for arg do
     case "$arg" in
         -c*)          HSC2HS_EXTRA=;;
@@ -11,4 +12,4 @@ for arg do
     esac
 done
 
-exec $executablename $tflag $HSC2HS_EXTRA ${1+"$@"}
+exec $executablename $tflag $HSC2HS_EXTRA ${1+"$@"} "$Iflag"