source: trunk/SConstruct@ 1341

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

added custom fortran location. added darwin release mode options

File size: 7.7 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
[1335]13opts = Options("options.cfg")
14opts.AddOptions(
[1325]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':
[1335]133 if env["PLATFORM"] != "darwin":
134 env.Append(LINKFLAGS=['-Wl,-O1', '-s'])
135 env.Append(CCFLAGS=["-O2"])
136else:
137 env.Append(CCFLAGS=["-g"])
[1184]138
139# Export for SConscript files
[1135]140Export("env")
[1082]141
[1325]142# build externals
143env.SConscript("external/SConscript")
[1184]144# build library
[1082]145so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
[1195]146# test module import, to see if there are unresolved symbols
147def test_module(target,source,env):
148 pth = str(target[0])
149 mod = os.path.splitext(pth)[0]
150 sys.path.insert(2, os.path.split(mod)[0])
151 __import__(os.path.split(mod)[1])
152 print "ok"
153 return 0
154def test_str(target, source, env):
155 return "Testing module..."
[1184]156
[1195]157taction = Action(test_module, test_str)
158env.AddPostAction(so, taction)
159
[1184]160# install targets
161somod = env.Install("$moduledir/asap", so )
162pymods = env.Install("$moduledir/asap", env.SGlob("python/*.py"))
163bins = env.Install("$prefix/bin", ["bin/asap", "bin/asap_update_data"])
[1187]164shares = env.Install("$moduledir/asap/data", "share/ipythonrc-asap")
[1184]165env.Alias('install', [somod, pymods, bins, shares])
166
167# install aips++ data repos
168rootdir=None
169outdir = os.path.join(env["moduledir"],'asap','data')
170sources = ['ephemerides','geodetic']
171if os.path.exists("/nfs/aips++/data"):
172 rootdir = "/nfs/aips++/data"
173elif os.path.exists("data"):
[1195]174 rootdir = "./data"
[1184]175if rootdir is not None:
176 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
177 data = env.InstallAs(ofiles, ifiles)
178 env.Alias('install', data)
[1202]179
[1177]180# make binary distribution
181if len(env["makedist"]):
[1184]182 env["stagedir"] = "asap-%s-%s" % (env["version"], env["makedist"])
183 env.Command('Staging distribution for archive in %s' % env["stagedir"],
184 '', env.MessageAction)
[1195]185 st0 = env.QInstall("$stagedir/asap", [so, env.SGlob("python/*.py")] )
[1184]186 env.QInstall("$stagedir/bin", ["bin/asap", "bin/asap_update_data"])
[1195]187 env.QInstall("$stagedir", ["bin/install"])
188 env.QInstall("$stagedir/asap/data", "share/ipythonrc-asap")
189 if rootdir is not None:
[1202]190 # This creates a directory Using data table... - disabled
191 #env.Command("Using data tables in %s" % rootdir,
192 # '', env.MessageAction)
[1184]193 outdir = os.path.join(env["stagedir"],'asap','data')
194 ofiles, ifiles = env.WalkDirTree(outdir, rootdir, sources)
195 env.QInstallAs(ofiles, ifiles)
[1195]196 else:
197 env.Command("No data tables available. Use 'asap_update_data' after install",
[1202]198 '', env.MessageAction)
[1184]199 arch = env.Archiver(os.path.join("dist",env["stagedir"]),
200 env["stagedir"])
201 env.AddPostAction(arch, Delete("$stagedir"))
[1259]202if env["makedoc"].lower() != "none":
203 env.SConscript("doc/SConscript")
[1195]204
205if env.GetOption("clean"):
206 Execute(Delete(".sconf_temp"))
Note: See TracBrowser for help on using the repository browser.