| [1125] | 1 | import os
 | 
|---|
 | 2 | import sys
 | 
|---|
| [1082] | 3 | import distutils.sysconfig
 | 
|---|
 | 4 | import platform
 | 
|---|
| [1125] | 5 | # scons plug-ins
 | 
|---|
| [1130] | 6 | #from installtree import InstallTree
 | 
|---|
| [1082] | 7 | 
 | 
|---|
| [1125] | 8 | moduledir = distutils.sysconfig.get_python_lib()
 | 
|---|
| [1136] | 9 | if  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.replace("lib", "lib64")
 | 
|---|
| [1082] | 13 | 
 | 
|---|
| [1120] | 14 | opts = Options("userconfig.py")
 | 
|---|
| [1130] | 15 | opts.AddOptions(PathOption("prefix",
 | 
|---|
 | 16 |                            "The root installation path",
 | 
|---|
 | 17 |                            distutils.sysconfig.PREFIX),
 | 
|---|
| [1120] | 18 |                 PathOption("moduledir",
 | 
|---|
 | 19 |                             "The python module path (site-packages))",
 | 
|---|
 | 20 |                             moduledir),
 | 
|---|
| [1130] | 21 |                 ("rpfitsdir", "Alternative rpfits location.", ""),
 | 
|---|
| [1138] | 22 |                 ("cfitsioincdir", "Alternative cfitsio include dir", ""),
 | 
|---|
| [1135] | 23 |                 ("casadir", "Alternative casa location", ""),
 | 
|---|
| [1120] | 24 |                 EnumOption("mode", "The type of build.", "debug",
 | 
|---|
| [1135] | 25 |                            ["release","debug"], ignorecase=1),
 | 
|---|
 | 26 |                 BoolOption("staticlink",
 | 
|---|
 | 27 |                            "Should extrenal libs be linked in statically",
 | 
|---|
 | 28 |                            False)
 | 
|---|
| [1130] | 29 |                 )
 | 
|---|
| [1082] | 30 | 
 | 
|---|
| [1135] | 31 | env = Environment( toolpath = ['./scons'],
 | 
|---|
 | 32 |                    tools = ["default", "disttar", "installtree", "casa",
 | 
|---|
 | 33 |                             "utils"],
 | 
|---|
 | 34 |                    ENV = { 'PATH' : os.environ[ 'PATH' ],
 | 
|---|
| [1120] | 35 |                           'HOME' : os.environ[ 'HOME' ] },
 | 
|---|
| [1135] | 36 |                    options = opts)
 | 
|---|
| [1082] | 37 | 
 | 
|---|
| [1120] | 38 | Help(opts.GenerateHelpText(env))
 | 
|---|
 | 39 | env.SConsignFile()
 | 
|---|
| [1135] | 40 | env.Append(CASAARCH = '', CASAROOT = '')
 | 
|---|
| [1138] | 41 | if (os.path.exists(env["cfitsioincdir"])):
 | 
|---|
 | 42 |     env.Append(CPPPATH=[env["cfitsioincdir"]])
 | 
|---|
 | 43 | env.AddCustomPath(env["rpfitsdir"])
 | 
|---|
| [1082] | 44 | if not env.GetOption('clean'):
 | 
|---|
| [1130] | 45 |     conf = Configure(env)
 | 
|---|
 | 46 |     # import Custom tests
 | 
|---|
| [1135] | 47 |     env.AddCasaTest(conf)
 | 
|---|
| [1130] | 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"])
 | 
|---|
| [1090] | 58 |     if not conf.CheckLib('rpfits'): Exit(1)
 | 
|---|
| [1138] | 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'])
 | 
|---|
| [1130] | 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)
 | 
|---|
| [1105] | 72 |     if not conf.CheckLib('g2c'): Exit(1)
 | 
|---|
| [1130] | 73 |     if not conf.CheckLib('stdc++', language='c++'): Exit(1)
 | 
|---|
| [1127] | 74 |     if not conf.CheckCasa(env["casadir"]): Exit(1)
 | 
|---|
| [1082] | 75 |     env = conf.Finish()
 | 
|---|
| [1120] | 76 | 
 | 
|---|
| [1135] | 77 | env["stage_dir"] = Dir("#/stage/asap")
 | 
|---|
 | 78 | 
 | 
|---|
| [1090] | 79 | # general CPPFLAGS
 | 
|---|
| [1135] | 80 | env.Append(CPPFLAGS=['-D_FILE_OFFSET_BITS=64', '-D_LARGEFILE_SOURCE', '-O3'])
 | 
|---|
| [1136] | 81 | 
 | 
|---|
| [1090] | 82 | # 64bit flags
 | 
|---|
| [1082] | 83 | if  platform.architecture()[0] == '64bit':
 | 
|---|
| [1135] | 84 |     env.Append(CPPFLAGS=['-fPIC', '-D__x86_64__', '-DAIPS_64B'])
 | 
|---|
| [1136] | 85 | 
 | 
|---|
| [1135] | 86 | if env["PLATFORM"] == "darwin":
 | 
|---|
 | 87 |     env['SHLINKFLAGS'] = '$LINKFLAGS -bundle'
 | 
|---|
 | 88 |     #env['SHLIBSUFFIX'] = '.dylib'
 | 
|---|
| [1130] | 89 | 
 | 
|---|
| [1120] | 90 | if env['mode'] == 'release':
 | 
|---|
 | 91 |     env.Append(LINKFLAGS=['-Wl,-O1'])
 | 
|---|
| [1135] | 92 | Export("env")
 | 
|---|
| [1082] | 93 | 
 | 
|---|
 | 94 | so = env.SConscript("src/SConscript", build_dir="build", duplicate=0)
 | 
|---|
| [1135] | 95 | env.Install(env["stage_dir"], so )
 | 
|---|
| [1120] | 96 | 
 | 
|---|
 | 97 | pys = env.SConscript("python/SConscript")
 | 
|---|
| [1130] | 98 | asapmod = env.InstallTree(dest_dir = os.path.join(env["moduledir"], "asap"),
 | 
|---|
| [1135] | 99 |                           src_dir  = "stage/asap",
 | 
|---|
 | 100 |                           includes = ['*.py', '*.so'],
 | 
|---|
 | 101 |                           excludes = [])
 | 
|---|
| [1130] | 102 | asapbin = env.Install(os.path.join(env["prefix"], "bin"), "bin/asap")
 | 
|---|
| [1127] | 103 | env.Alias('install', [asapmod, asapbin])
 | 
|---|