@@ -1,4 +1,3 @@
1−{-# LANGUAGE TemplateHaskell #-}
2import Distribution.Simple
1import Distribution.Simple
3import Distribution.Simple.LocalBuildInfo
2import Distribution.Simple.LocalBuildInfo
4import Distribution.Simple.Setup
3import Distribution.Simple.Setup
@@ -10,7 +9,6 @@ import System.Process
10import System.Directory
9import System.Directory
11import System.FilePath
10import System.FilePath
12import System.Exit
11import System.Exit
13−import Language.Haskell.TH (appE, varE, mkName, conE)
15main = defaultMainWithHooks hk
13main = defaultMainWithHooks hk
@@ -34,11 +32,7 @@ cArgsHC = map ("-optc" ++) cArgs
35canUseRDRAND :: FilePath -> IO Bool
33canUseRDRAND :: FilePath -> IO Bool
36canUseRDRAND cc = do
34canUseRDRAND cc = do
37− -- Template haskell to call withTempDirectory in a backward compatible way
35+ withTempDirectory normal "" "testRDRAND" $ \tmpDir -> do
38− -- withTempDirectory normal False "" "testRDRAND" $ \tmpDir -> do
39− $(if cabalVersion >= Version [1,17,0] []
40− then appE (appE (varE $ mkName "withTempDirectory") (varE 'normal)) (conE (mkName "False"))
41− else appE (varE $ mkName "withTempDirectory") (varE 'normal)) "" "testRDRAND" $ \tmpDir -> do
42 writeFile (tmpDir ++ "/testRDRAND.c")
36 writeFile (tmpDir ++ "/testRDRAND.c")
43 (unlines [ "#include <stdint.h>"
37 (unlines [ "#include <stdint.h>"
44 , "int main() {"
38 , "int main() {"