source: trunk/SConstruct@ 1090

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

added more auto-detection of libs

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