[1125] | 1 | import os
|
---|
| 2 | import sys
|
---|
[1082] | 3 | import distutils.sysconfig
|
---|
| 4 | import platform
|
---|
[1184] | 5 | import SCons
|
---|
[1125] | 6 | # scons plug-ins
|
---|
[1130] | 7 | #from installtree import InstallTree
|
---|
[1082] | 8 |
|
---|
[1125] | 9 | moduledir = distutils.sysconfig.get_python_lib()
|
---|
[1136] | 10 | if platform.architecture()[0] == '64bit':
|
---|
| 11 | # hack to install into /usr/lib64 if scons is in the 32bit /usr/lib/
|
---|
| 12 | if moduledir.startswith("/usr/lib/"):
|
---|
[1155] | 13 | moduledir = moduledir.replace("lib", "lib64")
|
---|
[1082] | 14 |
|
---|
[1120] | 15 | opts = Options("userconfig.py")
|
---|
[1130] | 16 | opts.AddOptions(PathOption("prefix",
|
---|
| 17 | "The root installation path",
|
---|
| 18 | distutils.sysconfig.PREFIX),
|
---|
[1120] | 19 | PathOption("moduledir",
|
---|
| 20 | "The python module path (site-packages))",
|
---|
| 21 | moduledir),
|
---|
[1130] | 22 | ("rpfitsdir", "Alternative rpfits location.", ""),
|
---|
[1138] | 23 | ("cfitsioincdir", "Alternative cfitsio include dir", ""),
|
---|
[1135] | 24 | ("casadir", "Alternative casa location", ""),
|
---|
[1120] | 25 | EnumOption("mode", "The type of build.", "debug",
|
---|
[1135] | 26 | ["release","debug"], ignorecase=1),
|
---|
[1177] | 27 | ("makedist",
|
---|
| 28 | "Make a binary distribution giving a suffix, e.g. sarge or fc5",
|
---|
| 29 | "")
|
---|
[1130] | 30 | )
|
---|
[1082] | 31 |
|
---|
[1135] | 32 | env = Environment( toolpath = ['./scons'],
|
---|
[1184] | 33 | tools = ["default", "casa", "archiver", "utils",
|
---|
| 34 | "quietinstall"],
|
---|
[1135] | 35 | ENV = { 'PATH' : os.environ[ 'PATH' ],
|
---|
[1120] | 36 | 'HOME' : os.environ[ 'HOME' ] },
|
---|
[1135] | 37 | options = opts)
|
---|
[1082] | 38 |
|
---|
[1120] | 39 | Help(opts.GenerateHelpText(env))
|
---|
| 40 | env.SConsignFile()
|
---|
[1135] | 41 | env.Append(CASAARCH = '', CASAROOT = '')
|
---|
[1138] | 42 | if (os.path.exists(env["cfitsioincdir"])):
|
---|
| 43 | env.Append(CPPPATH=[env["cfitsioincdir"]])
|
---|
| 44 | env.AddCustomPath(env["rpfitsdir"])
|
---|
[1082] | 45 | if not env.GetOption('clean'):
|
---|
[1130] | 46 | conf = Configure(env)
|
---|
| 47 | # import Custom tests
|
---|
[1135] | 48 | env.AddCasaTest(conf)
|
---|
[1130] | 49 | pylib = 'python'+distutils.sysconfig.get_python_version()
|
---|
| 50 | pyinc = "Python.h"
|
---|
| 51 | if env['PLATFORM'] == "darwin":
|
---|
| 52 | pylib = "Python"
|
---|
| 53 | if not conf.CheckLib(library=pylib, language='c'): Exit(1)
|
---|
| 54 | conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
|
---|
| 55 | if not conf.CheckHeader("Python.h", language='c'):
|
---|
| 56 | Exit(1)
|
---|
| 57 | if not conf.CheckLibWithHeader('boost_python', 'boost/python.hpp', 'c++'): Exit(1)
|
---|
| 58 | conf.env.AddCustomPath(env["rpfitsdir"])
|
---|
[1090] | 59 | if not conf.CheckLib('rpfits'): Exit(1)
|
---|
[1138] | 60 | # cfitsio is either in include/ or /include/cfitsio
|
---|
| 61 | # handle this
|
---|
| 62 | if not conf.CheckLib(library='cfitsio', language='c'): Exit(1)
|
---|
| 63 | if not conf.CheckHeader('fitsio.h', language='c'):
|
---|
| 64 | if not conf.CheckHeader('cfitsio/fitsio.h', language='c'):
|
---|
| 65 | Exit(1)
|
---|
| 66 | else:
|
---|
| 67 | conf.env.Append(CPPPATH=['/usr/include/cfitsio'])
|
---|
[1130] | 68 | if (sys.platform == "darwin"):
|
---|
| 69 | conf.env.Append(LIBS = ['-framework vecLib'])
|
---|
| 70 | else:
|
---|
| 71 | if not conf.CheckLib('lapack'): Exit(1)
|
---|
| 72 | if not conf.CheckLib('blas'): Exit(1)
|
---|
[1105] | 73 | if not conf.CheckLib('g2c'): Exit(1)
|
---|
[1130] | 74 | if not conf.CheckLib('stdc++', language='c++'): Exit(1)
|
---|
[1127] | 75 | if not conf.CheckCasa(env["casadir"]): Exit(1)
|
---|
[1082] | 76 | env = conf.Finish()
|
---|
[1120] | 77 |
|
---|
[1184] | 78 | env["version"] = "2.1.0b"
|
---|
[1135] | 79 |
|
---|
[1090] | 80 | # general CPPFLAGS
|
---|
[1135] | 81 | env.Append(CPPFLAGS=['-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-O3'])
|
---|
[1136] | 82 |
|
---|
[1090] | 83 | # 64bit flags
|
---|
[1082] | 84 | if platform.architecture()[0] == '64bit':
|
---|
[1135] | 85 | env.Append(CPPFLAGS=['-fPIC', '-D__x86_64__', '-DAIPS_64B'])
|
---|
[1136] | 86 |
|
---|
[1120] | 87 | if env['mode'] == 'release':
|
---|
| 88 | env.Append(LINKFLAGS=['-Wl,-O1'])
|
---|
[1184] | 89 |
|
---|
| 90 | # Export for SConscript files
|
---|
[1135] | 91 | Export("env")
|
---|
[1082] | 92 |
|
---|
[1184] | 93 | # build library
|
---|
[1082] | 94 | so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
|
---|
[1184] | 95 |
|
---|
| 96 | # install targets
|
---|
| 97 | somod = env.Install("$moduledir/asap", so )
|
---|
| 98 | pymods = env.Install("$moduledir/asap", env.SGlob("python/*.py"))
|
---|
| 99 | bins = env.Install("$prefix/bin", ["bin/asap", "bin/asap_update_data"])
|
---|
[1187] | 100 | shares = env.Install("$moduledir/asap/data", "share/ipythonrc-asap")
|
---|
[1184] | 101 | env.Alias('install', [somod, pymods, bins, shares])
|
---|
| 102 |
|
---|
| 103 | # install aips++ data repos
|
---|
| 104 | rootdir=None
|
---|
| 105 | outdir = os.path.join(env["moduledir"],'asap','data')
|
---|
| 106 | sources = ['ephemerides','geodetic']
|
---|
| 107 | if os.path.exists("/nfs/aips++/data"):
|
---|
| 108 | rootdir = "/nfs/aips++/data"
|
---|
| 109 | elif os.path.exists("data"):
|
---|
| 110 | rootdir = "data"
|
---|
| 111 | if rootdir is not None:
|
---|
| 112 | ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
|
---|
| 113 | data = env.InstallAs(ofiles, ifiles)
|
---|
| 114 | env.Alias('install', data)
|
---|
| 115 |
|
---|
[1177] | 116 | # make binary distribution
|
---|
| 117 | if len(env["makedist"]):
|
---|
[1184] | 118 | env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
|
---|
| 119 | env.Command('Staging distribution for archive in %s' % env["stagedir"],
|
---|
| 120 | '', env.MessageAction)
|
---|
[1186] | 121 | env.QInstall("$stagedir/asap", [so, env.SGlob("python/*.py")] )
|
---|
[1184] | 122 | env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
|
---|
| 123 | env.QInstall("$stagedir/install", ["bin/install"])
|
---|
| 124 | env.QInstall("$stagedir/data", "share/ipythonrc-asap")
|
---|
| 125 | if os.path.exists("/nfs/aips++/data"):
|
---|
| 126 | rootdir = "/nfs/aips++/data"
|
---|
| 127 | sources = ['ephemerides','geodetic']
|
---|
| 128 | outdir = os.path.join(env["stagedir"],'asap','data')
|
---|
| 129 | ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
|
---|
| 130 | env.QInstallAs(ofiles, ifiles)
|
---|
| 131 | arch = env.Archiver(os.path.join("dist",env["stagedir"]),
|
---|
| 132 | env["stagedir"])
|
---|
| 133 | env.AddPostAction(arch, Delete("$stagedir"))
|
---|
| 134 |
|
---|