source: trunk/SConstruct@ 2495

Last change on this file since 2495 was 2487, checked in by Malte Marquarding, 13 years ago

make makedist work by adding back in a dummy install target

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