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