[Numpy-svn] r4327 - in branches/numpy.scons/numpy: core distutils/scons distutils/scons/checkers

numpy-svn@scip... numpy-svn@scip...
Mon Oct 29 05:44:12 CDT 2007


Author: cdavid
Date: 2007-10-29 05:43:52 -0500 (Mon, 29 Oct 2007)
New Revision: 4327

Added:
   branches/numpy.scons/numpy/distutils/scons/checkers/
   branches/numpy.scons/numpy/distutils/scons/checkers/__init__.py
   branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py
Removed:
   branches/numpy.scons/numpy/distutils/scons/custom_checkers.py
Modified:
   branches/numpy.scons/numpy/core/SConstruct
   branches/numpy.scons/numpy/distutils/scons/TODO
   branches/numpy.scons/numpy/distutils/scons/__init__.py
Log:
Put custom checkers in separate module

Modified: branches/numpy.scons/numpy/core/SConstruct
===================================================================
--- branches/numpy.scons/numpy/core/SConstruct	2007-10-29 10:02:27 UTC (rev 4326)
+++ branches/numpy.scons/numpy/core/SConstruct	2007-10-29 10:43:52 UTC (rev 4327)
@@ -1,4 +1,4 @@
-# Last Change: Mon Oct 29 06:00 PM 2007 J
+# Last Change: Mon Oct 29 07:00 PM 2007 J
 # vim:syntax=python
 import os
 import sys
@@ -8,7 +8,7 @@
 from numpy.distutils.scons import get_python_inc, get_pythonlib_dir
 from numpy.distutils.scons import GetNumpyEnvironment
 from numpy.distutils.scons import NumpyCheckLib
-from numpy.distutils.scons.custom_checkers import CheckCBLAS, CheckMKL, CheckATLAS, CheckGenericBLAS, CheckGenericLAPACK
+from numpy.distutils.scons import CheckCBLAS, CheckMKL, CheckATLAS, CheckGenericBLAS, CheckGenericLAPACK
 from numpy.distutils.scons.configuration import write_info
 
 from scons_support import CheckBrokenMathlib, define_no_smp, \

Modified: branches/numpy.scons/numpy/distutils/scons/TODO
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/TODO	2007-10-29 10:02:27 UTC (rev 4326)
+++ branches/numpy.scons/numpy/distutils/scons/TODO	2007-10-29 10:43:52 UTC (rev 4327)
@@ -9,8 +9,6 @@
     - improve Fortran runtime detection for upstream integration
     - improve Fortran mangling and dummy main detection for upstream
       integration
-    - Netlib BLAS and LAPACK checkers with site.cfg overriding
-    - Generic BLAS and LAPACK checker with site.cfg overriding
 
 Builder:
     - Get a PythonExtension builder independant of distutils for upstream

Modified: branches/numpy.scons/numpy/distutils/scons/__init__.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-10-29 10:02:27 UTC (rev 4326)
+++ branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-10-29 10:43:52 UTC (rev 4327)
@@ -1,7 +1,7 @@
 from numpyenv import GetNumpyEnvironment, GetNumpyOptions
 from libinfo_scons import NumpyCheckLib
 from libinfo import get_paths as scons_get_paths
-from custom_checkers import CheckMKL, CheckATLAS, CheckCBLAS, \
+from checkers.custom_checkers import CheckMKL, CheckATLAS, CheckCBLAS, \
         CheckAccelerate, CheckMKL, CheckSunperf, CheckLAPACK, \
         CheckGenericBLAS, CheckGenericLAPACK
 from extension import get_python_inc, get_pythonlib_dir

Added: branches/numpy.scons/numpy/distutils/scons/checkers/__init__.py
===================================================================

