source: branches/casa-prerelease/pre-asap/SConstruct@ 2125

Last change on this file since 2125 was 2105, checked in by Takeshi Nakazato, 14 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Merged bug fix on trunk (r2103).


File size: 10.4 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
[1125]24moduledir = distutils.sysconfig.get_python_lib()
[1740]25
26if sys.platform.startswith('linux') and platform.architecture()[0] == '64bit':
[1136]27 # hack to install into /usr/lib64 if scons is in the 32bit /usr/lib/
28 if moduledir.startswith("/usr/lib/"):
[1155]29 moduledir = moduledir.replace("lib", "lib64")
[1082]30
[1464]31EnsureSConsVersion(1,1,0)
32
33opts = Variables("options.cfg")
34opts.AddVariables(
[1325]35 ("FORTRAN", "The fortran compiler", None),
36 ("f2clib", "The fortran to c library", None),
[1464]37 PathVariable("prefix",
[1325]38 "The root installation path",
[1130]39 distutils.sysconfig.PREFIX),
[1464]40 PathVariable("moduledir",
[1120]41 "The python module path (site-packages))",
42 moduledir),
[1464]43 PathVariable("casacoreroot", "The location of casacore",
[1740]44 "/usr/local"),
[1325]45 ("boostroot", "The root dir where boost is installed", None),
46 ("boostlib", "The name of the boost python library",
47 "boost_python"),
48 ("boostlibdir", "The boost library location", None),
49 ("boostincdir", "The boost header file location", None),
50 ("lapackroot",
51 "The root directory where lapack is installed", None),
52 ("lapacklibdir", "The lapack library location", None),
53 ("lapacklib",
54 "The lapack library name (e.g. for specialized AMD libraries",
[1327]55 "lapack"),
[1325]56 ("blasroot",
57 "The root directory where blas is installed", None),
58 ("blaslibdir", "The blas library location", None),
59 ("blaslib",
60 "The blas library name (e.g. for specialized AMD libraries",
[1327]61 "blas"),
[1325]62 ("cfitsioroot",
63 "The root directory where cfistio is installed", None),
64 ("cfitsiolibdir", "The cfitsio library location", None),
[1327]65 ("cfitsiolib", "The cfitsio library name", "cfitsio"),
[1325]66 ("cfitsioincdir", "The cfitsio include location", None),
[1740]67 ("wcslib", "The wcs library name", "wcs"),
[1325]68 ("wcsroot",
69 "The root directory where wcs is installed", None),
70 ("wcslibdir", "The wcs library location", None),
[1354]71 ("rpfitslib", "The rpfits library name", "rpfits"),
[1325]72 ("rpfitsroot",
73 "The root directory where rpfits is installed", None),
74 ("rpfitslibdir", "The rpfits library location", None),
[1501]75 ("pyraproot", "The root directory where libpyrap is installed",
76 None),
[1873]77 ("numpyincdir", "numpy header file directory",
78 get_numpy_incdir()),
[1501]79 ("pyraplib", "The name of the pyrap library", "pyrap"),
80 ("pyraplibdir", "The directory where libpyrap is installed",
81 None),
82 ("pyrapincdir", "The pyrap include location",
83 None),
84 BoolVariable("enable_pyrap", "Use pyrap conversion library",
[1687]85 False),
[1501]86
[1464]87 EnumVariable("mode", "The type of build.", "release",
[1135]88 ["release","debug"], ignorecase=1),
[1177]89 ("makedist",
[1195]90 "Make a binary archive giving a suffix, e.g. sarge or fc5",
[1259]91 ""),
[1464]92 EnumVariable("makedoc", "Build the userguide in specified format",
[1259]93 "none",
[1406]94 ["none", "pdf", "html"], ignorecase=1),
[1740]95 BoolVariable("apps", "Build cpp apps", True),
[1501]96 BoolVariable("alma", "Enable alma specific functionality",
97 False),
[1130]98 )
[1082]99
[1135]100env = Environment( toolpath = ['./scons'],
[1325]101 tools = ["default", "archiver", "utils",
[1184]102 "quietinstall"],
[1135]103 ENV = { 'PATH' : os.environ[ 'PATH' ],
[1120]104 'HOME' : os.environ[ 'HOME' ] },
[1135]105 options = opts)
[1082]106
[1120]107Help(opts.GenerateHelpText(env))
108env.SConsignFile()
[1325]109
110casacoretooldir = os.path.join(env["casacoreroot"],"share",
111 "casacore")
112if not os.path.exists(casacoretooldir):
113 print "Could not find casacore scons tools"
114 Exit(1)
115
116# load casacore specific build flags
[1406]117env.Tool('casaoptions', [casacoretooldir])
118opts.Update(env)
[1325]119env.Tool('casa', [casacoretooldir])
120
[1082]121if not env.GetOption('clean'):
[1130]122 conf = Configure(env)
[1326]123
124 conf.env.AppendUnique(LIBPATH=os.path.join(conf.env["casacoreroot"],
125 "lib"))
126 conf.env.AppendUnique(CPPPATH=os.path.join(conf.env["casacoreroot"],
127 "include", "casacore"))
128 if not conf.CheckLib("casa_casa", language='c++'): Exit(1)
[1443]129 conf.env.PrependUnique(LIBS=["casa_images", "casa_ms", "casa_components",
[1354]130 "casa_coordinates", "casa_lattices",
131 "casa_fits", "casa_measures", "casa_scimath",
132 "casa_scimath_f", "casa_tables",
133 "casa_mirlib"])
[1130]134 conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
135 if not conf.CheckHeader("Python.h", language='c'):
136 Exit(1)
[1325]137 pylib = 'python'+distutils.sysconfig.get_python_version()
138 if env['PLATFORM'] == "darwin":
139 conf.env.Append(FRAMEWORKS=["Python"])
[1130]140 else:
[1325]141 if not conf.CheckLib(library=pylib, language='c'): Exit(1)
142
143 conf.env.AddCustomPackage('boost')
[1501]144 if not conf.CheckLibWithHeader(conf.env["boostlib"],
[1325]145 'boost/python.hpp', language='c++'):
146 Exit(1)
[1501]147
148 conf.env.AddCustomPackage('pyrap')
[1873]149 if conf.CheckLib(conf.env["pyraplib"], language='c++', autoadd=0):
[1902]150 conf.env.Append(CPPFLAGS=['-DHAVE_LIBPYRAP'])
[1501]151 conf.env.PrependUnique(LIBS=env['pyraplib'])
[1873]152 else:
153 conf.env.AppendUnique(CPPPATH=[conf.env["numpyincdir"]])
154 # numpy 1.0 uses config.h; numpy >= 1.1 uses numpyconfig.h
155 if conf.CheckHeader("numpy/config.h") or \
156 conf.CheckHeader("numpy/numpyconfig.h"):
157 conf.env.Append(CPPDEFINES=["-DAIPS_USENUMPY"])
158 else:
159 conf.env.Exit(1)
[1902]160 conf.env.Append(CPPFLAGS=['-DHAVE_LIBPYRAP'])
[1873]161 # compile in pyrap here...
162 conf.env["pyrapint"] = "#/external/libpyrap/pyrap-0.3.2"
[1325]163 # test for cfitsio
164 if not conf.CheckLib("m"): Exit(1)
165 conf.env.AddCustomPackage('cfitsio')
[1327]166 if not conf.CheckLibWithHeader(conf.env["cfitsiolib"],
167 'fitsio.h', language='c'):
[1325]168 Exit(1)
169 conf.env.AddCustomPackage('wcs')
[1740]170 if not conf.CheckLibWithHeader(conf.env["wcslib"],
171 'wcslib/wcs.h', language='c'):
[1325]172 Exit(1)
173 conf.env.AddCustomPackage('rpfits')
[1354]174 if not conf.CheckLib(conf.env["rpfitslib"], language="c"):
175 Exit(1)
[1325]176
177 # test for blas/lapack
[1740]178 lapackname = conf.env.get("lapacklib", "lapack")
[1331]179 conf.env.AddCustomPackage("lapack")
[1740]180 if not conf.CheckLib(lapackname): Exit(1)
[1325]181 blasname = conf.env.get("blaslib", "blas")
182 conf.env.AddCustomPackage("blas")
[1740]183 if not conf.CheckLib(blasname): Exit(1)
[1325]184 conf.env.CheckFortran(conf)
[1130]185 if not conf.CheckLib('stdc++', language='c++'): Exit(1)
[1433]186 if conf.env["alma"]:
187 conf.env.Append(CPPFLAGS=['-DUSE_ALMA'])
[1082]188 env = conf.Finish()
[1120]189
[1819]190env["version"] = "3.0.0"
[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:
[1396]197 env.Append(CCFLAGS=["-g", "-Wall"])
[1184]198
199# Export for SConscript files
[1135]200Export("env")
[1082]201
[1325]202# build externals
[1819]203env.SConscript("external-alma/SConscript")
[1184]204# build library
[1082]205so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
[1195]206# test module import, to see if there are unresolved symbols
207def test_module(target,source,env):
208 pth = str(target[0])
209 mod = os.path.splitext(pth)[0]
210 sys.path.insert(2, os.path.split(mod)[0])
211 __import__(os.path.split(mod)[1])
212 print "ok"
213 return 0
214def test_str(target, source, env):
215 return "Testing module..."
[1184]216
[1195]217taction = Action(test_module, test_str)
218env.AddPostAction(so, taction)
219
[1184]220# install targets
[1740]221installs = []
222installs.append(env.Install("$moduledir/asap", so))
223installs.append(env.Install("$moduledir/asap", env.SGlob("python/*.py")))
224installs.append(env.Install("$prefix/bin",
225 ["bin/asap", "bin/asap_update_data"]))
226installs.append(env.Install("$moduledir/asap/data", "share/ipythonrc-asap"))
227installs.append(env.Install("$moduledir/asap/data", "share/ipy_user_conf.py"))
228env.Alias('install', installs)
[1184]229
230# install aips++ data repos
[1740]231rootdir = None
[1184]232outdir = os.path.join(env["moduledir"],'asap','data')
233sources = ['ephemerides','geodetic']
234if os.path.exists("/nfs/aips++/data"):
235 rootdir = "/nfs/aips++/data"
236elif os.path.exists("data"):
[1195]237 rootdir = "./data"
[1184]238if rootdir is not None:
239 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
240 data = env.InstallAs(ofiles, ifiles)
241 env.Alias('install', data)
[1202]242
[1177]243# make binary distribution
244if len(env["makedist"]):
[1184]245 env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
246 env.Command('Staging distribution for archive in %s' % env["stagedir"],
247 '', env.MessageAction)
[1195]248 st0 = env.QInstall("$stagedir/asap", [so, env.SGlob("python/*.py")] )
[1184]249 env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
[1195]250 env.QInstall("$stagedir", ["bin/install"])
251 env.QInstall("$stagedir/asap/data", "share/ipythonrc-asap")
[1511]252 env.QInstall("$stagedir/asap/data", "share/ipy_user_conf.py")
[1195]253 if rootdir is not None:
[1202]254 # This creates a directory Using data table... - disabled
255 #env.Command("Using data tables in %s" % rootdir,
256 # '', env.MessageAction)
[1184]257 outdir = os.path.join(env["stagedir"],'asap','data')
258 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
259 env.QInstallAs(ofiles, ifiles)
[1195]260 else:
261 env.Command("No data tables available. Use 'asap_update_data' after install",
[1202]262 '', env.MessageAction)
[1184]263 arch = env.Archiver(os.path.join("dist",env["stagedir"]),
264 env["stagedir"])
265 env.AddPostAction(arch, Delete("$stagedir"))
[1259]266if env["makedoc"].lower() != "none":
267 env.SConscript("doc/SConscript")
[1195]268
[1406]269if env["apps"]:
270 env.SConscript("apps/SConscript")
271
[1195]272if env.GetOption("clean"):
273 Execute(Delete(".sconf_temp"))
Note: See TracBrowser for help on using the repository browser.