@@ -1,3 +1,5 @@
1+{-# LANGUAGE CPP #-}
2+import Control.Monad
13import Distribution.Simple
24import Distribution.Simple.LocalBuildInfo
35import Distribution.Simple.Setup
@@ -9,6 +11,7 @@ import System.Process
911import System.Directory
1012import System.FilePath
1113import System.Exit
14+import System.IO
1215
1316main = defaultMainWithHooks hk
1417 where
@@ -44,6 +47,30 @@ canUseRDRAND cc = do
4447 , " return (!err);"
4548 , "}"
4649 ])
47− ec <- rawSystemExitCode normal cc [tmpDir </> "testRDRAND.c", "-o", tmpDir ++ "/a.o","-c"]
50+ ec <- myRawSystemExitCode normal cc [tmpDir </> "testRDRAND.c", "-o", tmpDir ++ "/a.o","-c"]
4851 notice normal $ "Result of RDRAND Test: " ++ show (ec == ExitSuccess)
4952 return (ec == ExitSuccess)
53+
54+myRawSystemExitCode :: Verbosity -> FilePath -> [String] -> IO ExitCode
55+#if __GLASGOW_HASKELL__ >= 704
56+-- We know for sure, that if GHC >= 7.4 implies Cabal >= 1.14
57+myRawSystemExitCode = rawSystemExitCode
58+#else
59+-- Legacy branch:
60+-- We implement our own 'rawSystemExitCode', this will even work if
61+-- the user happens to have Cabal >= 1.14 installed with GHC 7.0 or
62+-- 7.2
63+myRawSystemExitCode verbosity path args = do
64+ printRawCommandAndArgs verbosity path args
65+ hFlush stdout
66+ exitcode <- rawSystem path args
67+ unless (exitcode == ExitSuccess) $ do
68+ debug verbosity $ path ++ " returned " ++ show exitcode
69+ return exitcode
70+ where
71+ printRawCommandAndArgs :: Verbosity -> FilePath -> [String] -> IO ()
72+ printRawCommandAndArgs verbosity path args
73+ | verbosity >= deafening = print (path, args)
74+ | verbosity >= verbose = putStrLn $ unwords (path : args)
75+ | otherwise = return ()
76+#endif