Skip to content
Newer
Older
100644 46 lines (37 sloc) 1.32 KB
5264c5e @bos A very basic initial commit.
authored Apr 27, 2011
1 #!/usr/bin/env runhaskell
2
3 \begin{code}
4 {- OPTIONS_GHC -Wall #-}
5
6 import Control.Monad (liftM2, mplus)
7 import Data.List (isPrefixOf)
8 import Distribution.PackageDescription
9 import Distribution.Simple
10 import Distribution.Simple.LocalBuildInfo
11 import Distribution.Simple.Program
12 import Distribution.Verbosity
13
14 main = defaultMainWithHooks simpleUserHooks {
15 hookedPrograms = [mysqlConfigProgram],
16
17 confHook = \pkg flags -> do
18 lbi <- confHook simpleUserHooks pkg flags
19 bi <- mysqlBuildInfo lbi
20 return lbi {
21 localPkgDescr = updatePackageDescription (Just bi, []) (localPkgDescr lbi)
22 }
23 }
24
25 mysqlConfigProgram = (simpleProgram "mysql_config") {
26 programFindLocation = \verbosity -> liftM2 mplus
27 (findProgramLocation verbosity "mysql_config")
28 (findProgramLocation verbosity "mysql_config5")
29 }
30
31 mysqlBuildInfo :: LocalBuildInfo -> IO BuildInfo
32 mysqlBuildInfo lbi = do
33 let mysqlConfig = fmap words . rawSystemProgramStdoutConf normal
34 mysqlConfigProgram (withPrograms lbi)
35
36 include <- mysqlConfig ["--include"]
37 libs <- mysqlConfig ["--libs"]
38
39 return emptyBuildInfo {
40 extraLibDirs = map (drop 2) . filter ("-L" `isPrefixOf`) $ libs
6c7d0ed @bos Drop libmygcc from the list of required libraries.
authored May 16, 2011
41 , extraLibs = map (drop 2) . filter ("-l" `isPrefixOf`) .
42 filter (/= "-lmygcc") $ libs
5264c5e @bos A very basic initial commit.
authored Apr 27, 2011
43 , includeDirs = map (drop 2) include
44 }
45 \end{code}
Something went wrong with that request. Please try again.