[1125] | 1 | import os |
---|
| 2 | import sys |
---|
[1082] | 3 | import distutils.sysconfig |
---|
| 4 | import platform |
---|
[1125] | 5 | # scons plug-ins |
---|
[1130] | 6 | #from installtree import InstallTree |
---|
[1082] | 7 | |
---|
[1125] | 8 | moduledir = distutils.sysconfig.get_python_lib() |
---|
[1136] | 9 | if platform.architecture()[0] == '64bit': |
---|
| 10 | # hack to install into /usr/lib64 if scons is in the 32bit /usr/lib/ |
---|
| 11 | if moduledir.startswith("/usr/lib/"): |
---|
| 12 | moduledir.replace("lib", "lib64") |
---|
[1082] | 13 | |
---|
[1120] | 14 | opts = Options("userconfig.py") |
---|
[1130] | 15 | opts.AddOptions(PathOption("prefix", |
---|
| 16 | "The root installation path", |
---|
| 17 | distutils.sysconfig.PREFIX), |
---|
[1120] | 18 | PathOption("moduledir", |
---|
| 19 | "The python module path (site-packages))", |
---|
| 20 | moduledir), |
---|
[1130] | 21 | ("rpfitsdir", "Alternative rpfits location.", ""), |
---|
[1135] | 22 | ("casadir", "Alternative casa location", ""), |
---|
[1120] | 23 | EnumOption("mode", "The type of build.", "debug", |
---|
[1135] | 24 | ["release","debug"], ignorecase=1), |
---|
| 25 | BoolOption("staticlink", |
---|
| 26 | "Should extrenal libs be linked in statically", |
---|
| 27 | False) |
---|
[1130] | 28 | ) |
---|
[1082] | 29 | |
---|
[1135] | 30 | env = Environment( toolpath = ['./scons'], |
---|
| 31 | tools = ["default", "disttar", "installtree", "casa", |
---|
| 32 | "utils"], |
---|
| 33 | ENV = { 'PATH' : os.environ[ 'PATH' ], |
---|
[1120] | 34 | 'HOME' : os.environ[ 'HOME' ] }, |
---|
[1135] | 35 | options = opts) |
---|
[1082] | 36 | |
---|
[1120] | 37 | Help(opts.GenerateHelpText(env)) |
---|
| 38 | env.SConsignFile() |
---|
[1135] | 39 | env.Append(CASAARCH = '', CASAROOT = '') |
---|
[1130] | 40 | |
---|
[1082] | 41 | if not env.GetOption('clean'): |
---|
[1130] | 42 | conf = Configure(env) |
---|
| 43 | # import Custom tests |
---|
[1135] | 44 | env.AddCasaTest(conf) |
---|
[1130] | 45 | pylib = 'python'+distutils.sysconfig.get_python_version() |
---|
| 46 | pyinc = "Python.h" |
---|
| 47 | if env['PLATFORM'] == "darwin": |
---|
| 48 | pylib = "Python" |
---|
| 49 | if not conf.CheckLib(library=pylib, language='c'): Exit(1) |
---|
| 50 | conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()]) |
---|
| 51 | if not conf.CheckHeader("Python.h", language='c'): |
---|
| 52 | Exit(1) |
---|
| 53 | if not conf.CheckLibWithHeader('boost_python', 'boost/python.hpp', 'c++'): Exit(1) |
---|
| 54 | conf.env.AddCustomPath(env["rpfitsdir"]) |
---|
[1090] | 55 | if not conf.CheckLib('rpfits'): Exit(1) |
---|
[1130] | 56 | if not conf.CheckLibWithHeader('cfitsio', 'fitsio.h', 'c'): Exit(1) |
---|
| 57 | if (sys.platform == "darwin"): |
---|
| 58 | conf.env.Append(LIBS = ['-framework vecLib']) |
---|
| 59 | else: |
---|
| 60 | if not conf.CheckLib('lapack'): Exit(1) |
---|
| 61 | if not conf.CheckLib('blas'): Exit(1) |
---|
[1105] | 62 | if not conf.CheckLib('g2c'): Exit(1) |
---|
[1130] | 63 | if not conf.CheckLib('stdc++', language='c++'): Exit(1) |
---|
[1127] | 64 | if not conf.CheckCasa(env["casadir"]): Exit(1) |
---|
[1082] | 65 | env = conf.Finish() |
---|
[1120] | 66 | |
---|
[1135] | 67 | env["stage_dir"] = Dir("#/stage/asap") |
---|
| 68 | |
---|
[1090] | 69 | # general CPPFLAGS |
---|
[1135] | 70 | env.Append(CPPFLAGS=['-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-O3']) |
---|
[1136] | 71 | |
---|
[1090] | 72 | # 64bit flags |
---|
[1082] | 73 | if platform.architecture()[0] == '64bit': |
---|
[1135] | 74 | env.Append(CPPFLAGS=['-fPIC', '-D__x86_64__', '-DAIPS_64B']) |
---|
[1136] | 75 | |
---|
[1135] | 76 | if env["PLATFORM"] == "darwin": |
---|
| 77 | env['SHLINKFLAGS'] = '$LINKFLAGS -bundle' |
---|
| 78 | #env['SHLIBSUFFIX'] = '.dylib' |
---|
[1130] | 79 | |
---|
[1120] | 80 | if env['mode'] == 'release': |
---|
| 81 | env.Append(LINKFLAGS=['-Wl,-O1']) |
---|
[1135] | 82 | Export("env") |
---|
[1082] | 83 | |
---|
| 84 | so = env.SConscript("src/SConscript", build_dir="build", duplicate=0) |
---|
[1135] | 85 | env.Install(env["stage_dir"], so ) |
---|
[1120] | 86 | |
---|
| 87 | pys = env.SConscript("python/SConscript") |
---|
[1130] | 88 | asapmod = env.InstallTree(dest_dir = os.path.join(env["moduledir"], "asap"), |
---|
[1135] | 89 | src_dir = "stage/asap", |
---|
| 90 | includes = ['*.py', '*.so'], |
---|
| 91 | excludes = []) |
---|
[1130] | 92 | asapbin = env.Install(os.path.join(env["prefix"], "bin"), "bin/asap") |
---|
[1127] | 93 | env.Alias('install', [asapmod, asapbin]) |
---|