source: trunk/scons/casaoptions.py@ 2510

Last change on this file since 2510 was 2486, checked in by Malte Marquarding, 12 years ago

casacore moved to cmake, add tools locally

File size: 7.4 KB
Line 
1import sys, os
2from SCons.Variables import Variables
3from SCons.Script import AddOption, GetOption
4
5def generate(env):
6
7 class CLOptions(object):
8 def __init__(self):
9 self.opts = {}
10 self.variables = []
11
12 def add_option(self, *args, **kw):
13 AddOption(*args, **kw)
14 key = kw.get('dest')
15 value = GetOption(key)
16 defvalue = kw.get('default')
17 self.variables.append((key, '', defvalue))
18 if value != defvalue:
19 self.opts[key] = value
20
21 def update(self, fname):
22 if os.path.exists(fname) and not GetOption("silent") and not env.GetOption("help"):
23 print "Restoring previous command-line options from '%s'" % fname
24 vars = Variables(fname, self.opts)
25 vars.AddVariables(*self.variables)
26 vars.Update(env)
27 vars.Save(fname, env)
28
29 def add_pkg_option(self, libid, root=None, lib=None, libdir=None,
30 incdir=None, help=None):
31 libname = lib or libid
32 self.add_str_option(libid+"-lib", libname,
33 help="%s library name (default: %s)" % (libname, libname))
34 self.add_str_option(libid+"-root", root,
35 help="%s package root" % libid)
36 self.add_str_option(libid+"-incdir", incdir,
37 help="%s package 'include' directory (overwrites '-root')" % libid)
38 self.add_str_option(libid+"-libdir", libdir,
39 help="%s package 'lib' directory (overwrites '-root')" \
40 % libid)
41
42 def add_str_option(self, optname, default=None, help=None):
43 envopt = optname.replace("-", "_")
44 self.add_option("--%s" % optname, dest=envopt, type="string",
45 default=default, help=help)
46
47 def add_comp_option(self, optname, default=None, help=None):
48 self.add_option("--with-%s" % optname.lower(), dest=optname,
49 type="string", default=default, help=help)
50
51
52
53 env.CLOptions = CLOptions()
54
55 def AddCommandLineOptions( ):
56 """ Adds the build environment options to the opts. """
57
58 env.CLOptions.add_option("--enable-shared", dest="enable_shared",
59 action="store_true", default=False,
60 help="Enable building shared (dynamic) libraries")
61 env.CLOptions.add_option("--disable-static", dest="disable_static",
62 action="store_true", default=False,
63 help="Disable building static libraries")
64 env.CLOptions.add_option("--enable-hdf5", dest="enable_hdf5",
65 action="store_true", default=False,
66 help="Enable the HDF5 library")
67 env.CLOptions.add_option("--enable-fftw3", dest="enable_fftw3",
68 action="store_true", default=False,
69 help="Enable the FFTW3 library")
70 env.CLOptions.add_option("--disable-fftw3-threads", dest="disable_fftw3_threads",
71 action="store_true", default=False,
72 help="Disable use of threads in the FFTW3 library")
73 env.CLOptions.add_option("--disable-dl", dest="disable_dl",
74 action="store_true", default=False,
75 help="Disable the use of dlopen")
76 env.CLOptions.add_option("--enable-readline", dest="enable_readline",
77 action="store_true", default=False,
78 help="Enable the readline library")
79 env.CLOptions.add_option("--data-dir", dest="data_dir", default=None,
80 action="store", type="string",
81 help="The location of the measures data directory to compile in as the default search location")
82 env.CLOptions.add_option("--build-type", dest="build_type", default="opt",
83 action="store", type="string",
84 help="Build optimized 'opt' (default) or debug 'dbg'")
85
86 env.CLOptions.add_pkg_option("hdf5")
87 env.CLOptions.add_pkg_option("fftw3")
88 env.CLOptions.add_pkg_option("fftw3-threads")
89 env.CLOptions.add_pkg_option("dl")
90 env.CLOptions.add_pkg_option("readline")
91 env.CLOptions.add_pkg_option("blas")
92 env.CLOptions.add_pkg_option("lapack")
93 env.CLOptions.add_pkg_option("f2c", lib="gfortran")
94 env.CLOptions.add_pkg_option("cfitsio")
95 env.CLOptions.add_pkg_option("wcs")
96
97 options = [("extra-cppflags", None, "Extra pre-processor flags"),
98 ("extra-cxxflags", None, "Extra c++ compiler falgs"),
99 ("extra-cflags", None, "Extra c compiler flags"),
100 ("extra-linkflags", None, "Extra linker flags"),
101 ("extra-fflags", None, "Extra fortran compiler flags"),
102 ("extra-includedir", None, "Extra 'include' dir(s)"),
103 ("extra-librarydir", None, "Extra 'lib' dir(s)"),
104 ("extra-ldlibrarypath", None, "Extra (DY)LD_LIBRARY_PATH"),
105 ("extra-libs", None, "Extra libraries for linker"),
106 ("extra-path", None, "Extra PATH (bin) to search"),
107 ("extra-root", None, "Extra hierachy root to search")]
108 for opt in options:
109 env.CLOptions.add_str_option(*opt)
110 options = [("CC", None, "The c compiler"),
111 ("CXX", None, "The c++ compiler"),
112 ("FORTRAN", None, "The fortran compiler"),]
113# ("LD", None, "The linker")]
114 for opt in options:
115 env.CLOptions.add_comp_option(*opt)
116
117
118 PREFIX = "prefix"
119 EPREFIX = "eprefix"
120 BINDIR = "bindir"
121 LIBDIR = "libdir"
122 INCLUDEDIR = "includedir"
123 SHAREDIR = "sharedir"
124
125 defdir = "/usr/local"
126
127 env.CLOptions.add_option("--"+PREFIX, dest=PREFIX,
128 type="string", default=defdir,
129 help="The installation prefix (default: %s)" % defdir)
130 env.CLOptions.add_option("--"+EPREFIX, dest=EPREFIX,
131 type="string", default=defdir)
132 env.CLOptions.add_option("--"+BINDIR, dest=BINDIR,
133 type="string", default=None,
134 help="The installation bin directory (default: %s/bin)" % defdir)
135 env.CLOptions.add_option("--"+LIBDIR, dest=LIBDIR,
136 type="string", default=None,
137 help="The installation lib directory (default: %s/lib)" % defdir)
138 env.CLOptions.add_option("--"+INCLUDEDIR, dest=INCLUDEDIR,
139 type="string", default=None,
140 help="The installation include directory (default: %s/include)" % defdir)
141 env.CLOptions.add_option("--"+SHAREDIR, dest=SHAREDIR,
142 type="string", default=None,
143 help="The installation share directory (default: %s/share)" % defdir)
144
145 opt = ("universal", None,
146 "Create universal build using any of: ppc,i386,ppc64,x86_64")
147 if sys.platform == 'darwin':
148 env.CLOptions.add_str_option(*opt) # ppc i386 ppc64 x86_64
149
150 env.CLOptions.update('options.cache')
151
152 AddCommandLineOptions()
153
154def exists(env):
155 return 1
Note: See TracBrowser for help on using the repository browser.