source: trunk/SConstruct@ 1391

Last change on this file since 1391 was 1377, checked in by mar637, 17 years ago

version change

File size: 8.0 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),
[1120]55 EnumOption("mode", "The type of build.", "debug",
[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",
62 ["none", "pdf", "html"], ignorecase=1)
[1130]63 )
[1082]64
[1135]65env = Environment( toolpath = ['./scons'],
[1325]66 tools = ["default", "archiver", "utils",
[1184]67 "quietinstall"],
[1135]68 ENV = { 'PATH' : os.environ[ 'PATH' ],
[1120]69 'HOME' : os.environ[ 'HOME' ] },
[1135]70 options = opts)
[1082]71
[1120]72Help(opts.GenerateHelpText(env))
73env.SConsignFile()
[1325]74
[1329]75if env["PLATFORM"] == "darwin":
76 env.EnsureSConsVersion(0,96,95)
77
[1325]78casacoretooldir = os.path.join(env["casacoreroot"],"share",
79 "casacore")
80if not os.path.exists(casacoretooldir):
81 print "Could not find casacore scons tools"
82 Exit(1)
83
84# load casacore specific build flags
85env.Tool('casa', [casacoretooldir])
86
[1082]87if not env.GetOption('clean'):
[1130]88 conf = Configure(env)
[1326]89
90 conf.env.AppendUnique(LIBPATH=os.path.join(conf.env["casacoreroot"],
91 "lib"))
92 conf.env.AppendUnique(CPPPATH=os.path.join(conf.env["casacoreroot"],
93 "include", "casacore"))
94 if not conf.CheckLib("casa_casa", language='c++'): Exit(1)
[1354]95 conf.env.PrependUnique(LIBS=["casa_ms", "casa_components",
96 "casa_coordinates", "casa_lattices",
97 "casa_fits", "casa_measures", "casa_scimath",
98 "casa_scimath_f", "casa_tables",
99 "casa_mirlib"])
[1130]100 conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
101 if not conf.CheckHeader("Python.h", language='c'):
102 Exit(1)
[1325]103 pylib = 'python'+distutils.sysconfig.get_python_version()
104 if env['PLATFORM'] == "darwin":
105 conf.env.Append(FRAMEWORKS=["Python"])
[1130]106 else:
[1325]107 if not conf.CheckLib(library=pylib, language='c'): Exit(1)
108
109 conf.env.AddCustomPackage('boost')
110 if not conf.CheckLibWithHeader(env["boostlib"],
111 'boost/python.hpp', language='c++'):
112 Exit(1)
113 # test for cfitsio
114 if not conf.CheckLib("m"): Exit(1)
115 conf.env.AddCustomPackage('cfitsio')
[1327]116 if not conf.CheckLibWithHeader(conf.env["cfitsiolib"],
117 'fitsio.h', language='c'):
[1325]118 Exit(1)
119 conf.env.AddCustomPackage('wcs')
120 if not conf.CheckLibWithHeader('wcs', 'wcslib/wcs.h', language='c'):
121 Exit(1)
122 conf.env.AddCustomPackage('rpfits')
[1354]123 if not conf.CheckLib(conf.env["rpfitslib"], language="c"):
124 Exit(1)
[1325]125
126 # test for blas/lapack
[1331]127 conf.env.AddCustomPackage("lapack")
128 if not conf.CheckLib(conf.env["lapacklib"]): Exit(1)
[1325]129 blasname = conf.env.get("blaslib", "blas")
130 conf.env.AddCustomPackage("blas")
[1327]131 if not conf.CheckLib(conf.env["blaslib"]): Exit(1)
[1325]132 conf.env.CheckFortran(conf)
[1130]133 if not conf.CheckLib('stdc++', language='c++'): Exit(1)
[1082]134 env = conf.Finish()
[1120]135
[1377]136env["version"] = "2.2.x"
[1135]137
[1120]138if env['mode'] == 'release':
[1335]139 if env["PLATFORM"] != "darwin":
140 env.Append(LINKFLAGS=['-Wl,-O1', '-s'])
141 env.Append(CCFLAGS=["-O2"])
142else:
143 env.Append(CCFLAGS=["-g"])
[1184]144
145# Export for SConscript files
[1135]146Export("env")
[1082]147
[1325]148# build externals
149env.SConscript("external/SConscript")
[1184]150# build library
[1082]151so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
[1195]152# test module import, to see if there are unresolved symbols
153def test_module(target,source,env):
154 pth = str(target[0])
155 mod = os.path.splitext(pth)[0]
156 sys.path.insert(2, os.path.split(mod)[0])
157 __import__(os.path.split(mod)[1])
158 print "ok"
159 return 0
160def test_str(target, source, env):
161 return "Testing module..."
[1184]162
[1195]163taction = Action(test_module, test_str)
164env.AddPostAction(so, taction)
165
[1184]166# install targets
167somod = env.Install("$moduledir/asap", so )
168pymods = env.Install("$moduledir/asap", env.SGlob("python/*.py"))
169bins = env.Install("$prefix/bin", ["bin/asap", "bin/asap_update_data"])
[1187]170shares = env.Install("$moduledir/asap/data", "share/ipythonrc-asap")
[1184]171env.Alias('install', [somod, pymods, bins, shares])
172
173# install aips++ data repos
174rootdir=None
175outdir = os.path.join(env["moduledir"],'asap','data')
176sources = ['ephemerides','geodetic']
177if os.path.exists("/nfs/aips++/data"):
178 rootdir = "/nfs/aips++/data"
179elif os.path.exists("data"):
[1195]180 rootdir = "./data"
[1184]181if rootdir is not None:
182 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
183 data = env.InstallAs(ofiles, ifiles)
184 env.Alias('install', data)
[1202]185
[1177]186# make binary distribution
187if len(env["makedist"]):
[1184]188 env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
189 env.Command('Staging distribution for archive in %s' % env["stagedir"],
190 '', env.MessageAction)
[1195]191 st0 = env.QInstall("$stagedir/asap", [so, env.SGlob("python/*.py")] )
[1184]192 env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
[1195]193 env.QInstall("$stagedir", ["bin/install"])
194 env.QInstall("$stagedir/asap/data", "share/ipythonrc-asap")
195 if rootdir is not None:
[1202]196 # This creates a directory Using data table... - disabled
197 #env.Command("Using data tables in %s" % rootdir,
198 # '', env.MessageAction)
[1184]199 outdir = os.path.join(env["stagedir"],'asap','data')
200 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
201 env.QInstallAs(ofiles, ifiles)
[1195]202 else:
203 env.Command("No data tables available. Use 'asap_update_data' after install",
[1202]204 '', env.MessageAction)
[1184]205 arch = env.Archiver(os.path.join("dist",env["stagedir"]),
206 env["stagedir"])
207 env.AddPostAction(arch, Delete("$stagedir"))
[1259]208if env["makedoc"].lower() != "none":
209 env.SConscript("doc/SConscript")
[1195]210
211if env.GetOption("clean"):
212 Execute(Delete(".sconf_temp"))
Note: See TracBrowser for help on using the repository browser.