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