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