source: trunk/SConstruct@ 1134

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

changed to use scons environments. added cutom paths.

File size: 3.5 KB
RevLine 
[1125]1import os
2import sys
3import glob
[1082]4import distutils.sysconfig
5import platform
[1125]6# scons plug-ins
[1130]7#from installtree import InstallTree
[1082]8
[1125]9moduledir = distutils.sysconfig.get_python_lib()
[1082]10
[1120]11opts = Options("userconfig.py")
[1130]12opts.AddOptions(PathOption("prefix",
13 "The root installation path",
14 distutils.sysconfig.PREFIX),
[1120]15 PathOption("moduledir",
16 "The python module path (site-packages))",
17 moduledir),
[1130]18 ("rpfitsdir", "Alternative rpfits location.", ""),
19 ("casadir", "Alternative rpfits location", ""),
[1120]20 EnumOption("mode", "The type of build.", "debug",
[1130]21 ["release","debug"], ignorecase=1)
22 )
[1082]23
[1105]24def SGlob(pattern):
25 path = GetBuildPath('SConscript').replace('SConscript', '')
26 return [ i.replace(path, '') for i in glob.glob(path + pattern) ]
27
28
[1130]29env = Environment( toolpath = ['./scons'], tools = ["default", "disttar", "installtree", "malte"],
[1120]30 ENV = { 'PATH' : os.environ[ 'PATH' ],
31 'HOME' : os.environ[ 'HOME' ] },
32 options = opts)
[1082]33
[1120]34Help(opts.GenerateHelpText(env))
35env.SConsignFile()
[1130]36#env.Append(CASAARCH = '')
37#env.Append(CASAROOT = '')
38
[1082]39if not env.GetOption('clean'):
[1130]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"])
[1090]53 if not conf.CheckLib('rpfits'): Exit(1)
[1130]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)
[1105]60 if not conf.CheckLib('g2c'): Exit(1)
[1130]61 if not conf.CheckLib('stdc++', language='c++'): Exit(1)
[1127]62 if not conf.CheckCasa(env["casadir"]): Exit(1)
[1082]63 env = conf.Finish()
[1120]64
[1130]65env["dist_dir"] = "#/dist/asap"
[1090]66# general CPPFLAGS
[1082]67env.Append(CPPFLAGS='-O3 -Wno-long-long'.split())
[1090]68# 64bit flags
[1082]69if platform.architecture()[0] == '64bit':
[1123]70 env.Append(CPPFLAGS='-fPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__x86_64__ -DAIPS_64B'.split())
[1130]71 # hack to install into /usr/lib64 if scons is in the 32bit /usr/lib/
[1128]72 if moduledir.startswith("/usr/lib/"):
73 moduledir.replace("lib","lib64")
[1130]74if sys.platform == "darwin":
75 env['SHLINKFLAGS'] = '$LINKFLAGS -dynamiclib -single_module'
76 env['SHLIBSUFFIX'] = '.dylib'
77
[1120]78if env['mode'] == 'release':
79 env.Append(LINKFLAGS=['-Wl,-O1'])
80Export("env","SGlob")
[1082]81
82so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
[1130]83env.Install(env["dist_dir"], so )
[1120]84
85pys = env.SConscript("python/SConscript")
[1130]86asapmod = env.InstallTree(dest_dir = os.path.join(env["moduledir"], "asap"),
[1128]87 src_dir = "dist/asap",
[1125]88 includes = ['*.py', '*.so'],
89 excludes = [])
[1130]90asapbin = env.Install(os.path.join(env["prefix"], "bin"), "bin/asap")
[1127]91env.Alias('install', [asapmod, asapbin])
[1120]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.