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