diff options
-rw-r--r-- | numpy/core/SConstruct | 20 | ||||
-rw-r--r-- | numpy/core/scons_support.py | 28 |
2 files changed, 34 insertions, 14 deletions
diff --git a/numpy/core/SConstruct b/numpy/core/SConstruct index f4a9824b4..c4c3e528e 100644 --- a/numpy/core/SConstruct +++ b/numpy/core/SConstruct @@ -1,4 +1,4 @@ -# Last Change: Sun Jan 06 10:00 PM 2008 J +# Last Change: Tue Jan 08 09:00 PM 2008 J # vim:syntax=python import os import sys @@ -11,7 +11,8 @@ from numscons import CheckCBLAS from numscons import write_info from scons_support import CheckBrokenMathlib, define_no_smp, \ - generate_config_header, generate_config_header_emitter + generate_config_header, generate_config_header_emitter, \ + check_mlib, check_mlibs env = GetNumpyEnvironment(ARGUMENTS) env.Append(CPPPATH = [get_python_inc()]) @@ -26,7 +27,7 @@ if os.name == 'nt': #======================= # XXX: separate env for configuration config = env.NumpyConfigure(custom_tests = {'CheckBrokenMathlib' : CheckBrokenMathlib, - 'CheckCBLAS' : CheckCBLAS}) + 'CheckCBLAS' : CheckCBLAS}, config_h = 'scons_config.h') # Convention: list of tuples (definition, value). value: # - 0: #undef definition @@ -86,16 +87,9 @@ mlibs = [[], ['m'], ['cpml']] mathlib = os.environ.get('MATHLIB') if mathlib: mlibs.insert(0, mathlib) -for mlib in mlibs: - st = config.CheckBrokenMathlib(mlib) - if st: - break -if not st: - import SCons - raise SCons.Errors.UserError("No usable mathlib was found: chose another "\ - "one using the MATHLIB env variable, eg "\ - "'MATHLIB=m python setup.py build'") +mlib = check_mlibs(config, mlibs) + # XXX: this is ugly: mathlib has nothing to do in a public header file config_sym.append(('MATHLIB', ','.join(mlib))) @@ -103,7 +97,7 @@ def check_lib(f, autoadd = 0): """Check that f is available in mlib, and add the symbol appropriately. f is expected to be a tuble (symbol, cpp define).""" - st = config.CheckLibWithHeader(mlib, 'math.h', language = 'C', call = '%s;' % f[0], autoadd = autoadd) + st = config.CheckFunc(f[0], language = 'C') if st: config_sym.append((f[1], 1)) else: diff --git a/numpy/core/scons_support.py b/numpy/core/scons_support.py index 3d2c4eaea..2b0fadc3a 100644 --- a/numpy/core/scons_support.py +++ b/numpy/core/scons_support.py @@ -1,4 +1,4 @@ -#! Last Change: Sun Jan 06 09:00 PM 2008 J +#! Last Change: Tue Jan 08 08:00 PM 2008 J __docstring__ = """Code to support special facilities to scons which are only useful for numpy.core, hence not put into numpy.distutils.scons""" @@ -18,6 +18,7 @@ from numscons.numdist import process_c_str as process_str from numscons.core.utils import rsplit, isstring import SCons.Node +import SCons def split_ext(string): sp = rsplit(string, '.', 1) @@ -160,6 +161,31 @@ int main(int argc, char *argv[]) context.Result(' No !') return st[0] +def check_mlib(config, mlib): + """Return 1 if mlib is available and usable by numpy, 0 otherwise. + + mlib can be a string (one library), or a list of libraries.""" + # Check the libraries in mlib are linkable + if len(mlib) > 0: + # XXX: put an autoadd argument to 0 here and add an autoadd argument to + # CheckBroekenMathlib (otherwise we may add bogus libraries, the ones + # which do not path the CheckBrokenMathlib test). + st = config.CheckLib(mlib) + if not st: + return 0 + # Check the mlib is usable by numpy + return config.CheckBrokenMathlib(mlib) + +def check_mlibs(config, mlibs): + for mlib in mlibs: + if check_mlib(config, mlib): + return mlib + + # No mlib was found. + raise SCons.Errors.UserError("No usable mathlib was found: chose another "\ + "one using the MATHLIB env variable, eg "\ + "'MATHLIB=m python setup.py build'") + def define_no_smp(): """Returns True if we should define NPY_NOSMP, False otherwise.""" #-------------------------------- |