source: trunk/SConstruct @ 1325

Last change on this file since 1325 was 1325, checked in by mar637, 17 years ago

Changes to use casacore instead of casa_asap/aips++\nAdded atnf PKSIO library snapshot to external and linking against this local copy

File size: 8.1 KB
Line 
1import os
2import sys
3import distutils.sysconfig
4import platform
5import SCons
6
7moduledir = distutils.sysconfig.get_python_lib()
8if  platform.architecture()[0] == '64bit':
9    # hack to install into /usr/lib64 if scons is in the 32bit /usr/lib/
10    if moduledir.startswith("/usr/lib/"):
11        moduledir = moduledir.replace("lib", "lib64")
12
13opts = Options("userconfig.py")
14opts.AddOptions(               
15                ("FORTRAN", "The fortran compiler", None),
16                ("f2clib", "The fortran to c library", None),
17                PathOption("prefix",
18                "The root installation path",
19                           distutils.sysconfig.PREFIX),
20                PathOption("moduledir",
21                            "The python module path (site-packages))",
22                            moduledir),
23                PathOption("casacoreroot", "The location of casacore",
24                                    "/usr/local"),
25                ("boostroot", "The root dir where boost is installed", None),
26                ("boostlib", "The name of the boost python library",
27                 "boost_python"),
28                ("boostlibdir", "The boost library location", None),
29                ("boostincdir", "The boost header file location", None),
30                ("lapackroot",
31                 "The root directory where lapack is installed", None),
32                ("lapacklibdir", "The lapack library location", None),
33                ("lapacklib",
34                 "The lapack library name (e.g. for specialized AMD libraries",
35                 None),
36                ("blasroot",
37                 "The root directory where blas is installed", None),
38                ("blaslibdir", "The blas library location", None),
39                ("blaslib",
40                 "The blas library name (e.g. for specialized AMD libraries",
41                 None),
42                ("cfitsioroot",
43                 "The root directory where cfistio is installed", None),
44                ("cfitsiolibdir", "The cfitsio library location", None),
45                ("cfitsioincdir", "The cfitsio include location", None),
46                ("wcsroot",
47                 "The root directory where wcs is installed", None),
48                ("wcslibdir", "The wcs library location", None),
49                ("rpfitsroot",
50                 "The root directory where rpfits is installed", None),
51                ("rpfitslibdir", "The rpfits library location", None),
52               
53                EnumOption("mode", "The type of build.", "debug",
54                           ["release","debug"], ignorecase=1),
55                ("makedist",
56                 "Make a binary archive giving a suffix, e.g. sarge or fc5",
57                 ""),
58                EnumOption("makedoc", "Build the userguide in specified format",
59                           "none",
60                           ["none", "pdf", "html"], ignorecase=1)
61                )
62
63env = Environment( toolpath = ['./scons'],
64                   tools = ["default", "archiver", "utils",
65                            "quietinstall"],
66                   ENV = { 'PATH' : os.environ[ 'PATH' ],
67                          'HOME' : os.environ[ 'HOME' ] },
68                   options = opts)
69
70Help(opts.GenerateHelpText(env))
71env.SConsignFile()
72
73casacoretooldir = os.path.join(env["casacoreroot"],"share",
74                                   "casacore")
75if not os.path.exists(casacoretooldir):
76    print "Could not find casacore scons tools"
77    Exit(1)
78
79# load casacore specific build flags
80print casacoretooldir
81env.Tool('casa', [casacoretooldir])
82
83if not env.GetOption('clean'):
84    conf = Configure(env)
85    conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
86    if not conf.CheckHeader("Python.h", language='c'):
87        Exit(1)
88    pylib = 'python'+distutils.sysconfig.get_python_version()
89    if env['PLATFORM'] == "darwin":
90        conf.env.Append(FRAMEWORKS=["Python"])
91    else:
92        if not conf.CheckLib(library=pylib, language='c'): Exit(1)
93
94    conf.env.AppendUnique(LIBPATH=os.path.join(conf.env["casacoreroot"],
95                                               "lib"))
96    conf.env.AppendUnique(CPPPATH=os.path.join(conf.env["casacoreroot"],
97                                               "include", "casacore"))
98    print conf.env["CPPPATH"]
99#    if not conf.CheckLib("casa_images",  language='c++'): Exit(1)
100    if not conf.CheckLib("casa_ms",  language='c++'): Exit(1)
101    if not conf.CheckLib("casa_components",  language='c++'): Exit(1)
102    if not conf.CheckLib("casa_coordinates",  language='c++'): Exit(1)
103    if not conf.CheckLib("casa_lattices",  language='c++'): Exit(1)
104    if not conf.CheckLib("casa_fits",  language='c++'): Exit(1)
105    if not conf.CheckLib("casa_measures",  language='c++'): Exit(1)
106    if not conf.CheckLib("casa_scimath",  language='c++'): Exit(1)
107    if not conf.CheckLib("casa_scimath_f",  language='c++'): Exit(1)
108    if not conf.CheckLib("casa_tables",  language='c++'): Exit(1)
109    if not conf.CheckLib("casa_mirlib",  language='c++'): Exit(1)
110    if not conf.CheckLib("casa_casa",  language='c++'): Exit(1)
111    conf.env.AddCustomPackage('boost')
112    if not conf.CheckLibWithHeader(env["boostlib"],
113                                   'boost/python.hpp', language='c++'):
114        Exit(1)
115    # test for cfitsio
116    if not conf.CheckLib("m"): Exit(1)
117    conf.env.AddCustomPackage('cfitsio')
118    if not conf.CheckLibWithHeader('cfitsio', 'fitsio.h', language='c'):
119        Exit(1)
120    conf.env.AddCustomPackage('wcs')
121    if not conf.CheckLibWithHeader('wcs', 'wcslib/wcs.h', language='c'):
122        Exit(1)
123    conf.env.AddCustomPackage('rpfits')
124    if not conf.CheckLib("rpfits"): Exit(1)
125
126    # test for blas/lapack
127    blasname = conf.env.get("blaslib", "blas")
128    conf.env.AddCustomPackage("blas")
129    if not conf.CheckLib(blasname): Exit(1)
130    lapackname = conf.env.get("lapacklib", "lapack")
131    conf.env.AddCustomPackage("lapack")
132    if not conf.CheckLib(lapackname): Exit(1)
133    conf.env.CheckFortran(conf)
134    if not conf.CheckLib('stdc++', language='c++'): Exit(1)
135    env = conf.Finish()
136
137env["version"] = "trunk"
138
139if env['mode'] == 'release':
140    env.Append(LINKFLAGS=['-Wl,-O1'])
141
142# Export for SConscript files
143Export("env")
144
145# build externals
146env.SConscript("external/SConscript")
147# build library
148so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
149# test module import, to see if there are unresolved symbols
150def test_module(target,source,env):
151    pth = str(target[0])
152    mod = os.path.splitext(pth)[0]
153    sys.path.insert(2, os.path.split(mod)[0])
154    __import__(os.path.split(mod)[1])
155    print "ok"
156    return 0
157def test_str(target, source, env):
158    return "Testing module..."
159
160taction = Action(test_module, test_str)
161env.AddPostAction(so, taction)
162
163# install targets
164somod = env.Install("$moduledir/asap", so )
165pymods = env.Install("$moduledir/asap", env.SGlob("python/*.py"))
166bins = env.Install("$prefix/bin", ["bin/asap", "bin/asap_update_data"])
167shares = env.Install("$moduledir/asap/data", "share/ipythonrc-asap")
168env.Alias('install', [somod, pymods, bins, shares])
169
170# install aips++ data repos
171rootdir=None
172outdir =  os.path.join(env["moduledir"],'asap','data')
173sources = ['ephemerides','geodetic']
174if os.path.exists("/nfs/aips++/data"):
175    rootdir = "/nfs/aips++/data"
176elif os.path.exists("data"):
177    rootdir = "./data"
178if rootdir is not None:
179    ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
180    data =  env.InstallAs(ofiles, ifiles)
181    env.Alias('install', data)
182
183# make binary distribution
184if len(env["makedist"]):
185    env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
186    env.Command('Staging distribution for archive in %s' % env["stagedir"],
187                '', env.MessageAction)
188    st0 = env.QInstall("$stagedir/asap", [so,  env.SGlob("python/*.py")] )
189    env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
190    env.QInstall("$stagedir", ["bin/install"])
191    env.QInstall("$stagedir/asap/data", "share/ipythonrc-asap")
192    if rootdir is not None:
193        # This creates a directory Using data table... - disabled
194        #env.Command("Using data tables in %s" % rootdir,
195        #           '', env.MessageAction)
196        outdir =  os.path.join(env["stagedir"],'asap','data')
197        ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
198        env.QInstallAs(ofiles, ifiles)
199    else:
200        env.Command("No data tables available. Use 'asap_update_data' after install",
201                    '', env.MessageAction)
202    arch = env.Archiver(os.path.join("dist",env["stagedir"]),
203                        env["stagedir"])
204    env.AddPostAction(arch, Delete("$stagedir"))
205if env["makedoc"].lower() != "none":
206    env.SConscript("doc/SConscript")
207
208if env.GetOption("clean"):
209    Execute(Delete(".sconf_temp"))
Note: See TracBrowser for help on using the repository browser.