@@ -74,12 +74,10 @@ buildMakeActions outputDir filePathMap usePrefix =
7474 let path = fromMaybe (error "Module has no filename in 'make'") $ M.lookup mn filePathMap
7575 let filePath = either (const []) takeDirectory path
7676 fileBase = filePath </> (last . words . dotsTo ' ' $ P.runModuleName mn)
77− sourceFFI = addExtension fileBase sourceExt
78− headerFFI = addExtension fileBase headerExt
77+ ffis = addExtension fileBase <$> [sourceExt, headerExt] ++ otherExts
7978 e1 <- traverse getTimestamp path
80− sffi <- getTimestamp sourceFFI
81− hffi <- getTimestamp headerFFI
82− return $ fmap (max (max sffi hffi)) e1
79+ ffimax <- foldl1 max <$> mapM getTimestamp ffis
80+ return $ max ffimax <$> e1
8381
8482 getOutputTimestamp :: P.ModuleName -> Make (Maybe UTCTime)
8583 getOutputTimestamp mn = do
@@ -135,6 +133,8 @@ buildMakeActions outputDir filePathMap usePrefix =
135133 sfileExists <- textFileExists sfile
136134 when (sfileExists) $ do
137135 copyTextFile (addExtension (fileBase ++ ffiMangle) sourceExt) sfile
136+ mapM (copyTextFileWithExt fileBase inputPath) otherExts
137+ return ()
138138
139139 requiresForeign :: CF.Module a -> Bool
140140 requiresForeign = not . null . CF.moduleForeign
@@ -160,6 +160,12 @@ buildMakeActions outputDir filePathMap usePrefix =
160160 createDirectoryIfMissing True (takeDirectory to)
161161 copyFile from to
162162
163+ copyTextFileWithExt :: FilePath -> FilePath -> String -> Make ()
164+ copyTextFileWithExt to from ext = makeIO (const (ErrorMessage [] $ CannotWriteFile to)) $ do
165+ createDirectoryIfMissing True (takeDirectory to)
166+ _ <- tryIOError $ copyFile (addExtension from ext) (addExtension to ext)
167+ return ()
168+
163169 writeTextFile :: FilePath -> String -> Make ()
164170 writeTextFile path text = makeIO (const (ErrorMessage [] $ CannotWriteFile path)) $ do
165171 createDirectoryIfMissing True (takeDirectory path)
@@ -182,5 +188,8 @@ headerExt = "hh"
182188sourceExt :: String
183189sourceExt = "cc"
184190
191+otherExts :: [String]
192+otherExts = ["h", "inl"]
193+
185194ffiMangle :: String
186195ffiMangle = "_ffi"