summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--THANKS3
-rw-r--r--configure.hs45
2 files changed, 29 insertions, 19 deletions
diff --git a/THANKS b/THANKS
index bd68343..8797578 100644
--- a/THANKS
+++ b/THANKS
@@ -72,3 +72,6 @@ and all the people in the Haskell mailing lists for their help.
72 72
73- Max Suica simplified the installation on Windows and improved the instructions. 73- Max Suica simplified the installation on Windows and improved the instructions.
74 74
75- Vivian McPhail fixed configure.hs to allow non-root user installation in
76 case that /tmp is not writable.
77
diff --git a/configure.hs b/configure.hs
index 597affa..9b8a177 100644
--- a/configure.hs
+++ b/configure.hs
@@ -18,6 +18,7 @@
18-} 18-}
19 19
20import System 20import System
21import System.Directory(createDirectoryIfMissing)
21import Data.List(isPrefixOf, intercalate) 22import Data.List(isPrefixOf, intercalate)
22import Distribution.Simple.LocalBuildInfo 23import Distribution.Simple.LocalBuildInfo
23import Distribution.Simple.Configure 24import Distribution.Simple.Configure
@@ -37,13 +38,14 @@ opts = [ "" -- Ubuntu/Debian
37 ] 38 ]
38 39
39-- compile a simple program with symbols from GSL and LAPACK with the given libs 40-- compile a simple program with symbols from GSL and LAPACK with the given libs
40testprog buildInfo libs fmks = 41testprog bInfo buildInfo libs fmks =
41 "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){zgesvd_(); gsl_sf_gamma(5);}\"" 42 "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){zgesvd_(); gsl_sf_gamma(5);}\""
42 ++" > /tmp/dummy.c; gcc " 43 ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc "
43 ++ (join $ ccOptions buildInfo) ++ " " 44 ++ (join $ ccOptions buildInfo) ++ " "
44 ++ (join $ cppOptions buildInfo) ++ " " 45 ++ (join $ cppOptions buildInfo) ++ " "
45 ++ (join $ map ("-I"++) $ includeDirs buildInfo) 46 ++ (join $ map ("-I"++) $ includeDirs buildInfo) ++ " "
46 ++" /tmp/dummy.c -o /tmp/dummy " 47 ++ (buildDir bInfo) ++ "/dummy.c -o "
48 ++ (buildDir bInfo) ++ "/dummy "
47 ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " " 49 ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " "
48 ++ (prepend "-l" $ libs) ++ " " 50 ++ (prepend "-l" $ libs) ++ " "
49 ++ (prepend "-framework " fmks) ++ " > /dev/null 2> /dev/null" 51 ++ (prepend "-framework " fmks) ++ " > /dev/null 2> /dev/null"
@@ -51,26 +53,28 @@ testprog buildInfo libs fmks =
51join = intercalate " " 53join = intercalate " "
52prepend x = unwords . map (x++) . words 54prepend x = unwords . map (x++) . words
53 55
54check buildInfo libs fmks = (ExitSuccess ==) `fmap` system (testprog buildInfo libs fmks) 56check bInfo buildInfo libs fmks = (ExitSuccess ==) `fmap` system (testprog bInfo buildInfo libs fmks)
55 57
56-- simple test for GSL 58-- simple test for GSL
57gsl buildInfo = "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){gsl_sf_gamma(5);}\"" 59gsl bInfo buildInfo = "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){gsl_sf_gamma(5);}\""
58 ++" > /tmp/dummy.c; gcc " 60 ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc "
59 ++ (join $ ccOptions buildInfo) ++ " " 61 ++ (join $ ccOptions buildInfo) ++ " "
60 ++ (join $ cppOptions buildInfo) ++ " " 62 ++ (join $ cppOptions buildInfo) ++ " "
61 ++ (join $ map ("-I"++) $ includeDirs buildInfo) 63 ++ (join $ map ("-I"++) $ includeDirs buildInfo) ++ " "
62 ++ " /tmp/dummy.c -o /tmp/dummy " 64 ++ (buildDir bInfo) ++ "/dummy.c -o "
65 ++ (buildDir bInfo) ++ "/dummy "
63 ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas" 66 ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas"
64 ++ " > /dev/null 2> /dev/null" 67 ++ " > /dev/null 2> /dev/null"
65 68
66-- test for gsl >= 1.12 69-- test for gsl >= 1.12
67gsl112 buildInfo = 70gsl112 bInfo buildInfo =
68 "echo \"#include <gsl/gsl_sf_exp.h>\nint main(){gsl_sf_exprel_n_CF_e(1,1,0);}\"" 71 "echo \"#include <gsl/gsl_sf_exp.h>\nint main(){gsl_sf_exprel_n_CF_e(1,1,0);}\""
69 ++" > /tmp/dummy.c; gcc /tmp/dummy.c " 72 ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc "
73 ++ (buildDir bInfo) ++ "/dummy.c "
70 ++ (join $ ccOptions buildInfo) ++ " " 74 ++ (join $ ccOptions buildInfo) ++ " "
71 ++ (join $ cppOptions buildInfo) ++ " " 75 ++ (join $ cppOptions buildInfo) ++ " "
72 ++ (join $ map ("-I"++) $ includeDirs buildInfo) 76 ++ (join $ map ("-I"++) $ includeDirs buildInfo)
73 ++" -o /tmp/dummy " 77 ++" -o " ++ (buildDir bInfo) ++ "/dummy "
74 ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas" 78 ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas"
75 ++ " > /dev/null 2> /dev/null" 79 ++ " > /dev/null 2> /dev/null"
76 80
@@ -78,11 +82,11 @@ gsl112 buildInfo =
78checkCommand c = (ExitSuccess ==) `fmap` system c 82checkCommand c = (ExitSuccess ==) `fmap` system c
79 83
80-- test different configurations until the first one works 84-- test different configurations until the first one works
81try _ _ _ [] = return Nothing 85try _ _ _ _ [] = return Nothing
82try i b f (opt:rest) = do 86try l i b f (opt:rest) = do
83 ok <- check i (b ++ " " ++ opt) f 87 ok <- check l i (b ++ " " ++ opt) f
84 if ok then return (Just opt) 88 if ok then return (Just opt)
85 else try i b f rest 89 else try l i b f rest
86 90
87-- read --configure-option=link:lib1,lib2,lib3,etc 91-- read --configure-option=link:lib1,lib2,lib3,etc
88linkop = "link:" 92linkop = "link:"
@@ -110,11 +114,14 @@ main = do
110 let pref = if null (words (base ++ " " ++ auxpref)) then "gsl lapack" else auxpref 114 let pref = if null (words (base ++ " " ++ auxpref)) then "gsl lapack" else auxpref
111 fullOpts = map ((pref++" ")++) opts 115 fullOpts = map ((pref++" ")++) opts
112 116
113 r <- try buildInfo base fwks fullOpts 117 -- create the build directory (used for tmp files) if necessary
118 createDirectoryIfMissing True $ buildDir bInfo
119
120 r <- try bInfo buildInfo base fwks fullOpts
114 case r of 121 case r of
115 Nothing -> do 122 Nothing -> do
116 putStrLn " FAIL" 123 putStrLn " FAIL"
117 g <- checkCommand $ gsl buildInfo 124 g <- checkCommand $ gsl bInfo buildInfo
118 if g 125 if g
119 then putStrLn " *** Sorry, I can't link LAPACK." 126 then putStrLn " *** Sorry, I can't link LAPACK."
120 else putStrLn " *** Sorry, I can't link GSL." 127 else putStrLn " *** Sorry, I can't link GSL."
@@ -124,7 +131,7 @@ main = do
124 writeFile "hmatrix.buildinfo" ("buildable: False\n") 131 writeFile "hmatrix.buildinfo" ("buildable: False\n")
125 Just ops -> do 132 Just ops -> do
126 putStrLn " OK" 133 putStrLn " OK"
127 g <- checkCommand $ gsl112 buildInfo 134 g <- checkCommand $ gsl112 bInfo buildInfo
128 writeFile "hmatrix.buildinfo" $ "extra-libraries: " ++ 135 writeFile "hmatrix.buildinfo" $ "extra-libraries: " ++
129 ops ++ "\n" ++ 136 ops ++ "\n" ++
130 if g 137 if g