Copied: branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py (from rev 4326, branches/numpy.scons/numpy/distutils/scons/custom_checkers.py)
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/custom_checkers.py	2007-10-29 10:02:27 UTC (rev 4326)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py	2007-10-29 10:43:52 UTC (rev 4327)
@@ -0,0 +1,348 @@
+#! /usr/bin/env python
+# Last Change: Mon Oct 29 07:00 PM 2007 J
+
+# Module for custom, common checkers for numpy (and scipy)
+import sys
+import os.path
+from copy import deepcopy
+from distutils.util import get_platform
+
+from numpy.distutils.scons.libinfo import get_config_from_section, get_config
+from numpy.distutils.scons.testcode_snippets import cblas_sgemm as cblas_src, \
+        c_sgemm as sunperf_src, lapack_sgesv
+
+from numpy.distutils.scons.fortran_scons import CheckF77Mangling, CheckF77Clib
+
+from numpy.distutils.scons.configuration import opt_info, add_info
+
+def _check_include_and_run(context, name, cpppath, headers, run_src, libs,
+                           libpath, linkflags, cflags, autoadd = 1):
+    """This is a basic implementation for generic "test include and run"
+    testers.
+    
+    For example, for library foo, which implements function do_foo, and with
+    include header foo.h, this will:
+        - test that foo.h is found and compilable by the compiler
+        - test that the given source code can be compiled. The source code
+          should contain a simple program with the function.
+          
+    Arguments:
+        - name: name of the library
+        - cpppath: list of directories
+        - headers: list of headers
+        - run_src: the code for the run test
+        - libs: list of libraries to link
+        - libpath: list of library path.
+        - linkflags: list of link flags to add."""
+    context.Message('Checking for %s ... ' % name)
+    env = context.env
+
+    #----------------------------
+    # Check headers are available
+    #----------------------------
+    oldCPPPATH = (env.has_key('CPPPATH') and deepcopy(env['CPPPATH'])) or []
+    oldCFLAGS = (env.has_key('CFLAGS') and deepcopy(env['CFLAGS'])) or []
+    env.AppendUnique(CPPPATH = cpppath)
+    env.AppendUnique(CFLAGS = cflags)
+    # XXX: handle context
+    hcode = ['#include <%s>' % h for h in headers]
+    # HACK: we add cpppath in the command of the source, to add dependency of
+    # the check on the cpppath.
+    hcode.extend(['#if 0', '%s' % cpppath, '#endif\n'])
+    src = '\n'.join(hcode)
+
+    ret = context.TryCompile(src, '.c')
+    if not ret:
+        env.Replace(CPPPATH = oldCPPPATH)
+        env.Replace(CFLAGS = oldCFLAGS)
+        context.Result('Failed: %s include not found' % name)
+        return 0
+
+    #------------------------------
+    # Check a simple example works
+    #------------------------------
+    oldLIBPATH = (env.has_key('LIBPATH') and deepcopy(env['LIBPATH'])) or []
+    oldLIBS = (env.has_key('LIBS') and deepcopy(env['LIBS'])) or []
+    # XXX: RPATH, drawbacks using it ?
+    oldRPATH = (env.has_key('RPATH') and deepcopy(env['RPATH'])) or []
+    oldLINKFLAGS = (env.has_key('LINKFLAGS') and deepcopy(env['LINKFLAGS'])) or []
+    env.AppendUnique(LIBPATH = libpath)
+    env.AppendUnique(LIBS = libs)
+    env.AppendUnique(RPATH = libpath)
+    env.AppendUnique(LINKFLAGS = linkflags)
+
+    # HACK: we add libpath and libs at the end of the source as a comment, to
+    # add dependency of the check on those.
+    src = '\n'.join(['#include <%s>' % h for h in headers] +\
+                    [run_src, '#if 0', '%s' % libpath, 
+                     '%s' % headers, '%s' % libs, '#endif'])
+    ret = context.TryLink(src, '.c')
+    if (not ret or not autoadd):
+        # If test failed or autoadd = 0, restore everything
+        env.Replace(LIBS = oldLIBS)
+        env.Replace(LIBPATH = oldLIBPATH)
+        env.Replace(RPATH = oldRPATH)
+        env.Replace(LINKFLAGS = oldLINKFLAGS)
+
+    if not ret:
+        context.Result('Failed: %s test could not be linked and run' % name)
+        return 0
+
+    context.Result(ret)
+    return ret
+     
+#def CheckMKL(context, mkl_dir, nb):
+#    """mkl_lib is the root path of MKL (the one which contains include, lib,
+#    etc...). nb is 32, 64, emt, etc..."""
+#
+#    libs = ['mkl']
+#    cpppath = os.path.join(mkl_dir, 'include')
+#    libpath = os.path.join(mkl_dir, 'lib', nb)
+#
+#    return _check_include_and_run(context, 'MKL', cpppath, ['mkl.h'],
+#                                  cblas_src, libs, libpath, [], [], autoadd)
+
+def CheckMKL(context, autoadd = 1):
+    """Check MKL is usable using a simple cblas example."""
+    section = "mkl"
+    siteconfig, cfgfiles = get_config()
+    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
+    if not found:
+        # XXX: find exact options to use for the MKL
+        libs.extend(['lapack', 'mkl', 'guide', 'm'])
+    headers = ['mkl.h']
+
+    return _check_include_and_run(context, 'MKL', cpppath, headers,
+                                  cblas_src, libs, libpath, [], [], autoadd)
+
+def CheckATLAS(context, autoadd = 1):
+    """Check whether ATLAS is usable in C."""
+
+    libs = ['atlas', 'f77blas', 'cblas']
+    libpath = []
+
+    return _check_include_and_run(context, 'ATLAS', None, ['atlas_enum.h', 'cblas.h'],
+                                  cblas_src, libs, libpath, [], [], autoadd)
+
+def CheckAccelerate(context, autoadd = 1):
+    """Checker for Accelerate framework (on Mac OS X >= 10.3). Only test from
+    C."""
+    # According to
+    # http://developer.apple.com/hardwaredrivers/ve/vector_libraries.html:
+    #
+    #   This page contains a continually expanding set of vector libraries
+    #   that are available to the AltiVec programmer through the Accelerate
+    #   framework on MacOS X.3, Panther. On earlier versions of MacOS X,
+    #   these were available in vecLib.framework. The currently available
+    #   libraries are described below.
+
+    #XXX: get_platform does not seem to work...
+    #if get_platform()[-4:] == 'i386':
+    #    is_intel = 1
+    #    cflags.append('-msse3')
+    #else:
+    #    is_intel = 0
+    #    cflags.append('-faltivec')
+
+    # XXX: This double append is not good, any other way ?
+    linkflags = ['-framework', 'Accelerate']
+
+    return _check_include_and_run(context, 'FRAMEWORK: Accelerate', None, 
+                                  ['Accelerate/Accelerate.h'], cblas_src, [], 
+                                  [], linkflags, [], autoadd)
+
+def CheckVeclib(context, autoadd = 1):
+    """Checker for Veclib framework (on Mac OS X < 10.3)."""
+    # XXX: This double append is not good, any other way ?
+    linkflags = ['-framework', 'vecLib']
+
+    return _check_include_and_run(context, 'FRAMEWORK: veclib', None, 
+                                  ['vecLib/vecLib.h'], cblas_src, [], 
+                                  [], linkflags, [], autoadd)
+
+def CheckSunperf(context, autoadd = 1):
+    """Checker for sunperf using a simple sunperf example"""
+
+    # XXX: Other options needed ?
+    linkflags = ['-xlic_lib=sunperf']
+    cflags = ['-dalign']
+
+    return _check_include_and_run(context, 'sunperf', None, 
+                                  ['sunperf.h'], sunperf_src, [], 
+                                  [], linkflags, cflags, autoadd)
+
+def CheckCBLAS(context, autoadd = 1):
+    env = context.env
+
+    # If section cblas is in site.cfg, use those options. Otherwise, use default
+    section = "cblas"
+    siteconfig, cfgfiles = get_config()
+    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
+    if found:
+        headers = ['cblas.h']
+        linkflags = []
+        cflags = []
+        st = _check_include_and_run(context, 'CBLAS', [], headers, cblas_src,
+                                      libs, libpath, linkflags, cflags, autoadd)
+        if st:
+            add_info(env, 'cblas', opt_info('cblas', site = 1))
+            return st
+    else:
+        if sys.platform == 'darwin':
+            st = CheckAccelerate(context, autoadd)
+            if st:
+                add_info(env, 'cblas', opt_info('Accelerate'))
+                return st
+            st = CheckVeclib(context, autoadd)
+            if st:
+                add_info(env, 'cblas', opt_info('vecLib'))
+                return st
+
+            add_info(env, 'cblas', opt_info(''))
+            return 0
+            
+        else:
+            # Check MKL, then ATLAS, then Sunperf
+            st = CheckMKL(context, autoadd)
+            if st:
+                add_info(env, 'cblas', opt_info('mkl'))
+                return st
+            st = CheckATLAS(context, autoadd)
+            if st:
+                add_info(env, 'cblas', opt_info('atlas'))
+                return st
+            st = CheckSunperf(context, autoadd)
+            if st:
+                add_info(env, 'cblas', opt_info('sunperf'))
+                return st
+
+            add_info(env, 'cblas', opt_info(''))
+            return 0
+
+def CheckLAPACK(context, autoadd = 1):
+    # XXX: this whole thing is ugly. Think more about how to combine checkers
+    # in 'meta checker' like this.
+    if sys.platform == 'nt':
+        import warnings
+        warning.warn('FIXME: LAPACK checks not implemented yet on win32')
+        return 0
+    else:
+        env = context.env
+
+        # Get fortran stuff
+        if not env.has_key('F77_NAME_MANGLER'):
+            if not CheckF77Mangling(context):
+                return 0
+        if not env.has_key('F77_LDFLAGS'):
+            if not CheckF77Clib(context):
+                return 0
+
+        # Get the mangled name of our test function
+        sgesv_string = env['F77_NAME_MANGLER']('sgesv')
+        test_src = lapack_sgesv % sgesv_string
+
+        # Check MKL
+        st = CheckMKL(context, autoadd = 1)
+        if st:
+            fdict = env.ParseFlags(context.env['F77_LDFLAGS'])
+            fdict['LIBS'].append('lapack')
+            if env.has_key('LIBS'):
+                fdict['LIBS'].extend(context.env['LIBS'])
+            if env.has_key('LIBPATH'):
+                fdict['LIBPATH'].extend(context.env['LIBPATH'])
+            st =_check_include_and_run(context, 'LAPACK (MKL)', [], [],
+                    test_src, fdict['LIBS'], fdict['LIBPATH'], [], [], autoadd = 1)
+            add_info(env, 'lapack', opt_info('mkl'))
+            return st
+
+        # Check ATLAS
+        st = CheckATLAS(context, autoadd = 1)
+        if st:
+            fdict = env.ParseFlags(context.env['F77_LDFLAGS'])
+            fdict['LIBS'].append('lapack')
+            if env.has_key('LIBS'):
+                fdict['LIBS'].extend(context.env['LIBS'])
+            if env.has_key('LIBPATH'):
+                fdict['LIBPATH'].extend(context.env['LIBPATH'])
+            st =_check_include_and_run(context, 'LAPACK (ATLAS)', [], [],
+                    test_src, fdict['LIBS'], fdict['LIBPATH'], [], [], autoadd = 1)
+            add_info(env, 'lapack', opt_info('atlas'))
+            # XXX: Check complete LAPACK or not
+            return st
+
+    return 0
+
+def _my_try_link(context, src, libs, libpath, autoadd = 0):
+    """Try to link the given text in src with libs and libpath."""
+    env = context.env
+
+    oldLIBS = (env.has_key('LIBS') and deepcopy(env['LIBS'])) or []
+    oldLIBPATH = (env.has_key('LIBPATH') and deepcopy(env['LIBPATH'])) or []
+
+    ret = 0
+    try:
+        env.AppendUnique(LIBS = libs, LIBPATH = libpath)
+        ret = context.TryLink(src, '.c')
+    finally:
+        if not ret or not autoadd:
+            env.Replace(LIBS = oldLIBS, LIBPATH = oldLIBPATH)
+
+    return ret
+
+def CheckGenericBLAS(context, autoadd = 1, section = 'blas'):
+    """Check whether a BLAS library can be found.
+
+    Use site.cfg if found (section given by section argument)."""
+    siteconfig, cfgfiles = get_config()
+    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
+    if not found:
+        libs.extend(['blas'])
+
+    env = context.env
+    # Get fortran mangling
+    if not env.has_key('F77_NAME_MANGLER'):
+        if not CheckF77Mangling(context):
+            return 0
+
+    test_func_name = env['F77_NAME_MANGLER']('dgemm')
+    src = get_func_link_src(test_func_name)
+
+    context.Message("Checking for Generic BLAS... ")
+
+    st =  _my_try_link(context, src, libs, libpath, autoadd)
+    if st:
+        env['F77_BLAS_LIBS'] = libs
+        env['F77_BLAS_LIBPATH'] = libpath
+
+    context.Result(st)
+
+    return st
+
+def CheckGenericLAPACK(context, autoadd = 1, section = 'lapack'):
+    """Check whether a LAPACK library can be found.
+
+    Use site.cfg if found (section given by section argument)."""
+    siteconfig, cfgfiles = get_config()
+    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
+    if not found:
+        libs.extend(['lapack'])
+
+    env = context.env
+    # Get fortran mangling
+    if not env.has_key('F77_NAME_MANGLER'):
+        if not CheckF77Mangling(context):
+            return 0
+
+    test_func_name = env['F77_NAME_MANGLER']('dpotri')
+    src = get_func_link_src(test_func_name)
+
+    context.Message("Checking for Generic LAPACK... ")
+
+    st =  _my_try_link(context, src, libs, libpath, autoadd)
+    if st:
+        env['F77_LAPACK_LIBS'] = libs
+        env['F77_LAPACK_LIBPATH'] = libpath
+
+    context.Result(st)
+
+    return st

