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