source: branches/alma/SConstruct@ 1556

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

version change

File size: 8.0 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
13opts = Options("options.cfg")
14opts.AddOptions(
15 ("FORTRAN", "The fortran compiler", None),
16 ("f2clib", "The fortran to c library", None),
17 PathOption("prefix",
18 "The root installation path",
19 distutils.sysconfig.PREFIX),
20 PathOption("moduledir",
21 "The python module path (site-packages))",
22 moduledir),
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",
35 "lapack"),
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",
41 "blas"),
42 ("cfitsioroot",
43 "The root directory where cfistio is installed", None),
44 ("cfitsiolibdir", "The cfitsio library location", None),
45 ("cfitsiolib", "The cfitsio library name", "cfitsio"),
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),
50 ("rpfitslib", "The rpfits library name", "rpfits"),
51 ("rpfitsroot",
52 "The root directory where rpfits is installed", None),
53 ("rpfitslibdir", "The rpfits library location", None),
54# ("rpfitsincdir", "The rpfits include location", None),
55 EnumOption("mode", "The type of build.", "debug",
56 ["release","debug"], ignorecase=1),
57 ("makedist",
58 "Make a binary archive giving a suffix, e.g. sarge or fc5",
59 ""),
60 EnumOption("makedoc", "Build the userguide in specified format",
61 "none",
62 ["none", "pdf", "html"], ignorecase=1)
63 )
64
65env = Environment( toolpath = ['./scons'],
66 tools = ["default", "archiver", "utils",
67 "quietinstall"],
68 ENV = { 'PATH' : os.environ[ 'PATH' ],
69 'HOME' : os.environ[ 'HOME' ] },
70 options = opts)
71
72Help(opts.GenerateHelpText(env))
73env.SConsignFile()
74
75if env["PLATFORM"] == "darwin":
76 env.EnsureSConsVersion(0,96,95)
77
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
87if not env.GetOption('clean'):
88 conf = Configure(env)
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)
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"])
100 conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
101 if not conf.CheckHeader("Python.h", language='c'):
102 Exit(1)
103 pylib = 'python'+distutils.sysconfig.get_python_version()
104 if env['PLATFORM'] == "darwin":
105 conf.env.Append(FRAMEWORKS=["Python"])
106 else:
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')
116 if not conf.CheckLibWithHeader(conf.env["cfitsiolib"],
117 'fitsio.h', language='c'):
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')
123 if not conf.CheckLib(conf.env["rpfitslib"], language="c"):
124 Exit(1)
125
126 # test for blas/lapack
127 conf.env.AddCustomPackage("lapack")
128 if not conf.CheckLib(conf.env["lapacklib"]): Exit(1)
129 blasname = conf.env.get("blaslib", "blas")
130 conf.env.AddCustomPackage("blas")
131 if not conf.CheckLib(conf.env["blaslib"]): Exit(1)
132 conf.env.CheckFortran(conf)
133 if not conf.CheckLib('stdc++', language='c++'): Exit(1)
134 env = conf.Finish()
135
136env["version"] = "2.2.x"
137
138if env['mode'] == 'release':
139 if env["PLATFORM"] != "darwin":
140 env.Append(LINKFLAGS=['-Wl,-O1', '-s'])
141 env.Append(CCFLAGS=["-O2"])
142else:
143 env.Append(CCFLAGS=["-g"])
144
145# Export for SConscript files
146Export("env")
147
148# build externals
149env.SConscript("external/SConscript")
150# build library
151so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
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..."
162
163taction = Action(test_module, test_str)
164env.AddPostAction(so, taction)
165
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"])
170shares = env.Install("$moduledir/asap/data", "share/ipythonrc-asap")
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"):
180 rootdir = "./data"
181if rootdir is not None:
182 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
183 data = env.InstallAs(ofiles, ifiles)
184 env.Alias('install', data)
185
186# make binary distribution
187if len(env["makedist"]):
188 env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
189 env.Command('Staging distribution for archive in %s' % env["stagedir"],
190 '', env.MessageAction)
191 st0 = env.QInstall("$stagedir/asap", [so, env.SGlob("python/*.py")] )
192 env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
193 env.QInstall("$stagedir", ["bin/install"])
194 env.QInstall("$stagedir/asap/data", "share/ipythonrc-asap")
195 if rootdir is not None:
196 # This creates a directory Using data table... - disabled
197 #env.Command("Using data tables in %s" % rootdir,
198 # '', env.MessageAction)
199 outdir = os.path.join(env["stagedir"],'asap','data')
200 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
201 env.QInstallAs(ofiles, ifiles)
202 else:
203 env.Command("No data tables available. Use 'asap_update_data' after install",
204 '', env.MessageAction)
205 arch = env.Archiver(os.path.join("dist",env["stagedir"]),
206 env["stagedir"])
207 env.AddPostAction(arch, Delete("$stagedir"))
208if env["makedoc"].lower() != "none":
209 env.SConscript("doc/SConscript")
210
211if env.GetOption("clean"):
212 Execute(Delete(".sconf_temp"))
Note: See TracBrowser for help on using the repository browser.