1 | import os, sys, glob
|
---|
2 | import distutils.sysconfig
|
---|
3 | import platform
|
---|
4 |
|
---|
5 | #vars = distutils.sysconfig.get_config_vars()
|
---|
6 | moduledir = "/opt/lib/python2/"#distutils.sysconfig.get_python_lib()
|
---|
7 |
|
---|
8 | opts = Options("userconfig.py", ARGUMENTS)
|
---|
9 | opts.Add("prefix", "The root installation path", distutils.sysconfig.PREFIX)
|
---|
10 | opts.Add("moduledir", "The python module path (site-packages))", moduledir)
|
---|
11 |
|
---|
12 | def SGlob(pattern):
|
---|
13 | path = GetBuildPath('SConscript').replace('SConscript', '')
|
---|
14 | return [ i.replace(path, '') for i in glob.glob(path + pattern) ]
|
---|
15 |
|
---|
16 |
|
---|
17 | def 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 |
|
---|
30 | def 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 |
|
---|
59 | env = Environment( ENV = { 'PATH' : os.environ[ 'PATH' ],
|
---|
60 | 'HOME' : os.environ[ 'HOME' ] # required for distcc
|
---|
61 | }, options = opts)
|
---|
62 | env.Append(CASAARCH = '')
|
---|
63 | env.Append(CASAROOT = '')
|
---|
64 | if 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
|
---|
81 | env.Append(CPPFLAGS='-O3 -Wno-long-long'.split())
|
---|
82 | # 64bit flags
|
---|
83 | if platform.architecture()[0] == '64bit':
|
---|
84 | env.Append(CPPFLAGS='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__x86_64__ -DAIPS_64B'.split())
|
---|
85 |
|
---|
86 | Export("env","SGlob")
|
---|
87 | so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
|
---|
88 | env.Install(moduledir, so )
|
---|
89 | #pys = env.SConscript("python/SConscript")
|
---|
90 | # env.Install(moduledir, pys)
|
---|
91 | env.Alias('install', moduledir)
|
---|