source: trunk/SConstruct@ 1410

Last change on this file since 1410 was 1406, checked in by Malte Marquarding, 17 years ago

work with the latest version of casacore; made release mode default. Add optional build of apps.

File size: 8.2 KB
RevLine 
[1125]1import os
2import sys
[1082]3import distutils.sysconfig
4import platform
[1184]5import SCons
[1082]6
[1125]7moduledir = distutils.sysconfig.get_python_lib()
[1136]8if platform.architecture()[0] == '64bit':
9 # hack to install into /usr/lib64 if scons is in the 32bit /usr/lib/
10 if moduledir.startswith("/usr/lib/"):
[1155]11 moduledir = moduledir.replace("lib", "lib64")
[1082]12
[1335]13opts = Options("options.cfg")
14opts.AddOptions(
[1325]15 ("FORTRAN", "The fortran compiler", None),
16 ("f2clib", "The fortran to c library", None),
17 PathOption("prefix",
18 "The root installation path",
[1130]19 distutils.sysconfig.PREFIX),
[1120]20 PathOption("moduledir",
21 "The python module path (site-packages))",
22 moduledir),
[1325]23 PathOption("casacoreroot", "The location of casacore",
24 "/usr/local"),
25 ("boostroot", "The root dir where boost is installed", None),
26 ("boostlib", "The name of the boost python library",
27 "boost_python"),
28 ("boostlibdir", "The boost library location", None),
29 ("boostincdir", "The boost header file location", None),
30 ("lapackroot",
31 "The root directory where lapack is installed", None),
32 ("lapacklibdir", "The lapack library location", None),
33 ("lapacklib",
34 "The lapack library name (e.g. for specialized AMD libraries",
[1327]35 "lapack"),
[1325]36 ("blasroot",
37 "The root directory where blas is installed", None),
38 ("blaslibdir", "The blas library location", None),
39 ("blaslib",
40 "The blas library name (e.g. for specialized AMD libraries",
[1327]41 "blas"),
[1325]42 ("cfitsioroot",
43 "The root directory where cfistio is installed", None),
44 ("cfitsiolibdir", "The cfitsio library location", None),
[1327]45 ("cfitsiolib", "The cfitsio library name", "cfitsio"),
[1325]46 ("cfitsioincdir", "The cfitsio include location", None),
47 ("wcsroot",
48 "The root directory where wcs is installed", None),
49 ("wcslibdir", "The wcs library location", None),
[1354]50 ("rpfitslib", "The rpfits library name", "rpfits"),
[1325]51 ("rpfitsroot",
52 "The root directory where rpfits is installed", None),
53 ("rpfitslibdir", "The rpfits library location", None),
[1354]54# ("rpfitsincdir", "The rpfits include location", None),
[1406]55 EnumOption("mode", "The type of build.", "release",
[1135]56 ["release","debug"], ignorecase=1),
[1177]57 ("makedist",
[1195]58 "Make a binary archive giving a suffix, e.g. sarge or fc5",
[1259]59 ""),
60 EnumOption("makedoc", "Build the userguide in specified format",
61 "none",
[1406]62 ["none", "pdf", "html"], ignorecase=1),
63 BoolOption("apps", "Build cpp apps", False)
[1130]64 )
[1082]65
[1135]66env = Environment( toolpath = ['./scons'],
[1325]67 tools = ["default", "archiver", "utils",
[1184]68 "quietinstall"],
[1135]69 ENV = { 'PATH' : os.environ[ 'PATH' ],
[1120]70 'HOME' : os.environ[ 'HOME' ] },
[1135]71 options = opts)
[1082]72
[1120]73Help(opts.GenerateHelpText(env))
74env.SConsignFile()
[1325]75
[1329]76if env["PLATFORM"] == "darwin":
77 env.EnsureSConsVersion(0,96,95)
78
[1325]79casacoretooldir = os.path.join(env["casacoreroot"],"share",
80 "casacore")
81if not os.path.exists(casacoretooldir):
82 print "Could not find casacore scons tools"
83 Exit(1)
84
85# load casacore specific build flags
[1406]86env.Tool('casaoptions', [casacoretooldir])
87env.AddCommonOptions(opts)
88opts.Update(env)
[1325]89env.Tool('casa', [casacoretooldir])
90
[1082]91if not env.GetOption('clean'):
[1130]92 conf = Configure(env)
[1326]93
94 conf.env.AppendUnique(LIBPATH=os.path.join(conf.env["casacoreroot"],
95 "lib"))
96 conf.env.AppendUnique(CPPPATH=os.path.join(conf.env["casacoreroot"],
97 "include", "casacore"))
98 if not conf.CheckLib("casa_casa", language='c++'): Exit(1)
[1354]99 conf.env.PrependUnique(LIBS=["casa_ms", "casa_components",
100 "casa_coordinates", "casa_lattices",
101 "casa_fits", "casa_measures", "casa_scimath",
102 "casa_scimath_f", "casa_tables",
103 "casa_mirlib"])
[1130]104 conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
105 if not conf.CheckHeader("Python.h", language='c'):
106 Exit(1)
[1325]107 pylib = 'python'+distutils.sysconfig.get_python_version()
108 if env['PLATFORM'] == "darwin":
109 conf.env.Append(FRAMEWORKS=["Python"])
[1130]110 else:
[1325]111 if not conf.CheckLib(library=pylib, language='c'): Exit(1)
112
113 conf.env.AddCustomPackage('boost')
114 if not conf.CheckLibWithHeader(env["boostlib"],
115 'boost/python.hpp', language='c++'):
116 Exit(1)
117 # test for cfitsio
118 if not conf.CheckLib("m"): Exit(1)
119 conf.env.AddCustomPackage('cfitsio')
[1327]120 if not conf.CheckLibWithHeader(conf.env["cfitsiolib"],
121 'fitsio.h', language='c'):
[1325]122 Exit(1)
123 conf.env.AddCustomPackage('wcs')
124 if not conf.CheckLibWithHeader('wcs', 'wcslib/wcs.h', language='c'):
125 Exit(1)
126 conf.env.AddCustomPackage('rpfits')
[1354]127 if not conf.CheckLib(conf.env["rpfitslib"], language="c"):
128 Exit(1)
[1325]129
130 # test for blas/lapack
[1331]131 conf.env.AddCustomPackage("lapack")
132 if not conf.CheckLib(conf.env["lapacklib"]): Exit(1)
[1325]133 blasname = conf.env.get("blaslib", "blas")
134 conf.env.AddCustomPackage("blas")
[1327]135 if not conf.CheckLib(conf.env["blaslib"]): Exit(1)
[1325]136 conf.env.CheckFortran(conf)
[1130]137 if not conf.CheckLib('stdc++', language='c++'): Exit(1)
[1082]138 env = conf.Finish()
[1120]139
[1377]140env["version"] = "2.2.x"
[1135]141
[1120]142if env['mode'] == 'release':
[1335]143 if env["PLATFORM"] != "darwin":
144 env.Append(LINKFLAGS=['-Wl,-O1', '-s'])
145 env.Append(CCFLAGS=["-O2"])
146else:
[1396]147 env.Append(CCFLAGS=["-g", "-Wall"])
[1184]148
149# Export for SConscript files
[1135]150Export("env")
[1082]151
[1325]152# build externals
153env.SConscript("external/SConscript")
[1184]154# build library
[1082]155so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
[1195]156# test module import, to see if there are unresolved symbols
157def test_module(target,source,env):
158 pth = str(target[0])
159 mod = os.path.splitext(pth)[0]
160 sys.path.insert(2, os.path.split(mod)[0])
161 __import__(os.path.split(mod)[1])
162 print "ok"
163 return 0
164def test_str(target, source, env):
165 return "Testing module..."
[1184]166
[1195]167taction = Action(test_module, test_str)
168env.AddPostAction(so, taction)
169
[1184]170# install targets
171somod = env.Install("$moduledir/asap", so )
172pymods = env.Install("$moduledir/asap", env.SGlob("python/*.py"))
173bins = env.Install("$prefix/bin", ["bin/asap", "bin/asap_update_data"])
[1187]174shares = env.Install("$moduledir/asap/data", "share/ipythonrc-asap")
[1184]175env.Alias('install', [somod, pymods, bins, shares])
176
177# install aips++ data repos
178rootdir=None
179outdir = os.path.join(env["moduledir"],'asap','data')
180sources = ['ephemerides','geodetic']
181if os.path.exists("/nfs/aips++/data"):
182 rootdir = "/nfs/aips++/data"
183elif os.path.exists("data"):
[1195]184 rootdir = "./data"
[1184]185if rootdir is not None:
186 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
187 data = env.InstallAs(ofiles, ifiles)
188 env.Alias('install', data)
[1202]189
[1177]190# make binary distribution
191if len(env["makedist"]):
[1184]192 env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
193 env.Command('Staging distribution for archive in %s' % env["stagedir"],
194 '', env.MessageAction)
[1195]195 st0 = env.QInstall("$stagedir/asap", [so, env.SGlob("python/*.py")] )
[1184]196 env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
[1195]197 env.QInstall("$stagedir", ["bin/install"])
198 env.QInstall("$stagedir/asap/data", "share/ipythonrc-asap")
199 if rootdir is not None:
[1202]200 # This creates a directory Using data table... - disabled
201 #env.Command("Using data tables in %s" % rootdir,
202 # '', env.MessageAction)
[1184]203 outdir = os.path.join(env["stagedir"],'asap','data')
204 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
205 env.QInstallAs(ofiles, ifiles)
[1195]206 else:
207 env.Command("No data tables available. Use 'asap_update_data' after install",
[1202]208 '', env.MessageAction)
[1184]209 arch = env.Archiver(os.path.join("dist",env["stagedir"]),
210 env["stagedir"])
211 env.AddPostAction(arch, Delete("$stagedir"))
[1259]212if env["makedoc"].lower() != "none":
213 env.SConscript("doc/SConscript")
[1195]214
[1406]215if env["apps"]:
216 env.SConscript("apps/SConscript")
217
[1195]218if env.GetOption("clean"):
219 Execute(Delete(".sconf_temp"))
Note: See TracBrowser for help on using the repository browser.