2import Distribution.Simple
3import Distribution.Simple.LocalBuildInfo
4import Distribution.Simple.Setup
5import Distribution.PackageDescription
6import Distribution.Simple.Utils
7import Distribution.Simple.Program
8import Distribution.Verbosity
10import System.Directory
14main = defaultMainWithHooks hk
16 hk = simpleUserHooks { buildHook = \pd lbi uh bf -> do
17 let ccProg0 = Program "gcc" undefined undefined undefined
18 ccProg1 = Program "clang" undefined undefined undefined
19 f x = lookupProgram x (withPrograms lbi)
20 mConf = f ccProg0 `mplus` f ccProg1
21 err = error "Could not determine C compiler"
22 cc = locationPath . programLocation . maybe err id $ mConf
23 print (withPrograms lbi)
25 let newWithPrograms1 = userSpecifyArgs "gcc" cArgs (withPrograms lbi)
26 newWithPrograms = userSpecifyArgs "ghc" cArgsHC newWithPrograms1
27 lbiNew = if b then (lbi {withPrograms = newWithPrograms }) else lbi
28 buildHook simpleUserHooks pd lbiNew uh bf
32cArgs = ["-DHAVE_RDRAND"]
35cArgsHC = map ("-optc" ++) cArgs
37canUseRDRAND :: FilePath -> IO Bool
39 withTempDirectory normal "" "testRDRAND" $ \tmpDir -> do
40 -- withTempDirectory normal False "" "testRDRAND" $ \tmpDir -> do
41 writeFile (tmpDir ++ "/testRDRAND.c")
42 (unlines [ "#include <stdint.h>"
44 , " uint64_t therand;"
45 , " unsigned char err;"
46 , " asm volatile(\"rdrand %0 ; setc %1\""
47 , " : \"=r\" (therand), \"=qm\" (err));"
51 ec <- rawSystemExitCode normal cc [tmpDir </> "testRDRAND.c", "-o" ++ tmpDir ++ "/a.out"]
52 notice normal $ "Result of RDRAND Test: " ++ show (ec == ExitSuccess)
53 return (ec == ExitSuccess)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list