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