[1125] | 1 | import os
|
---|
| 2 | import sys
|
---|
| 3 | import glob
|
---|
[1082] | 4 | import distutils.sysconfig
|
---|
| 5 | import platform
|
---|
[1125] | 6 | # scons plug-ins
|
---|
[1120] | 7 | sys.path.append("scons")
|
---|
| 8 | from casa import checkCasa
|
---|
[1125] | 9 | from installtree import InstallTree
|
---|
[1082] | 10 |
|
---|
[1125] | 11 | moduledir = distutils.sysconfig.get_python_lib()
|
---|
[1082] | 12 |
|
---|
[1120] | 13 | opts = Options("userconfig.py")
|
---|
| 14 | opts.AddOptions(PathOption("prefix", "The root installation path",
|
---|
| 15 | distutils.sysconfig.PREFIX),
|
---|
| 16 | PathOption("moduledir",
|
---|
| 17 | "The python module path (site-packages))",
|
---|
| 18 | moduledir),
|
---|
| 19 | EnumOption("mode", "The type of build.", "debug",
|
---|
| 20 | ["release","debug"], ignorecase=1))
|
---|
[1082] | 21 |
|
---|
[1105] | 22 | def SGlob(pattern):
|
---|
| 23 | path = GetBuildPath('SConscript').replace('SConscript', '')
|
---|
| 24 | return [ i.replace(path, '') for i in glob.glob(path + pattern) ]
|
---|
| 25 |
|
---|
| 26 |
|
---|
[1120] | 27 | env = Environment( toolpath = ['./scons'], tools = ["default", "disttar"],
|
---|
| 28 | ENV = { 'PATH' : os.environ[ 'PATH' ],
|
---|
| 29 | 'HOME' : os.environ[ 'HOME' ] },
|
---|
| 30 | options = opts)
|
---|
[1082] | 31 |
|
---|
[1120] | 32 | Help(opts.GenerateHelpText(env))
|
---|
| 33 | env.SConsignFile()
|
---|
[1082] | 34 | env.Append(CASAARCH = '')
|
---|
| 35 | env.Append(CASAROOT = '')
|
---|
| 36 | if not env.GetOption('clean'):
|
---|
| 37 | conf = Configure(env,custom_tests = {'CheckCasa': checkCasa} )
|
---|
| 38 | pyvers = 'python'+distutils.sysconfig.get_python_version()
|
---|
| 39 | if not conf.CheckLib(library=pyvers, language='c'): Exit(1)
|
---|
| 40 | if not conf.CheckHeader(pyvers+'/Python.h', language='c'): Exit(1)
|
---|
| 41 | else: conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
|
---|
[1090] | 42 | if not conf.CheckHeader(['boost/python.hpp'], language="C++"): Exit(1)
|
---|
[1082] | 43 | if not conf.CheckLib(library='boost_python', language='c++'): Exit(1)
|
---|
[1090] | 44 | if not conf.CheckLib('rpfits'): Exit(1)
|
---|
[1120] | 45 | if not conf.CheckHeader('cfitsio/fitsio.h', language='c++'): Exit(1)
|
---|
[1090] | 46 | if not conf.CheckLib('cfitsio'): Exit(1)
|
---|
| 47 | if not conf.CheckLib('lapack'): Exit(1)
|
---|
| 48 | if not conf.CheckLib('blas'): Exit(1)
|
---|
[1105] | 49 | if not conf.CheckLib('g2c'): Exit(1)
|
---|
[1090] | 50 | if not conf.CheckLib('stdc++',language='c++'): Exit(1)
|
---|
[1082] | 51 | if not conf.CheckCasa(): Exit(1)
|
---|
| 52 | env = conf.Finish()
|
---|
[1120] | 53 |
|
---|
| 54 | env["dist_dir"] = "dist/asap"
|
---|
[1090] | 55 | # general CPPFLAGS
|
---|
[1082] | 56 | env.Append(CPPFLAGS='-O3 -Wno-long-long'.split())
|
---|
[1090] | 57 | # 64bit flags
|
---|
[1082] | 58 | if platform.architecture()[0] == '64bit':
|
---|
[1123] | 59 | env.Append(CPPFLAGS='-fPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__x86_64__ -DAIPS_64B'.split())
|
---|
[1120] | 60 | if env['mode'] == 'release':
|
---|
| 61 | env.Append(LINKFLAGS=['-Wl,-O1'])
|
---|
| 62 | Export("env","SGlob")
|
---|
[1082] | 63 |
|
---|
| 64 | so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
|
---|
[1120] | 65 |
|
---|
| 66 | env.Install(env["dist_dir"], so )
|
---|
| 67 | pys = env.SConscript("python/SConscript")
|
---|
[1125] | 68 | asapmod = InstallTree(env,
|
---|
| 69 | dest_dir = os.path.join(moduledir, "asap"),
|
---|
| 70 | src_dir = env["dist_dir"],
|
---|
| 71 | includes = ['*.py', '*.so'],
|
---|
| 72 | excludes = [])
|
---|
| 73 | env.Alias('install', asapmod)
|
---|
[1120] | 74 |
|
---|
| 75 | #if env['mode'] == "release":
|
---|
| 76 | # env.DistTar("dist/asap", ["README", "INSTALL", Dir(env["dist_dir"])])
|
---|