[1125] | 1 | import os
|
---|
| 2 | import sys
|
---|
[1082] | 3 | import distutils.sysconfig
|
---|
| 4 | import platform
|
---|
[1184] | 5 | import SCons
|
---|
[1082] | 6 |
|
---|
[1873] | 7 | # try to autodetect numpy
|
---|
| 8 | def 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 |
|
---|
[2166] | 24 | EnsureSConsVersion(1,0,0)
|
---|
[1464] | 25 |
|
---|
[2503] | 26 | opts = Variables("options.cache")
|
---|
[1464] | 27 | opts.AddVariables(
|
---|
[1325] | 28 | ("FORTRAN", "The fortran compiler", None),
|
---|
| 29 | ("f2clib", "The fortran to c library", None),
|
---|
[1464] | 30 | PathVariable("casacoreroot", "The location of casacore",
|
---|
[1740] | 31 | "/usr/local"),
|
---|
[1325] | 32 | ("boostroot", "The root dir where boost is installed", None),
|
---|
| 33 | ("boostlib", "The name of the boost python library",
|
---|
| 34 | "boost_python"),
|
---|
| 35 | ("boostlibdir", "The boost library location", None),
|
---|
| 36 | ("boostincdir", "The boost header file location", None),
|
---|
| 37 | ("lapackroot",
|
---|
| 38 | "The root directory where lapack is installed", None),
|
---|
| 39 | ("lapacklibdir", "The lapack library location", None),
|
---|
| 40 | ("lapacklib",
|
---|
| 41 | "The lapack library name (e.g. for specialized AMD libraries",
|
---|
[1327] | 42 | "lapack"),
|
---|
[1325] | 43 | ("blasroot",
|
---|
| 44 | "The root directory where blas is installed", None),
|
---|
| 45 | ("blaslibdir", "The blas library location", None),
|
---|
| 46 | ("blaslib",
|
---|
| 47 | "The blas library name (e.g. for specialized AMD libraries",
|
---|
[1327] | 48 | "blas"),
|
---|
[1325] | 49 | ("cfitsioroot",
|
---|
| 50 | "The root directory where cfistio is installed", None),
|
---|
| 51 | ("cfitsiolibdir", "The cfitsio library location", None),
|
---|
[1327] | 52 | ("cfitsiolib", "The cfitsio library name", "cfitsio"),
|
---|
[1325] | 53 | ("cfitsioincdir", "The cfitsio include location", None),
|
---|
[1740] | 54 | ("wcslib", "The wcs library name", "wcs"),
|
---|
[1325] | 55 | ("wcsroot",
|
---|
| 56 | "The root directory where wcs is installed", None),
|
---|
| 57 | ("wcslibdir", "The wcs library location", None),
|
---|
[1354] | 58 | ("rpfitslib", "The rpfits library name", "rpfits"),
|
---|
[1325] | 59 | ("rpfitsroot",
|
---|
| 60 | "The root directory where rpfits is installed", None),
|
---|
| 61 | ("rpfitslibdir", "The rpfits library location", None),
|
---|
[2503] | 62 |
|
---|
[1501] | 63 | ("pyraproot", "The root directory where libpyrap is installed",
|
---|
| 64 | None),
|
---|
[1873] | 65 | ("numpyincdir", "numpy header file directory",
|
---|
| 66 | get_numpy_incdir()),
|
---|
[2503] | 67 | BoolVariable("enable_pyrap",
|
---|
| 68 | "Use pyrap conversion library from system",
|
---|
| 69 | False),
|
---|
[1501] | 70 | ("pyraplib", "The name of the pyrap library", "pyrap"),
|
---|
| 71 | ("pyraplibdir", "The directory where libpyrap is installed",
|
---|
| 72 | None),
|
---|
| 73 | ("pyrapincdir", "The pyrap include location",
|
---|
| 74 | None),
|
---|
[1464] | 75 | EnumVariable("mode", "The type of build.", "release",
|
---|
[1135] | 76 | ["release","debug"], ignorecase=1),
|
---|
[2503] | 77 | EnumVariable("makedoc",
|
---|
| 78 | "Build the userguide in specified format",
|
---|
| 79 | "none",
|
---|
| 80 | ["none", "pdf", "html"], ignorecase=1),
|
---|
[1740] | 81 | BoolVariable("apps", "Build cpp apps", True),
|
---|
[1501] | 82 | BoolVariable("alma", "Enable alma specific functionality",
|
---|
| 83 | False),
|
---|
[1130] | 84 | )
|
---|
[1082] | 85 |
|
---|
[1135] | 86 | env = Environment( toolpath = ['./scons'],
|
---|
[2503] | 87 | tools = ["default", "utils",
|
---|
| 88 | "casaoptions", "casa"],
|
---|
[1135] | 89 | ENV = { 'PATH' : os.environ[ 'PATH' ],
|
---|
[1120] | 90 | 'HOME' : os.environ[ 'HOME' ] },
|
---|
[1135] | 91 | options = opts)
|
---|
[1082] | 92 |
|
---|
[2503] | 93 | env.Help(opts.GenerateHelpText(env))
|
---|
[1120] | 94 | env.SConsignFile()
|
---|
[2503] | 95 | if not ( env.GetOption('clean') or env.GetOption('help') ):
|
---|
[1325] | 96 |
|
---|
[1130] | 97 | conf = Configure(env)
|
---|
[1326] | 98 |
|
---|
| 99 | conf.env.AppendUnique(LIBPATH=os.path.join(conf.env["casacoreroot"],
|
---|
| 100 | "lib"))
|
---|
| 101 | conf.env.AppendUnique(CPPPATH=os.path.join(conf.env["casacoreroot"],
|
---|
| 102 | "include", "casacore"))
|
---|
| 103 | if not conf.CheckLib("casa_casa", language='c++'): Exit(1)
|
---|
[1443] | 104 | conf.env.PrependUnique(LIBS=["casa_images", "casa_ms", "casa_components",
|
---|
[1354] | 105 | "casa_coordinates", "casa_lattices",
|
---|
| 106 | "casa_fits", "casa_measures", "casa_scimath",
|
---|
| 107 | "casa_scimath_f", "casa_tables",
|
---|
| 108 | "casa_mirlib"])
|
---|
[1130] | 109 | conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
|
---|
| 110 | if not conf.CheckHeader("Python.h", language='c'):
|
---|
| 111 | Exit(1)
|
---|
[1325] | 112 | pylib = 'python'+distutils.sysconfig.get_python_version()
|
---|
| 113 | if env['PLATFORM'] == "darwin":
|
---|
| 114 | conf.env.Append(FRAMEWORKS=["Python"])
|
---|
[1130] | 115 | else:
|
---|
[1325] | 116 | if not conf.CheckLib(library=pylib, language='c'): Exit(1)
|
---|
| 117 |
|
---|
| 118 | conf.env.AddCustomPackage('boost')
|
---|
[1501] | 119 | if not conf.CheckLibWithHeader(conf.env["boostlib"],
|
---|
[1325] | 120 | 'boost/python.hpp', language='c++'):
|
---|
| 121 | Exit(1)
|
---|
[1501] | 122 |
|
---|
[2503] | 123 | if env["enable_pyrap"]:
|
---|
| 124 | conf.env.AddCustomPackage('pyrap')
|
---|
| 125 | if conf.CheckLib(conf.env["pyraplib"], language='c++', autoadd=0):
|
---|
| 126 | conf.env.PrependUnique(LIBS=env['pyraplib'])
|
---|
| 127 | else:
|
---|
| 128 | Exit(1)
|
---|
[1873] | 129 | else:
|
---|
| 130 | conf.env.AppendUnique(CPPPATH=[conf.env["numpyincdir"]])
|
---|
| 131 | # numpy 1.0 uses config.h; numpy >= 1.1 uses numpyconfig.h
|
---|
[2503] | 132 | if conf.CheckHeader("numpy/numpyconfig.h"):
|
---|
[1873] | 133 | conf.env.Append(CPPDEFINES=["-DAIPS_USENUMPY"])
|
---|
| 134 | else:
|
---|
| 135 | conf.env.Exit(1)
|
---|
[2503] | 136 | # compile in pyrap from here...
|
---|
[1873] | 137 | conf.env["pyrapint"] = "#/external/libpyrap/pyrap-0.3.2"
|
---|
[2503] | 138 | conf.env.Append(CPPFLAGS=['-DHAVE_LIBPYRAP'])
|
---|
| 139 |
|
---|
[1325] | 140 | # test for cfitsio
|
---|
| 141 | if not conf.CheckLib("m"): Exit(1)
|
---|
| 142 | conf.env.AddCustomPackage('cfitsio')
|
---|
[1327] | 143 | if not conf.CheckLibWithHeader(conf.env["cfitsiolib"],
|
---|
| 144 | 'fitsio.h', language='c'):
|
---|
[1325] | 145 | Exit(1)
|
---|
| 146 | conf.env.AddCustomPackage('wcs')
|
---|
[1740] | 147 | if not conf.CheckLibWithHeader(conf.env["wcslib"],
|
---|
| 148 | 'wcslib/wcs.h', language='c'):
|
---|
[1325] | 149 | Exit(1)
|
---|
| 150 | conf.env.AddCustomPackage('rpfits')
|
---|
[1354] | 151 | if not conf.CheckLib(conf.env["rpfitslib"], language="c"):
|
---|
| 152 | Exit(1)
|
---|
[1325] | 153 |
|
---|
| 154 | # test for blas/lapack
|
---|
[1740] | 155 | lapackname = conf.env.get("lapacklib", "lapack")
|
---|
[1331] | 156 | conf.env.AddCustomPackage("lapack")
|
---|
[1740] | 157 | if not conf.CheckLib(lapackname): Exit(1)
|
---|
[1325] | 158 | blasname = conf.env.get("blaslib", "blas")
|
---|
| 159 | conf.env.AddCustomPackage("blas")
|
---|
[1740] | 160 | if not conf.CheckLib(blasname): Exit(1)
|
---|
[1325] | 161 | conf.env.CheckFortran(conf)
|
---|
[1130] | 162 | if not conf.CheckLib('stdc++', language='c++'): Exit(1)
|
---|
[1433] | 163 | if conf.env["alma"]:
|
---|
[2485] | 164 | conf.env.Append(CPPFLAGS=['-DUSE_CASAPY'])
|
---|
[1082] | 165 | env = conf.Finish()
|
---|
[1120] | 166 |
|
---|
[2503] | 167 | opts.Save('options.cache', env)
|
---|
| 168 |
|
---|
[2485] | 169 | env["version"] = "4.1.x"
|
---|
[1135] | 170 |
|
---|
[1120] | 171 | if env['mode'] == 'release':
|
---|
[1335] | 172 | if env["PLATFORM"] != "darwin":
|
---|
| 173 | env.Append(LINKFLAGS=['-Wl,-O1', '-s'])
|
---|
| 174 | env.Append(CCFLAGS=["-O2"])
|
---|
| 175 | else:
|
---|
[2179] | 176 | env.Append(CCFLAGS=["-g", "-W", "-Wall"])
|
---|
[1184] | 177 |
|
---|
| 178 | # Export for SConscript files
|
---|
[1135] | 179 | Export("env")
|
---|
[1082] | 180 |
|
---|
[1325] | 181 | # build externals
|
---|
[2503] | 182 | ext = env.SConscript("external-alma/SConscript")
|
---|
| 183 |
|
---|
[1184] | 184 | # build library
|
---|
[2179] | 185 | so = env.SConscript("src/SConscript", variant_dir="build", duplicate=0)
|
---|
[2503] | 186 |
|
---|
| 187 | apps = env.SConscript("apps/SConscript")
|
---|
| 188 |
|
---|
[1195] | 189 | # test module import, to see if there are unresolved symbols
|
---|
| 190 | def test_module(target,source,env):
|
---|
| 191 | pth = str(target[0])
|
---|
| 192 | mod = os.path.splitext(pth)[0]
|
---|
| 193 | sys.path.insert(2, os.path.split(mod)[0])
|
---|
| 194 | __import__(os.path.split(mod)[1])
|
---|
| 195 | print "ok"
|
---|
| 196 | return 0
|
---|
[2503] | 197 |
|
---|
[1195] | 198 | def test_str(target, source, env):
|
---|
| 199 | return "Testing module..."
|
---|
[1184] | 200 |
|
---|
[1195] | 201 | taction = Action(test_module, test_str)
|
---|
| 202 | env.AddPostAction(so, taction)
|
---|
| 203 |
|
---|
| 204 | if env.GetOption("clean"):
|
---|
| 205 | Execute(Delete(".sconf_temp"))
|
---|
[2503] | 206 | Execute(Delete("options.cache"))
|
---|
[2166] | 207 |
|
---|
| 208 | if env["makedoc"].lower() != "none":
|
---|
| 209 | env.SConscript("doc/SConscript")
|
---|