source: trunk/SConstruct@ 1198

Last change on this file since 1198 was 1195, checked in by mar637, 18 years ago

added module test action. fixed makedist target including install script.

File size: 5.7 KB
Line 
1import os
2import sys
3import distutils.sysconfig
4import platform
5import SCons
6# scons plug-ins
7#from installtree import InstallTree
8
9moduledir = distutils.sysconfig.get_python_lib()
10if 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
15opts = Options("userconfig.py")
16opts.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 archive giving a suffix, e.g. sarge or fc5",
29 "")
30 )
31
32env = Environment( toolpath = ['./scons'],
33 tools = ["default", "casa", "archiver", "utils",
34 "quietinstall"],
35 ENV = { 'PATH' : os.environ[ 'PATH' ],
36 'HOME' : os.environ[ 'HOME' ] },
37 options = opts)
38
39Help(opts.GenerateHelpText(env))
40env.SConsignFile()
41env.Append(CASAARCH = '', CASAROOT = '')
42if (os.path.exists(env["cfitsioincdir"])):
43 env.Append(CPPPATH=[env["cfitsioincdir"]])
44env.AddCustomPath(env["rpfitsdir"])
45if 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
78env["version"] = "2.1.0b"
79
80# general CPPFLAGS
81env.Append(CPPFLAGS=['-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-O3'])
82
83# 64bit flags
84if platform.architecture()[0] == '64bit':
85 env.Append(CPPFLAGS=['-fPIC', '-D__x86_64__', '-DAIPS_64B'])
86
87if env['mode'] == 'release':
88 env.Append(LINKFLAGS=['-Wl,-O1'])
89
90# Export for SConscript files
91Export("env")
92
93# build library
94so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
95# test module import, to see if there are unresolved symbols
96def test_module(target,source,env):
97 pth = str(target[0])
98 mod = os.path.splitext(pth)[0]
99 sys.path.insert(2, os.path.split(mod)[0])
100 __import__(os.path.split(mod)[1])
101 print "ok"
102 return 0
103def test_str(target, source, env):
104 return "Testing module..."
105
106taction = Action(test_module, test_str)
107env.AddPostAction(so, taction)
108
109# install targets
110somod = env.Install("$moduledir/asap", so )
111pymods = env.Install("$moduledir/asap", env.SGlob("python/*.py"))
112bins = env.Install("$prefix/bin", ["bin/asap", "bin/asap_update_data"])
113shares = env.Install("$moduledir/asap/data", "share/ipythonrc-asap")
114env.Alias('install', [somod, pymods, bins, shares])
115
116# install aips++ data repos
117rootdir=None
118outdir = os.path.join(env["moduledir"],'asap','data')
119sources = ['ephemerides','geodetic']
120if os.path.exists("/nfs/aips++/data"):
121 rootdir = "/nfs/aips++/data"
122elif os.path.exists("data"):
123 rootdir = "./data"
124if rootdir is not None:
125 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
126 data = env.InstallAs(ofiles, ifiles)
127 env.Alias('install', data)
128
129# make binary distribution
130if len(env["makedist"]):
131 env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
132 env.Command('Staging distribution for archive in %s' % env["stagedir"],
133 '', env.MessageAction)
134 st0 = env.QInstall("$stagedir/asap", [so, env.SGlob("python/*.py")] )
135 env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
136 env.QInstall("$stagedir", ["bin/install"])
137 env.QInstall("$stagedir/asap/data", "share/ipythonrc-asap")
138 if rootdir is not None:
139 env.Command("Using data tables in %s" % rootdir,
140 '', env.MessageAction)
141 outdir = os.path.join(env["stagedir"],'asap','data')
142 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
143 env.QInstallAs(ofiles, ifiles)
144 else:
145 env.Command("No data tables available. Use 'asap_update_data' after install",
146 '', env.MessageAction)
147 arch = env.Archiver(os.path.join("dist",env["stagedir"]),
148 env["stagedir"])
149 env.AddPostAction(arch, Delete("$stagedir"))
150
151if env.GetOption("clean"):
152 Execute(Delete(".sconf_temp"))
Note: See TracBrowser for help on using the repository browser.