Deleted: branches/numpy.scons/numpy/distutils/scons/custom_checkers.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/custom_checkers.py	2007-10-29 10:02:27 UTC (rev 4326)
+++ branches/numpy.scons/numpy/distutils/scons/custom_checkers.py	2007-10-29 10:43:52 UTC (rev 4327)
@@ -1,349 +0,0 @@
-#! /usr/bin/env python
-# Last Change: Mon Oct 29 06:00 PM 2007 J
-
-# Module for custom, common checkers for numpy (and scipy)
-import sys
-import os.path
-from copy import deepcopy
-from distutils.util import get_platform
-
-from libinfo import get_config, get_config_from_section, get_func_link_src
-from libinfo_scons import NumpyCheckLib
-from testcode_snippets import cblas_sgemm as cblas_src, \
-        c_sgemm as sunperf_src, lapack_sgesv
-
-from fortran_scons import CheckF77Mangling, CheckF77Clib
-
-from configuration import opt_info, add_info
-
-def _check_include_and_run(context, name, cpppath, headers, run_src, libs,
-                           libpath, linkflags, cflags, autoadd = 1):
-    """This is a basic implementation for generic "test include and run"
-    testers.
-    
-    For example, for library foo, which implements function do_foo, and with
-    include header foo.h, this will:
-        - test that foo.h is found and compilable by the compiler
-        - test that the given source code can be compiled. The source code
-          should contain a simple program with the function.
-          
-    Arguments:
-        - name: name of the library
-        - cpppath: list of directories
-        - headers: list of headers
-        - run_src: the code for the run test
-        - libs: list of libraries to link
-        - libpath: list of library path.
-        - linkflags: list of link flags to add."""
-    context.Message('Checking for %s ... ' % name)
-    env = context.env
-
-    #----------------------------
-    # Check headers are available
-    #----------------------------
-    oldCPPPATH = (env.has_key('CPPPATH') and deepcopy(env['CPPPATH'])) or []
-    oldCFLAGS = (env.has_key('CFLAGS') and deepcopy(env['CFLAGS'])) or []
-    env.AppendUnique(CPPPATH = cpppath)
-    env.AppendUnique(CFLAGS = cflags)
-    # XXX: handle context
-    hcode = ['#include <%s>' % h for h in headers]
-    # HACK: we add cpppath in the command of the source, to add dependency of
-    # the check on the cpppath.
-    hcode.extend(['#if 0', '%s' % cpppath, '#endif\n'])
-    src = '\n'.join(hcode)
-
-    ret = context.TryCompile(src, '.c')
-    if not ret:
-        env.Replace(CPPPATH = oldCPPPATH)
-        env.Replace(CFLAGS = oldCFLAGS)
-        context.Result('Failed: %s include not found' % name)
-        return 0
-
-    #------------------------------
-    # Check a simple example works
-    #------------------------------
-    oldLIBPATH = (env.has_key('LIBPATH') and deepcopy(env['LIBPATH'])) or []
-    oldLIBS = (env.has_key('LIBS') and deepcopy(env['LIBS'])) or []
-    # XXX: RPATH, drawbacks using it ?
-    oldRPATH = (env.has_key('RPATH') and deepcopy(env['RPATH'])) or []
-    oldLINKFLAGS = (env.has_key('LINKFLAGS') and deepcopy(env['LINKFLAGS'])) or []
-    env.AppendUnique(LIBPATH = libpath)
-    env.AppendUnique(LIBS = libs)
-    env.AppendUnique(RPATH = libpath)
-    env.AppendUnique(LINKFLAGS = linkflags)
-
-    # HACK: we add libpath and libs at the end of the source as a comment, to
-    # add dependency of the check on those.
-    src = '\n'.join(['#include <%s>' % h for h in headers] +\
-                    [run_src, '#if 0', '%s' % libpath, 
-                     '%s' % headers, '%s' % libs, '#endif'])
-    ret = context.TryLink(src, '.c')
-    if (not ret or not autoadd):
-        # If test failed or autoadd = 0, restore everything
-        env.Replace(LIBS = oldLIBS)
-        env.Replace(LIBPATH = oldLIBPATH)
-        env.Replace(RPATH = oldRPATH)
-        env.Replace(LINKFLAGS = oldLINKFLAGS)
-
-    if not ret:
-        context.Result('Failed: %s test could not be linked and run' % name)
-        return 0
-
-    context.Result(ret)
-    return ret
-     
-#def CheckMKL(context, mkl_dir, nb):
-#    """mkl_lib is the root path of MKL (the one which contains include, lib,
-#    etc...). nb is 32, 64, emt, etc..."""
-#
-#    libs = ['mkl']
-#    cpppath = os.path.join(mkl_dir, 'include')
-#    libpath = os.path.join(mkl_dir, 'lib', nb)
-#
-#    return _check_include_and_run(context, 'MKL', cpppath, ['mkl.h'],
-#                                  cblas_src, libs, libpath, [], [], autoadd)
-
-def CheckMKL(context, autoadd = 1):
-    """Check MKL is usable using a simple cblas example."""
-    section = "mkl"
-    siteconfig, cfgfiles = get_config()
-    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
-    if not found:
-        # XXX: find exact options to use for the MKL
-        libs.extend(['lapack', 'mkl', 'guide', 'm'])
-    headers = ['mkl.h']
-
-    return _check_include_and_run(context, 'MKL', cpppath, headers,
-                                  cblas_src, libs, libpath, [], [], autoadd)
-
-def CheckATLAS(context, autoadd = 1):
-    """Check whether ATLAS is usable in C."""
-
-    libs = ['atlas', 'f77blas', 'cblas']
-    libpath = []
-
-    return _check_include_and_run(context, 'ATLAS', None, ['atlas_enum.h', 'cblas.h'],
-                                  cblas_src, libs, libpath, [], [], autoadd)
-
-def CheckAccelerate(context, autoadd = 1):
-    """Checker for Accelerate framework (on Mac OS X >= 10.3). Only test from
-    C."""
-    # According to
-    # http://developer.apple.com/hardwaredrivers/ve/vector_libraries.html:
-    #
-    #   This page contains a continually expanding set of vector libraries
-    #   that are available to the AltiVec programmer through the Accelerate
-    #   framework on MacOS X.3, Panther. On earlier versions of MacOS X,
-    #   these were available in vecLib.framework. The currently available
-    #   libraries are described below.
-
-    #XXX: get_platform does not seem to work...
-    #if get_platform()[-4:] == 'i386':
-    #    is_intel = 1
-    #    cflags.append('-msse3')
-    #else:
-    #    is_intel = 0
-    #    cflags.append('-faltivec')
-
-    # XXX: This double append is not good, any other way ?
-    linkflags = ['-framework', 'Accelerate']
-
-    return _check_include_and_run(context, 'FRAMEWORK: Accelerate', None, 
-                                  ['Accelerate/Accelerate.h'], cblas_src, [], 
-                                  [], linkflags, [], autoadd)
-
-def CheckVeclib(context, autoadd = 1):
-    """Checker for Veclib framework (on Mac OS X < 10.3)."""
-    # XXX: This double append is not good, any other way ?
-    linkflags = ['-framework', 'vecLib']
-
-    return _check_include_and_run(context, 'FRAMEWORK: veclib', None, 
-                                  ['vecLib/vecLib.h'], cblas_src, [], 
-                                  [], linkflags, [], autoadd)
-
-def CheckSunperf(context, autoadd = 1):
-    """Checker for sunperf using a simple sunperf example"""
-
-    # XXX: Other options needed ?
-    linkflags = ['-xlic_lib=sunperf']
-    cflags = ['-dalign']
-
-    return _check_include_and_run(context, 'sunperf', None, 
-                                  ['sunperf.h'], sunperf_src, [], 
-                                  [], linkflags, cflags, autoadd)
-
-def CheckCBLAS(context, autoadd = 1):
-    env = context.env
-
-    # If section cblas is in site.cfg, use those options. Otherwise, use default
-    section = "cblas"
-    siteconfig, cfgfiles = get_config()
-    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
-    if found:
-        headers = ['cblas.h']
-        linkflags = []
-        cflags = []
-        st = _check_include_and_run(context, 'CBLAS', [], headers, cblas_src,
-                                      libs, libpath, linkflags, cflags, autoadd)
-        if st:
-            add_info(env, 'cblas', opt_info('cblas', site = 1))
-            return st
-    else:
-        if sys.platform == 'darwin':
-            st = CheckAccelerate(context, autoadd)
-            if st:
-                add_info(env, 'cblas', opt_info('Accelerate'))
-                return st
-            st = CheckVeclib(context, autoadd)
-            if st:
-                add_info(env, 'cblas', opt_info('vecLib'))
-                return st
-
-            add_info(env, 'cblas', opt_info(''))
-            return 0
-            
-        else:
-            # Check MKL, then ATLAS, then Sunperf
-            st = CheckMKL(context, autoadd)
-            if st:
-                add_info(env, 'cblas', opt_info('mkl'))
-                return st
-            st = CheckATLAS(context, autoadd)
-            if st:
-                add_info(env, 'cblas', opt_info('atlas'))
-                return st
-            st = CheckSunperf(context, autoadd)
-            if st:
-                add_info(env, 'cblas', opt_info('sunperf'))
-                return st
-
-            add_info(env, 'cblas', opt_info(''))
-            return 0
-
-def CheckLAPACK(context, autoadd = 1):
-    # XXX: this whole thing is ugly. Think more about how to combine checkers
-    # in 'meta checker' like this.
-    if sys.platform == 'nt':
-        import warnings
-        warning.warn('FIXME: LAPACK checks not implemented yet on win32')
-        return 0
-    else:
-        env = context.env
-
-        # Get fortran stuff
-        if not env.has_key('F77_NAME_MANGLER'):
-            if not CheckF77Mangling(context):
-                return 0
-        if not env.has_key('F77_LDFLAGS'):
-            if not CheckF77Clib(context):
-                return 0
-
-        # Get the mangled name of our test function
-        sgesv_string = env['F77_NAME_MANGLER']('sgesv')
-        test_src = lapack_sgesv % sgesv_string
-
-        # Check MKL
-        st = CheckMKL(context, autoadd = 1)
-        if st:
-            fdict = env.ParseFlags(context.env['F77_LDFLAGS'])
-            fdict['LIBS'].append('lapack')
-            if env.has_key('LIBS'):
-                fdict['LIBS'].extend(context.env['LIBS'])
-            if env.has_key('LIBPATH'):
-                fdict['LIBPATH'].extend(context.env['LIBPATH'])
-            st =_check_include_and_run(context, 'LAPACK (MKL)', [], [],
-                    test_src, fdict['LIBS'], fdict['LIBPATH'], [], [], autoadd = 1)
-            add_info(env, 'lapack', opt_info('mkl'))
-            return st
-
-        # Check ATLAS
-        st = CheckATLAS(context, autoadd = 1)
-        if st:
-            fdict = env.ParseFlags(context.env['F77_LDFLAGS'])
-            fdict['LIBS'].append('lapack')
-            if env.has_key('LIBS'):
-                fdict['LIBS'].extend(context.env['LIBS'])
-            if env.has_key('LIBPATH'):
-                fdict['LIBPATH'].extend(context.env['LIBPATH'])
-            st =_check_include_and_run(context, 'LAPACK (ATLAS)', [], [],
-                    test_src, fdict['LIBS'], fdict['LIBPATH'], [], [], autoadd = 1)
-            add_info(env, 'lapack', opt_info('atlas'))
-            # XXX: Check complete LAPACK or not
-            return st
-
-    return 0
-
-def _my_try_link(context, src, libs, libpath, autoadd = 0):
-    """Try to link the given text in src with libs and libpath."""
-    env = context.env
-
-    oldLIBS = (env.has_key('LIBS') and deepcopy(env['LIBS'])) or []
-    oldLIBPATH = (env.has_key('LIBPATH') and deepcopy(env['LIBPATH'])) or []
-
-    ret = 0
-    try:
-        env.AppendUnique(LIBS = libs, LIBPATH = libpath)
-        ret = context.TryLink(src, '.c')
-    finally:
-        if not ret or not autoadd:
-            env.Replace(LIBS = oldLIBS, LIBPATH = oldLIBPATH)
-
-    return ret
-
-def CheckGenericBLAS(context, autoadd = 1, section = 'blas'):
-    """Check whether a BLAS library can be found.
-
-    Use site.cfg if found (section given by section argument)."""
-    siteconfig, cfgfiles = get_config()
-    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
-    if not found:
-        libs.extend(['blas'])
-
-    env = context.env
-    # Get fortran mangling
-    if not env.has_key('F77_NAME_MANGLER'):
-        if not CheckF77Mangling(context):
-            return 0
-
-    test_func_name = env['F77_NAME_MANGLER']('dgemm')
-    src = get_func_link_src(test_func_name)
-
-    context.Message("Checking for Generic BLAS... ")
-
-    st =  _my_try_link(context, src, libs, libpath, autoadd)
-    if st:
-        env['F77_BLAS_LIBS'] = libs
-        env['F77_BLAS_LIBPATH'] = libpath
-
-    context.Result(st)
-
-    return st
-
-def CheckGenericLAPACK(context, autoadd = 1, section = 'lapack'):
-    """Check whether a LAPACK library can be found.
-
-    Use site.cfg if found (section given by section argument)."""
-    siteconfig, cfgfiles = get_config()
-    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
-    if not found:
-        libs.extend(['lapack'])
-
-    env = context.env
-    # Get fortran mangling
-    if not env.has_key('F77_NAME_MANGLER'):
-        if not CheckF77Mangling(context):
-            return 0
-
-    test_func_name = env['F77_NAME_MANGLER']('dpotri')
-    src = get_func_link_src(test_func_name)
-
-    context.Message("Checking for Generic LAPACK... ")
-
-    st =  _my_try_link(context, src, libs, libpath, autoadd)
-    if st:
-        env['F77_LAPACK_LIBS'] = libs
-        env['F77_LAPACK_LIBPATH'] = libpath
-
-    context.Result(st)
-
-    return st



More information about the Numpy-svn mailing list