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