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