source: trunk/SConstruct@ 1131

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

changed to use scons environments. added cutom paths.

File size: 3.5 KB
Line 
1import os
2import sys
3import glob
4import distutils.sysconfig
5import platform
6# scons plug-ins
7#from installtree import InstallTree
8
9moduledir = distutils.sysconfig.get_python_lib()
10
11opts = Options("userconfig.py")
12opts.AddOptions(PathOption("prefix",
13 "The root installation path",
14 distutils.sysconfig.PREFIX),
15 PathOption("moduledir",
16 "The python module path (site-packages))",
17 moduledir),
18 ("rpfitsdir", "Alternative rpfits location.", ""),
19 ("casadir", "Alternative rpfits location", ""),
20 EnumOption("mode", "The type of build.", "debug",
21 ["release","debug"], ignorecase=1)
22 )
23
24def SGlob(pattern):
25 path = GetBuildPath('SConscript').replace('SConscript', '')
26 return [ i.replace(path, '') for i in glob.glob(path + pattern) ]
27
28
29env = Environment( toolpath = ['./scons'], tools = ["default", "disttar", "installtree", "malte"],
30 ENV = { 'PATH' : os.environ[ 'PATH' ],
31 'HOME' : os.environ[ 'HOME' ] },
32 options = opts)
33
34Help(opts.GenerateHelpText(env))
35env.SConsignFile()
36#env.Append(CASAARCH = '')
37#env.Append(CASAROOT = '')
38
39if not env.GetOption('clean'):
40 conf = Configure(env)
41 # import Custom tests
42 env.AddCustomTests(conf)
43 pylib = 'python'+distutils.sysconfig.get_python_version()
44 pyinc = "Python.h"
45 if env['PLATFORM'] == "darwin":
46 pylib = "Python"
47 if not conf.CheckLib(library=pylib, language='c'): Exit(1)
48 conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
49 if not conf.CheckHeader("Python.h", language='c'):
50 Exit(1)
51 if not conf.CheckLibWithHeader('boost_python', 'boost/python.hpp', 'c++'): Exit(1)
52 conf.env.AddCustomPath(env["rpfitsdir"])
53 if not conf.CheckLib('rpfits'): Exit(1)
54 if not conf.CheckLibWithHeader('cfitsio', 'fitsio.h', 'c'): Exit(1)
55 if (sys.platform == "darwin"):
56 conf.env.Append(LIBS = ['-framework vecLib'])
57 else:
58 if not conf.CheckLib('lapack'): Exit(1)
59 if not conf.CheckLib('blas'): Exit(1)
60 if not conf.CheckLib('g2c'): Exit(1)
61 if not conf.CheckLib('stdc++', language='c++'): Exit(1)
62 if not conf.CheckCasa(env["casadir"]): Exit(1)
63 env = conf.Finish()
64
65env["dist_dir"] = "#/dist/asap"
66# general CPPFLAGS
67env.Append(CPPFLAGS='-O3 -Wno-long-long'.split())
68# 64bit flags
69if platform.architecture()[0] == '64bit':
70 env.Append(CPPFLAGS='-fPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__x86_64__ -DAIPS_64B'.split())
71 # hack to install into /usr/lib64 if scons is in the 32bit /usr/lib/
72 if moduledir.startswith("/usr/lib/"):
73 moduledir.replace("lib","lib64")
74if sys.platform == "darwin":
75 env['SHLINKFLAGS'] = '$LINKFLAGS -dynamiclib -single_module'
76 env['SHLIBSUFFIX'] = '.dylib'
77
78if env['mode'] == 'release':
79 env.Append(LINKFLAGS=['-Wl,-O1'])
80Export("env","SGlob")
81
82so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
83env.Install(env["dist_dir"], so )
84
85pys = env.SConscript("python/SConscript")
86asapmod = env.InstallTree(dest_dir = os.path.join(env["moduledir"], "asap"),
87 src_dir = "dist/asap",
88 includes = ['*.py', '*.so'],
89 excludes = [])
90asapbin = env.Install(os.path.join(env["prefix"], "bin"), "bin/asap")
91env.Alias('install', [asapmod, asapbin])
92
93#if env['mode'] == "release":
94# env.DistTar("dist/asap", ["README", "INSTALL", Dir(env["dist_dir"])])
Note: See TracBrowser for help on using the repository browser.