source: trunk/SConstruct@ 2985

Last change on this file since 2985 was 2942, checked in by Malte Marquarding, 11 years ago

remove redundant libraries - lapack, blas and gfortran

File size: 8.1 KB
RevLine 
[1125]1import os
2import sys
[1082]3import distutils.sysconfig
4import platform
[1184]5import SCons
[1082]6
[1873]7# try to autodetect numpy
8def get_numpy_incdir():
9 try:
10 # try to find an egg
11 from pkg_resources import require
12 tmp = require("numpy")
13 import numpy
14 return numpy.__path__[0]+"/core/include"
15 except Exception:
16 # now try standard package
17 try:
18 import numpy
19 return numpy.__path__[0]+"/core/include"
20 except ImportError:
21 pass
22 return ""
23
[2517]24def get_libdir():
25 return os.path.basename(distutils.sysconfig.get_config_var('LIBDIR'))
26
[2518]27LIBDIR = 'lib' #get_libdir()
[2517]28
[2166]29EnsureSConsVersion(1,0,0)
[1464]30
[2503]31opts = Variables("options.cache")
[1464]32opts.AddVariables(
[2505]33 ("extraroot", "Addition tree to look for packages", None),
[2525]34 ("extraflags", "Additional build flags", None),
[1464]35 PathVariable("casacoreroot", "The location of casacore",
[1740]36 "/usr/local"),
[2506]37 BoolVariable("casacorestatic",
38 "Link statically against casacore",
39 False),
[1325]40 ("boostroot", "The root dir where boost is installed", None),
41 ("boostlib", "The name of the boost python library",
42 "boost_python"),
43 ("boostlibdir", "The boost library location", None),
44 ("boostincdir", "The boost header file location", None),
45 ("cfitsioroot",
46 "The root directory where cfistio is installed", None),
47 ("cfitsiolibdir", "The cfitsio library location", None),
[1327]48 ("cfitsiolib", "The cfitsio library name", "cfitsio"),
[1325]49 ("cfitsioincdir", "The cfitsio include location", None),
[1740]50 ("wcslib", "The wcs library name", "wcs"),
[1325]51 ("wcsroot",
52 "The root directory where wcs is installed", None),
53 ("wcslibdir", "The wcs library location", None),
[1354]54 ("rpfitslib", "The rpfits library name", "rpfits"),
[1325]55 ("rpfitsroot",
56 "The root directory where rpfits is installed", None),
57 ("rpfitslibdir", "The rpfits library location", None),
[2503]58
[1501]59 ("pyraproot", "The root directory where libpyrap is installed",
60 None),
[1873]61 ("numpyincdir", "numpy header file directory",
62 get_numpy_incdir()),
[2503]63 BoolVariable("enable_pyrap",
64 "Use pyrap conversion library from system",
65 False),
[1501]66 ("pyraplib", "The name of the pyrap library", "pyrap"),
67 ("pyraplibdir", "The directory where libpyrap is installed",
68 None),
69 ("pyrapincdir", "The pyrap include location",
70 None),
[1464]71 EnumVariable("mode", "The type of build.", "release",
[1135]72 ["release","debug"], ignorecase=1),
[2503]73 EnumVariable("makedoc",
74 "Build the userguide in specified format",
75 "none",
76 ["none", "pdf", "html"], ignorecase=1),
[1740]77 BoolVariable("apps", "Build cpp apps", True),
[1501]78 BoolVariable("alma", "Enable alma specific functionality",
79 False),
[1130]80 )
[1082]81
[1135]82env = Environment( toolpath = ['./scons'],
[2505]83 tools = ["default", "utils", "casa"],
[1135]84 ENV = { 'PATH' : os.environ[ 'PATH' ],
[1120]85 'HOME' : os.environ[ 'HOME' ] },
[1135]86 options = opts)
[1082]87
[2503]88env.Help(opts.GenerateHelpText(env))
[1120]89env.SConsignFile()
[2503]90if not ( env.GetOption('clean') or env.GetOption('help') ):
[1325]91
[1130]92 conf = Configure(env)
[2507]93 if conf.env.get("extraroot", None):
[2506]94 conf.env.AddCustomPackage('extra')
[1130]95 conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
96 if not conf.CheckHeader("Python.h", language='c'):
97 Exit(1)
[1325]98 pylib = 'python'+distutils.sysconfig.get_python_version()
99 if env['PLATFORM'] == "darwin":
100 conf.env.Append(FRAMEWORKS=["Python"])
[1130]101 else:
[1325]102 if not conf.CheckLib(library=pylib, language='c'): Exit(1)
103
104 conf.env.AddCustomPackage('boost')
[2506]105 libname = conf.env["boostlib"]
106 if libname.find(".") > -1 and os.path.exists(libname):
107 conf.env.AppendUnique(LIBS=[env.File(libname)])
108 else:
109 if not conf.CheckLibWithHeader(libname,
110 'boost/python.hpp', language='c++'):
111 Exit(1)
[1501]112
[2503]113 if env["enable_pyrap"]:
114 conf.env.AddCustomPackage('pyrap')
115 if conf.CheckLib(conf.env["pyraplib"], language='c++', autoadd=0):
116 conf.env.PrependUnique(LIBS=env['pyraplib'])
117 else:
118 Exit(1)
[1873]119 else:
120 conf.env.AppendUnique(CPPPATH=[conf.env["numpyincdir"]])
[2503]121 if conf.CheckHeader("numpy/numpyconfig.h"):
[1873]122 conf.env.Append(CPPDEFINES=["-DAIPS_USENUMPY"])
123 else:
124 conf.env.Exit(1)
[2503]125 # compile in pyrap from here...
[1873]126 conf.env["pyrapint"] = "#/external/libpyrap/pyrap-0.3.2"
[2503]127 conf.env.Append(CPPFLAGS=['-DHAVE_LIBPYRAP'])
128
[2517]129 if not conf.CheckLib("m"):
130 Exit(1)
[1325]131 # test for cfitsio
132 conf.env.AddCustomPackage('cfitsio')
[2506]133 libname = conf.env["cfitsiolib"]
[2517]134 if not conf.CheckHeader("fitsio.h"):
135 #SuSE is being special
136 conf.env.AppendUnique(CPPPATH=['/usr/include/libcfitsio0'])
137 if not conf.CheckHeader("fitsio.h"):
138 Exit(1)
[2506]139 if libname.find(".") > -1 and os.path.exists(libname):
140 conf.env.AppendUnique(LIBS=[env.File(libname)])
141 else:
[2517]142 if not conf.CheckLib(libname, language='c'):
[2506]143 Exit(1)
[1325]144 conf.env.AddCustomPackage('wcs')
[2506]145 libname = conf.env["wcslib"]
146 if libname.find(".") > -1 and os.path.exists(libname):
147 conf.env.AppendUnique(LIBS=[env.File(libname)])
148 else:
149 if not conf.CheckLibWithHeader(libname,
150 'wcslib/wcs.h', language='c'):
151 Exit(1)
152
[1325]153 conf.env.AddCustomPackage('rpfits')
[2517]154 if not conf.CheckLibWithHeader(conf.env["rpfitslib"], "RPFITS.h",
155 language="c"):
[1354]156 Exit(1)
[2506]157
158 libpath = ""
[2510]159 for p in [conf.env["casacoreroot"], conf.env.get("extraroot", "")]:
[2506]160 pth = os.path.join(p, "include", "casacore")
161 if os.path.exists(pth):
[2624]162 libpath = os.path.join(p, LIBDIR)
[2506]163 conf.env.AppendUnique(CPPPATH=[pth])
164 break
165 cclibs = ["casa_images", "casa_ms", "casa_components",
166 "casa_coordinates", "casa_lattices",
167 "casa_fits", "casa_measures", "casa_scimath",
[2517]168 "casa_scimath_f", "casa_tables", "casa_casa"]
[2506]169 if conf.env["casacorestatic"]:
[2624]170 libs = [ env.File(os.path.join(libpath, "lib"+lib+".a")) \
[2506]171 for lib in cclibs ]
172 else:
[2624]173 conf.env.AppendUnique(LIBPATH=libpath)
[2506]174 if not conf.CheckLibWithHeader("casa_casa", "casa/aips.h",
175 language='c++', autoadd=0):
176 Exit(1)
177 libs = cclibs
178 conf.env.PrependUnique(LIBS=libs)
[1325]179
[1130]180 if not conf.CheckLib('stdc++', language='c++'): Exit(1)
[1433]181 if conf.env["alma"]:
[2485]182 conf.env.Append(CPPFLAGS=['-DUSE_CASAPY'])
[2525]183 if conf.env.get("extraflags"):
184 flags = conf.env.ParseFlags(conf.env["extraflags"])
185 conf.env.MergeFlags(flags)
[1082]186 env = conf.Finish()
[1120]187
[2503]188opts.Save('options.cache', env)
189
[2942]190env["version"] = "4.3.x"
[1135]191
[1120]192if env['mode'] == 'release':
[1335]193 if env["PLATFORM"] != "darwin":
194 env.Append(LINKFLAGS=['-Wl,-O1', '-s'])
195 env.Append(CCFLAGS=["-O2"])
196else:
[2179]197 env.Append(CCFLAGS=["-g", "-W", "-Wall"])
[1184]198
199# Export for SConscript files
[1135]200Export("env")
[1082]201
[1325]202# build externals
[2503]203ext = env.SConscript("external-alma/SConscript")
204
[1184]205# build library
[2179]206so = env.SConscript("src/SConscript", variant_dir="build", duplicate=0)
[2503]207
208apps = env.SConscript("apps/SConscript")
209
[1195]210# test module import, to see if there are unresolved symbols
211def test_module(target,source,env):
212 pth = str(target[0])
213 mod = os.path.splitext(pth)[0]
214 sys.path.insert(2, os.path.split(mod)[0])
215 __import__(os.path.split(mod)[1])
216 print "ok"
217 return 0
[2503]218
[1195]219def test_str(target, source, env):
220 return "Testing module..."
[1184]221
[1195]222taction = Action(test_module, test_str)
223env.AddPostAction(so, taction)
224
225if env.GetOption("clean"):
226 Execute(Delete(".sconf_temp"))
[2503]227 Execute(Delete("options.cache"))
[2627]228 Execute(Delete(".sconsign.dblite"))
[2166]229if env["makedoc"].lower() != "none":
230 env.SConscript("doc/SConscript")
Note: See TracBrowser for help on using the repository browser.