[1105] | 1 | import os, sys, glob
|
---|
[1082] | 2 | import distutils.sysconfig
|
---|
| 3 | import platform
|
---|
| 4 |
|
---|
| 5 | #vars = distutils.sysconfig.get_config_vars()
|
---|
[1105] | 6 | moduledir = "/opt/lib/python2/"#distutils.sysconfig.get_python_lib()
|
---|
[1082] | 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 |
|
---|
[1105] | 12 | def SGlob(pattern):
|
---|
| 13 | path = GetBuildPath('SConscript').replace('SConscript', '')
|
---|
| 14 | return [ i.replace(path, '') for i in glob.glob(path + pattern) ]
|
---|
| 15 |
|
---|
| 16 |
|
---|
[1090] | 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 )
|
---|
[1105] | 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 ] )
|
---|
[1090] | 27 | # Explicit templates in casa
|
---|
| 28 | env.Append( CPPFLAGS = ['-DAIPS_NO_TEMPLATE_SRC'] )
|
---|
[1082] | 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])
|
---|
[1090] | 38 | addCasaLibs(conf.env)
|
---|
[1082] | 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)
|
---|
[1090] | 53 | addCasaLibs(conf.env)
|
---|
[1082] | 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()])
|
---|
[1090] | 70 | if not conf.CheckHeader(['boost/python.hpp'], language="C++"): Exit(1)
|
---|
[1082] | 71 | if not conf.CheckLib(library='boost_python', language='c++'): Exit(1)
|
---|
[1090] | 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)
|
---|
[1105] | 76 | if not conf.CheckLib('g2c'): Exit(1)
|
---|
[1090] | 77 | if not conf.CheckLib('stdc++',language='c++'): Exit(1)
|
---|
[1082] | 78 | if not conf.CheckCasa(): Exit(1)
|
---|
| 79 | env = conf.Finish()
|
---|
[1090] | 80 | # general CPPFLAGS
|
---|
[1082] | 81 | env.Append(CPPFLAGS='-O3 -Wno-long-long'.split())
|
---|
[1090] | 82 | # 64bit flags
|
---|
[1082] | 83 | if platform.architecture()[0] == '64bit':
|
---|
[1090] | 84 | env.Append(CPPFLAGS='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__x86_64__ -DAIPS_64B'.split())
|
---|
[1082] | 85 |
|
---|
[1105] | 86 | Export("env","SGlob")
|
---|
[1082] | 87 | so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
|
---|
| 88 | env.Install(moduledir, so )
|
---|
[1105] | 89 | #pys = env.SConscript("python/SConscript")
|
---|
| 90 | # env.Install(moduledir, pys)
|
---|
| 91 | env.Alias('install', moduledir)
|
---|