source: trunk/SConstruct@ 1116

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

more clever use of python...

File size: 3.6 KB
Line 
1import os, sys, glob
2import distutils.sysconfig
3import platform
4
5#vars = distutils.sysconfig.get_config_vars()
6moduledir = "/opt/lib/python2/"#distutils.sysconfig.get_python_lib()
7
8opts = Options("userconfig.py", ARGUMENTS)
9opts.Add("prefix", "The root installation path", distutils.sysconfig.PREFIX)
10opts.Add("moduledir", "The python module path (site-packages))", moduledir)
11
12def SGlob(pattern):
13 path = GetBuildPath('SConscript').replace('SConscript', '')
14 return [ i.replace(path, '') for i in glob.glob(path + pattern) ]
15
16
17def addCasaLibs(env):
18 casalibs = "casav atnf images ms components coordinates \
19 lattices fits measures measures_f \
20 tables scimath scimath_f casa wcs".split()
21 env.Prepend( LIBS = casalibs )
22 casaincd = [os.path.join(env['CASAROOT'], 'code/include'), \
23 os.path.join(env['CASAROOT'], 'code/casa')]
24 env.Append( CPPPATH = casaincd )
25 casalibd = os.path.join(env['CASAROOT'], env['CASAARCH'], 'lib')
26 env.Append( LIBPATH = [ casalibd ] )
27 # Explicit templates in casa
28 env.Append( CPPFLAGS = ['-DAIPS_NO_TEMPLATE_SRC'] )
29
30def checkCasa(conf, path=None):
31 ''' look for casa libraries'''
32 conf.Message('Checking for casa libraries...')
33 casaarch = None
34 if os.environ.has_key('AIPSPATH'):
35 casa = os.environ.get('AIPSPATH').split()
36 conf.env.Append(CASAARCH = casa[1])
37 conf.env.Append(CASAROOT = casa[0])
38 addCasaLibs(conf.env)
39 conf.Result('yes')
40 return True
41 casaarch = 'linux_gnu'
42 if sys.platform == 'darwin':
43 casaarch = darwin
44 elif sys.platform == 'linux2' and platform.architecture()[0] == '64bit':
45 casarch = 'linux_64b'
46 paths = "/nfs/aips++/weekly /aips++ /opt/aips++ ../casa_asap".split()
47 if path is not None:
48 paths = [path]
49 for p in paths:
50 if os.path.isfile(os.path.join(p,casaarch,"lib/libcasa.a")):
51 conf.env.Append(CASAARCH = casaarch)
52 conf.env.Append(CASAROOT = p)
53 addCasaLibs(conf.env)
54 conf.Result('yes')
55 return True
56 conf.Result('n')
57 return False
58
59env = Environment( ENV = { 'PATH' : os.environ[ 'PATH' ],
60 'HOME' : os.environ[ 'HOME' ] # required for distcc
61 }, options = opts)
62env.Append(CASAARCH = '')
63env.Append(CASAROOT = '')
64if not env.GetOption('clean'):
65 conf = Configure(env,custom_tests = {'CheckCasa': checkCasa} )
66 pyvers = 'python'+distutils.sysconfig.get_python_version()
67 if not conf.CheckLib(library=pyvers, language='c'): Exit(1)
68 if not conf.CheckHeader(pyvers+'/Python.h', language='c'): Exit(1)
69 else: conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
70 if not conf.CheckHeader(['boost/python.hpp'], language="C++"): Exit(1)
71 if not conf.CheckLib(library='boost_python', language='c++'): Exit(1)
72 if not conf.CheckLib('rpfits'): Exit(1)
73 if not conf.CheckLib('cfitsio'): Exit(1)
74 if not conf.CheckLib('lapack'): Exit(1)
75 if not conf.CheckLib('blas'): Exit(1)
76 if not conf.CheckLib('g2c'): Exit(1)
77 if not conf.CheckLib('stdc++',language='c++'): Exit(1)
78 if not conf.CheckCasa(): Exit(1)
79 env = conf.Finish()
80# general CPPFLAGS
81env.Append(CPPFLAGS='-O3 -Wno-long-long'.split())
82# 64bit flags
83if platform.architecture()[0] == '64bit':
84 env.Append(CPPFLAGS='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__x86_64__ -DAIPS_64B'.split())
85
86Export("env","SGlob")
87so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
88env.Install(moduledir, so )
89#pys = env.SConscript("python/SConscript")
90# env.Install(moduledir, pys)
91env.Alias('install', moduledir)
Note: See TracBrowser for help on using the repository browser.