source: trunk/SConstruct@ 1620

Last change on this file since 1620 was 1557, checked in by Malte Marquarding, 16 years ago

change tag version to trunk

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