source: trunk/SConstruct@ 1331

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

changed order of blas and lapack

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