source: trunk/SConstruct@ 1172

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

fix for 64bit path replacement

File size: 3.9 KB
Line 
1import os
2import sys
3import distutils.sysconfig
4import platform
5# scons plug-ins
6#from installtree import InstallTree
7
8moduledir = distutils.sysconfig.get_python_lib()
9if platform.architecture()[0] == '64bit':
10 # hack to install into /usr/lib64 if scons is in the 32bit /usr/lib/
11 if moduledir.startswith("/usr/lib/"):
12 moduledir = moduledir.replace("lib", "lib64")
13
14opts = Options("userconfig.py")
15opts.AddOptions(PathOption("prefix",
16 "The root installation path",
17 distutils.sysconfig.PREFIX),
18 PathOption("moduledir",
19 "The python module path (site-packages))",
20 moduledir),
21 ("rpfitsdir", "Alternative rpfits location.", ""),
22 ("cfitsioincdir", "Alternative cfitsio include dir", ""),
23 ("casadir", "Alternative casa location", ""),
24 EnumOption("mode", "The type of build.", "debug",
25 ["release","debug"], ignorecase=1),
26 BoolOption("staticlink",
27 "Should extrenal libs be linked in statically",
28 False)
29 )
30
31env = Environment( toolpath = ['./scons'],
32 tools = ["default", "disttar", "installtree", "casa",
33 "utils"],
34 ENV = { 'PATH' : os.environ[ 'PATH' ],
35 'HOME' : os.environ[ 'HOME' ] },
36 options = opts)
37
38Help(opts.GenerateHelpText(env))
39env.SConsignFile()
40env.Append(CASAARCH = '', CASAROOT = '')
41if (os.path.exists(env["cfitsioincdir"])):
42 env.Append(CPPPATH=[env["cfitsioincdir"]])
43env.AddCustomPath(env["rpfitsdir"])
44if not env.GetOption('clean'):
45 conf = Configure(env)
46 # import Custom tests
47 env.AddCasaTest(conf)
48 pylib = 'python'+distutils.sysconfig.get_python_version()
49 pyinc = "Python.h"
50 if env['PLATFORM'] == "darwin":
51 pylib = "Python"
52 if not conf.CheckLib(library=pylib, language='c'): Exit(1)
53 conf.env.Append(CPPPATH=[distutils.sysconfig.get_python_inc()])
54 if not conf.CheckHeader("Python.h", language='c'):
55 Exit(1)
56 if not conf.CheckLibWithHeader('boost_python', 'boost/python.hpp', 'c++'): Exit(1)
57 conf.env.AddCustomPath(env["rpfitsdir"])
58 if not conf.CheckLib('rpfits'): Exit(1)
59 # cfitsio is either in include/ or /include/cfitsio
60 # handle this
61 if not conf.CheckLib(library='cfitsio', language='c'): Exit(1)
62 if not conf.CheckHeader('fitsio.h', language='c'):
63 if not conf.CheckHeader('cfitsio/fitsio.h', language='c'):
64 Exit(1)
65 else:
66 conf.env.Append(CPPPATH=['/usr/include/cfitsio'])
67 if (sys.platform == "darwin"):
68 conf.env.Append(LIBS = ['-framework vecLib'])
69 else:
70 if not conf.CheckLib('lapack'): Exit(1)
71 if not conf.CheckLib('blas'): Exit(1)
72 if not conf.CheckLib('g2c'): Exit(1)
73 if not conf.CheckLib('stdc++', language='c++'): Exit(1)
74 if not conf.CheckCasa(env["casadir"]): Exit(1)
75 env = conf.Finish()
76
77env["stage_dir"] = Dir("#/stage/asap")
78
79# general CPPFLAGS
80env.Append(CPPFLAGS=['-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-O3'])
81
82# 64bit flags
83if platform.architecture()[0] == '64bit':
84 env.Append(CPPFLAGS=['-fPIC', '-D__x86_64__', '-DAIPS_64B'])
85
86if env["PLATFORM"] == "darwin":
87 env['SHLINKFLAGS'] = '$LINKFLAGS -bundle'
88 #env['SHLIBSUFFIX'] = '.dylib'
89
90if env['mode'] == 'release':
91 env.Append(LINKFLAGS=['-Wl,-O1'])
92Export("env")
93
94so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
95env.Install(env["stage_dir"], so )
96
97pys = env.SConscript("python/SConscript")
98asapmod = env.InstallTree(dest_dir = os.path.join(env["moduledir"], "asap"),
99 src_dir = "stage/asap",
100 includes = ['*.py', '*.so'],
101 excludes = [])
102asapbin = env.Install(os.path.join(env["prefix"], "bin"), "bin/asap")
103env.Alias('install', [asapmod, asapbin])
Note: See TracBrowser for help on using the repository browser.