@@ -3,6 +3,9 @@
3#ifndef MIN_VERSION_Cabal
3#ifndef MIN_VERSION_Cabal
4#define MIN_VERSION_Cabal(x,y,z) 0
4#define MIN_VERSION_Cabal(x,y,z) 0
6+#ifndef MIN_VERSION_directory
7+#define MIN_VERSION_directory(x,y,z) 0
6#if MIN_VERSION_Cabal(1,24,0)
9#if MIN_VERSION_Cabal(1,24,0)
7#define InstalledPackageId UnitId
10#define InstalledPackageId UnitId
@@ -26,6 +29,19 @@ import System.FilePath ( (</>) )
26import Distribution.Simple.BuildPaths ( autogenComponentModulesDir )
29import Distribution.Simple.BuildPaths ( autogenComponentModulesDir )
32+#if MIN_VERSION_directory(1,2,2)
33+import System.Directory (makeAbsolute)
35+import System.Directory (getCurrentDirectory)
36+import System.FilePath (isAbsolute)
38+makeAbsolute :: FilePath -> IO FilePath
39+makeAbsolute p | isAbsolute p = return p
41+ cwd <- getCurrentDirectory
29main :: IO ()
45main :: IO ()
30main = defaultMainWithHooks simpleUserHooks
46main = defaultMainWithHooks simpleUserHooks
31 { buildHook = \pkg lbi hooks flags -> do
47 { buildHook = \pkg lbi hooks flags -> do
@@ -58,8 +74,8 @@ generateBuildModule flags pkg lbi = do
60 -- Lib sources and includes
76 -- Lib sources and includes
61− let iArgs = map ("-i"++) $ libAutogenDir : hsSourceDirs libBI
77+ iArgs <- mapM (fmap ("-i"++) . makeAbsolute) $ libAutogenDir : hsSourceDirs libBI
62− let includeArgs = map ("-I"++) $ includeDirs libBI
78+ includeArgs <- mapM (fmap ("-I"++) . makeAbsolute) $ includeDirs libBI
64 -- CPP includes, i.e. include cabal_macros.h
80 -- CPP includes, i.e. include cabal_macros.h
65 let cppFlags = map ("-optP"++) $
81 let cppFlags = map ("-optP"++) $