diff options
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | configure.hs | 63 |
2 files changed, 43 insertions, 22 deletions
@@ -115,3 +115,5 @@ in the Haskell mailing lists for their help. | |||
115 | - Tracy Wadleigh improved the definitions of (|>) and (><), which now | 115 | - Tracy Wadleigh improved the definitions of (|>) and (><), which now |
116 | apply an appropriate 'take' to the given lists so that they may be | 116 | apply an appropriate 'take' to the given lists so that they may be |
117 | safely used on lists that are too long (or infinite). | 117 | safely used on lists that are too long (or infinite). |
118 | |||
119 | - Chris Waterson improved the configure.hs program for OS/X. | ||
diff --git a/configure.hs b/configure.hs index d34cbe8..da18302 100644 --- a/configure.hs +++ b/configure.hs | |||
@@ -18,7 +18,7 @@ | |||
18 | -} | 18 | -} |
19 | 19 | ||
20 | import System | 20 | import System |
21 | import Data.List(isPrefixOf) | 21 | import Data.List(isPrefixOf, intercalate) |
22 | import Distribution.Simple.LocalBuildInfo | 22 | import Distribution.Simple.LocalBuildInfo |
23 | import Distribution.Simple.Configure | 23 | import Distribution.Simple.Configure |
24 | import Distribution.PackageDescription | 24 | import Distribution.PackageDescription |
@@ -36,34 +36,52 @@ opts = [ "" -- Ubuntu/Debian | |||
36 | ] | 36 | ] |
37 | 37 | ||
38 | -- compile a simple program with symbols from GSL and LAPACK with the given libs | 38 | -- compile a simple program with symbols from GSL and LAPACK with the given libs |
39 | testprog libs fmks = "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){zgesvd_(); gsl_sf_gamma(5);}\"" | 39 | testprog buildInfo libs fmks = |
40 | ++" > /tmp/dummy.c; gcc /tmp/dummy.c -o /tmp/dummy " | 40 | "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){zgesvd_(); gsl_sf_gamma(5);}\"" |
41 | ++ f1 libs ++ " " ++ f2 fmks ++ " > /dev/null 2> /dev/null" | 41 | ++" > /tmp/dummy.c; gcc " |
42 | 42 | ++ (join $ ccOptions buildInfo) ++ " " | |
43 | f1 = unwords . map ("-l"++) . words | 43 | ++ (join $ cppOptions buildInfo) ++ " " |
44 | f2 = unwords . map ("-framework "++) . words | 44 | ++ (join $ map ("-I"++) $ includeDirs buildInfo) |
45 | 45 | ++" /tmp/dummy.c -o /tmp/dummy " | |
46 | check libs fmks = (ExitSuccess ==) `fmap` system (testprog libs fmks) | 46 | ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " " |
47 | ++ (prepend "-l" $ libs) ++ " " | ||
48 | ++ (prepend "-framework " fmks) ++ " > /dev/null 2> /dev/null" | ||
49 | |||
50 | join = intercalate " " | ||
51 | prepend x = unwords . map (x++) . words | ||
52 | |||
53 | check buildInfo libs fmks = (ExitSuccess ==) `fmap` system (testprog buildInfo libs fmks) | ||
47 | 54 | ||
48 | -- simple test for GSL | 55 | -- simple test for GSL |
49 | gsl = "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){gsl_sf_gamma(5);}\"" | 56 | gsl buildInfo = "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){gsl_sf_gamma(5);}\"" |
50 | ++" > /tmp/dummy.c; gcc /tmp/dummy.c -o /tmp/dummy -lgsl -lgslcblas" | 57 | ++" > /tmp/dummy.c; gcc " |
58 | ++ (join $ ccOptions buildInfo) ++ " " | ||
59 | ++ (join $ cppOptions buildInfo) ++ " " | ||
60 | ++ (join $ map ("-I"++) $ includeDirs buildInfo) | ||
61 | ++ " /tmp/dummy.c -o /tmp/dummy " | ||
62 | ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas" | ||
51 | ++ " > /dev/null 2> /dev/null" | 63 | ++ " > /dev/null 2> /dev/null" |
52 | 64 | ||
53 | -- test for gsl >= 1.12 | 65 | -- test for gsl >= 1.12 |
54 | gsl112 = "echo \"#include <gsl/gsl_sf_exp.h>\nint main(){gsl_sf_exprel_n_CF_e(1,1,0);}\"" | 66 | gsl112 buildInfo = |
55 | ++" > /tmp/dummy.c; gcc /tmp/dummy.c -o /tmp/dummy -lgsl -lgslcblas" | 67 | "echo \"#include <gsl/gsl_sf_exp.h>\nint main(){gsl_sf_exprel_n_CF_e(1,1,0);}\"" |
68 | ++" > /tmp/dummy.c; gcc /tmp/dummy.c " | ||
69 | ++ (join $ ccOptions buildInfo) ++ " " | ||
70 | ++ (join $ cppOptions buildInfo) ++ " " | ||
71 | ++ (join $ map ("-I"++) $ includeDirs buildInfo) | ||
72 | ++" -o /tmp/dummy " | ||
73 | ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas" | ||
56 | ++ " > /dev/null 2> /dev/null" | 74 | ++ " > /dev/null 2> /dev/null" |
57 | 75 | ||
58 | 76 | ||
59 | checkCommand c = (ExitSuccess ==) `fmap` system c | 77 | checkCommand c = (ExitSuccess ==) `fmap` system c |
60 | 78 | ||
61 | -- test different configurations until the first one works | 79 | -- test different configurations until the first one works |
62 | try _ _ [] = return Nothing | 80 | try _ _ _ [] = return Nothing |
63 | try b f (opt:rest) = do | 81 | try i b f (opt:rest) = do |
64 | ok <- check (b ++ " " ++ opt) f | 82 | ok <- check i (b ++ " " ++ opt) f |
65 | if ok then return (Just opt) | 83 | if ok then return (Just opt) |
66 | else try b f rest | 84 | else try i b f rest |
67 | 85 | ||
68 | -- read --configure-option=link:lib1,lib2,lib3,etc | 86 | -- read --configure-option=link:lib1,lib2,lib3,etc |
69 | linkop = "link:" | 87 | linkop = "link:" |
@@ -79,8 +97,9 @@ main = do | |||
79 | Just bInfo <- maybeGetPersistBuildConfig "dist" | 97 | Just bInfo <- maybeGetPersistBuildConfig "dist" |
80 | 98 | ||
81 | let Just lib = library . localPkgDescr $ bInfo | 99 | let Just lib = library . localPkgDescr $ bInfo |
82 | base = unwords . extraLibs . libBuildInfo $ lib | 100 | buildInfo = libBuildInfo lib |
83 | fwks = unwords . frameworks . libBuildInfo $ lib | 101 | base = unwords . extraLibs $ buildInfo |
102 | fwks = unwords . frameworks $ buildInfo | ||
84 | auxpref = getUserLink args | 103 | auxpref = getUserLink args |
85 | 104 | ||
86 | -- We extract the desired libs from hmatrix.cabal (using a cabal flags) | 105 | -- We extract the desired libs from hmatrix.cabal (using a cabal flags) |
@@ -90,11 +109,11 @@ main = do | |||
90 | let pref = if null (words (base ++ " " ++ auxpref)) then "gsl lapack" else auxpref | 109 | let pref = if null (words (base ++ " " ++ auxpref)) then "gsl lapack" else auxpref |
91 | fullOpts = map ((pref++" ")++) opts | 110 | fullOpts = map ((pref++" ")++) opts |
92 | 111 | ||
93 | r <- try base fwks fullOpts | 112 | r <- try buildInfo base fwks fullOpts |
94 | case r of | 113 | case r of |
95 | Nothing -> do | 114 | Nothing -> do |
96 | putStrLn " FAIL" | 115 | putStrLn " FAIL" |
97 | g <- checkCommand gsl | 116 | g <- checkCommand $ gsl buildInfo |
98 | if g | 117 | if g |
99 | then putStrLn " *** Sorry, I can't link LAPACK." | 118 | then putStrLn " *** Sorry, I can't link LAPACK." |
100 | else putStrLn " *** Sorry, I can't link GSL." | 119 | else putStrLn " *** Sorry, I can't link GSL." |
@@ -104,7 +123,7 @@ main = do | |||
104 | writeFile "hmatrix.buildinfo" ("buildable: False\n") | 123 | writeFile "hmatrix.buildinfo" ("buildable: False\n") |
105 | Just ops -> do | 124 | Just ops -> do |
106 | putStrLn " OK" | 125 | putStrLn " OK" |
107 | g <- checkCommand gsl112 | 126 | g <- checkCommand $ gsl112 buildInfo |
108 | writeFile "hmatrix.buildinfo" $ "extra-libraries: " ++ | 127 | writeFile "hmatrix.buildinfo" $ "extra-libraries: " ++ |
109 | ops ++ "\n" ++ | 128 | ops ++ "\n" ++ |
110 | if g | 129 | if g |