-
Notifications
You must be signed in to change notification settings - Fork 13
/
Setup.hs
59 lines (50 loc) · 2.03 KB
/
Setup.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{-# LANGUAGE CPP #-}
import Distribution.Simple
import Distribution.Simple.BuildPaths (autogenModulesDir)
import Distribution.Simple.InstallDirs as I
import Distribution.Simple.LocalBuildInfo as L
import qualified Distribution.Simple.Setup as S
import qualified Distribution.Simple.Program as P
import Distribution.Simple.Utils (createDirectoryIfMissingVerbose, rewriteFile)
import Distribution.PackageDescription
import Distribution.Text
import System.FilePath ((</>), splitDirectories,isAbsolute)
-- -----------------------------------------------------------------------------
-- Make Commands
-- use GNU make on FreeBSD
#if defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS)
mymake = "gmake"
#else
mymake = "make"
#endif
make verbosity =
P.runProgramInvocation verbosity . P.simpleProgramInvocation mymake
idrisLLVMClean _ flags _ _ = do
make verbosity [ "-C", "src/rts", "clean", "IDRIS=idris" ]
where
verbosity = S.fromFlag $ S.cleanVerbosity flags
idrisLLVMInstall verbosity copy pkg local = do
installLLVMRTS
where
target = datadir $ L.absoluteInstallDirs pkg local copy
installLLVMRTS = do
let target' = target </> "rts"
putStrLn $ "Installing LLVM runtime in " ++ target
makeInstall "src/rts" target
makeInstall src target =
make verbosity [ "-C", src, "install", "TARGET=" ++ target ]
idrisLLVMBuild _ flags _ local = do
buildLLVM
where
verbosity = S.fromFlag $ S.buildVerbosity flags
buildLLVM = make verbosity ["-C", "src/rts", "build"]
main = defaultMainWithHooks $ simpleUserHooks
{ postClean = idrisLLVMClean
, postBuild = idrisLLVMBuild
, postCopy = \_ flags pkg local ->
idrisLLVMInstall (S.fromFlag $ S.copyVerbosity flags)
(S.fromFlag $ S.copyDest flags) pkg local
, postInst = \_ flags pkg local ->
idrisLLVMInstall (S.fromFlag $ S.installVerbosity flags)
NoCopyDest pkg local
}