diff options
author | Alberto Ruiz <aruiz@um.es> | 2013-05-21 13:30:45 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2013-05-21 13:30:45 +0200 |
commit | c5606c622cebf265ae0bb3ea32a9f2ebf2f3a79f (patch) | |
tree | 7b3b202eb267e84f7815bf8b3cc1dbae51228476 /Config.hs | |
parent | 6b2f191ea8d6665996070bf6b3e5b4109584dcab (diff) |
merge develop, fix conflicts
Diffstat (limited to 'Config.hs')
-rw-r--r-- | Config.hs | 88 |
1 files changed, 44 insertions, 44 deletions
@@ -20,6 +20,7 @@ import System.Process | |||
20 | import System.Exit | 20 | import System.Exit |
21 | import System.Environment | 21 | import System.Environment |
22 | import System.Directory(createDirectoryIfMissing) | 22 | import System.Directory(createDirectoryIfMissing) |
23 | import System.FilePath((</>)) | ||
23 | import Data.List(isPrefixOf, intercalate) | 24 | import Data.List(isPrefixOf, intercalate) |
24 | import Distribution.Simple.LocalBuildInfo | 25 | import Distribution.Simple.LocalBuildInfo |
25 | import Distribution.Simple.Configure | 26 | import Distribution.Simple.Configure |
@@ -38,61 +39,60 @@ opts = [ "" -- Ubuntu/Debian | |||
38 | , "blas gslcblas gfortran" -- Arch Linux with normal blas and lapack | 39 | , "blas gslcblas gfortran" -- Arch Linux with normal blas and lapack |
39 | ] | 40 | ] |
40 | 41 | ||
42 | -- location of test program | ||
43 | testProgLoc bInfo = buildDir bInfo </> "dummy.c" | ||
44 | testOutLoc bInfo = buildDir bInfo </> "dummy" | ||
45 | |||
46 | -- write test program | ||
47 | writeTestProg bInfo contents = writeFile (testProgLoc bInfo) contents | ||
48 | |||
49 | -- compile, discarding error messages | ||
50 | compile cmd = do | ||
51 | let processRecord = (shell $ join cmd) { std_out = CreatePipe | ||
52 | , std_err = CreatePipe } | ||
53 | ( _, _, _, h) <- createProcess processRecord | ||
54 | waitForProcess h | ||
55 | |||
56 | -- command to compile the test program | ||
57 | compileCmd bInfo buildInfo = [ "gcc " | ||
58 | , (join $ ccOptions buildInfo) | ||
59 | , (join $ cppOptions buildInfo) | ||
60 | , (join $ map ("-I"++) $ includeDirs buildInfo) | ||
61 | , testProgLoc bInfo | ||
62 | , "-o" | ||
63 | , testOutLoc bInfo | ||
64 | , (join $ map ("-L"++) $ extraLibDirs buildInfo) | ||
65 | ] | ||
66 | |||
41 | -- compile a simple program with symbols from GSL and LAPACK with the given libs | 67 | -- compile a simple program with symbols from GSL and LAPACK with the given libs |
42 | testprog bInfo buildInfo libs fmks = | 68 | testprog bInfo buildInfo libs fmks = do |
43 | "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){dgemm_(); zgesvd_(); gsl_sf_gamma(5);}\"" | 69 | writeTestProg bInfo "#include <gsl/gsl_sf_gamma.h>\nint main(){dgemm_(); zgesvd_(); gsl_sf_gamma(5);}" |
44 | ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc " | 70 | compile $ compileCmd bInfo |
45 | ++ (join $ ccOptions buildInfo) ++ " " | 71 | buildInfo |
46 | ++ (join $ cppOptions buildInfo) ++ " " | 72 | ++ [ (prepend "-l" $ libs) |
47 | ++ (join $ map ("-I"++) $ includeDirs buildInfo) ++ " " | 73 | , (prepend "-framework " fmks) ] |
48 | ++ (buildDir bInfo) ++ "/dummy.c -o " | ||
49 | ++ (buildDir bInfo) ++ "/dummy " | ||
50 | ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " " | ||
51 | ++ (prepend "-l" $ libs) ++ " " | ||
52 | ++ (prepend "-framework " fmks) ++ " > /dev/null 2> /dev/null" | ||
53 | 74 | ||
54 | join = intercalate " " | 75 | join = intercalate " " |
55 | prepend x = unwords . map (x++) . words | 76 | prepend x = unwords . map (x++) . words |
56 | 77 | ||
57 | check bInfo buildInfo libs fmks = (ExitSuccess ==) `fmap` system (testprog bInfo buildInfo libs fmks) | 78 | check bInfo buildInfo libs fmks = (ExitSuccess ==) `fmap` testprog bInfo buildInfo libs fmks |
58 | 79 | ||
59 | -- simple test for GSL | 80 | -- simple test for GSL |
60 | gsl bInfo buildInfo = "echo \"#include <gsl/gsl_sf_gamma.h>\nint main(){gsl_sf_gamma(5);}\"" | 81 | gsl bInfo buildInfo = do |
61 | ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc " | 82 | writeTestProg bInfo "#include <gsl/gsl_sf_gamma.h>\nint main(){gsl_sf_gamma(5);}" |
62 | ++ (join $ ccOptions buildInfo) ++ " " | 83 | compile $ compileCmd bInfo buildInfo ++ ["-lgsl", "-lgslcblas"] |
63 | ++ (join $ cppOptions buildInfo) ++ " " | ||
64 | ++ (join $ map ("-I"++) $ includeDirs buildInfo) ++ " " | ||
65 | ++ (buildDir bInfo) ++ "/dummy.c -o " | ||
66 | ++ (buildDir bInfo) ++ "/dummy " | ||
67 | ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas" | ||
68 | ++ " > /dev/null 2> /dev/null" | ||
69 | 84 | ||
70 | -- test for gsl >= 1.12 | 85 | -- test for gsl >= 1.12 |
71 | gsl112 bInfo buildInfo = | 86 | gsl112 bInfo buildInfo = do |
72 | "echo \"#include <gsl/gsl_sf_exp.h>\nint main(){gsl_sf_exprel_n_CF_e(1,1,0);}\"" | 87 | writeTestProg bInfo "#include <gsl/gsl_sf_exp.h>\nint main(){gsl_sf_exprel_n_CF_e(1,1,0);}" |
73 | ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc " | 88 | compile $ compileCmd bInfo buildInfo ++ ["-lgsl", "-lgslcblas"] |
74 | ++ (buildDir bInfo) ++ "/dummy.c " | ||
75 | ++ (join $ ccOptions buildInfo) ++ " " | ||
76 | ++ (join $ cppOptions buildInfo) ++ " " | ||
77 | ++ (join $ map ("-I"++) $ includeDirs buildInfo) | ||
78 | ++" -o " ++ (buildDir bInfo) ++ "/dummy " | ||
79 | ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas" | ||
80 | ++ " > /dev/null 2> /dev/null" | ||
81 | 89 | ||
82 | -- test for odeiv2 | 90 | -- test for odeiv2 |
83 | gslodeiv2 bInfo buildInfo = | 91 | gslodeiv2 bInfo buildInfo = do |
84 | "echo \"#include <gsl/gsl_odeiv2.h>\nint main(){return 0;}\"" | 92 | writeTestProg bInfo "#include <gsl/gsl_odeiv2.h>\nint main(){return 0;}" |
85 | ++" > " ++ (buildDir bInfo) ++ "/dummy.c; gcc " | 93 | compile $ compileCmd bInfo buildInfo ++ ["-lgsl", "-lgslcblas"] |
86 | ++ (buildDir bInfo) ++ "/dummy.c " | 94 | |
87 | ++ (join $ ccOptions buildInfo) ++ " " | 95 | checkCommand c = (ExitSuccess ==) `fmap` c |
88 | ++ (join $ cppOptions buildInfo) ++ " " | ||
89 | ++ (join $ map ("-I"++) $ includeDirs buildInfo) | ||
90 | ++" -o " ++ (buildDir bInfo) ++ "/dummy " | ||
91 | ++ (join $ map ("-L"++) $ extraLibDirs buildInfo) ++ " -lgsl -lgslcblas" | ||
92 | ++ " > /dev/null 2> /dev/null" | ||
93 | |||
94 | |||
95 | checkCommand c = (ExitSuccess ==) `fmap` system c | ||
96 | 96 | ||
97 | -- test different configurations until the first one works | 97 | -- test different configurations until the first one works |
98 | try _ _ _ _ [] = return Nothing | 98 | try _ _ _ _ [] = return Nothing |