示例#1
0
def CheckJPEG(ctx, write_config_h=True):
    ctx.Message('Checking for libjpeg... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']
    lastLIBS = list(ctx.env.get('LIBS', []))

    # "libjpeg" variant is required here because scons seems to remove
    # remove sometimes lib prefix (at least in mingw mode)
    for jpeglib in ('jpeg', 'libjpeg', '"libjpeg"'):
        ctx.env.Append(LIBS = [jpeglib])
        ret = ctx.TryLink("""
    #include <stdio.h>
    #include <jpeglib.h>
    int main(int argc, char **argv) { 
      struct jpeg_decompress_struct cinfo;
      jpeg_destroy_decompress(&cinfo);
      return 0;
    }
""", extension='.c')
        ctx.env.Replace(LIBS = lastLIBS)
        if ret:
            ctx.env.Replace(LIBJPEG=[jpeglib])
            break

    key = confprefix+'HAVE_LIBJPEG'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#2
0
def CheckTIFF(ctx, write_config_h=True):
    ctx.Message('Checking for libtiff... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']
    lastLIBS = list(ctx.env.get('LIBS', []))

    for tifflib in ('tiff', 'libtiff'):
        ctx.env.Append(LIBS = [tifflib])
        ret = ctx.TryLink("""
    #include <stdio.h>
    #include <tiffio.h>
    int main(int argc, char **argv) {
      TIFF *tif;
      tif = TIFFOpen("test","r");
      TIFFClose(tif);
      return 0;
    }
""", extension='.c')
        ctx.env.Replace(LIBS = lastLIBS)
        if ret:
            ctx.env.Replace(LIBTIFF=[tifflib])
            break
        
    key = confprefix+'HAVE_LIBTIFF'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret:
            ctx.env.Append(CPPDEFINES=[key])
    
    ctx.Result(ret)
    return ret
示例#3
0
def CheckURayUtils(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for URayUtils header files... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']

    ret = ctx.TryLink("""
    #include "URayUtils/Config/URayConfig.hpp"

    using namespace URay;
    
    int main(int argc, char **argv) {
      uint32 i = 0;
      return 0;
    }
""",
                      extension='.cpp')

    key = confprefix + 'HAVE_URAY_UTILS'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#4
0
def CheckRTfactRTpie(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for delicious RTfact Pie header files... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_RTFACT_REMOTE'

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS CCFLAGS')

    rtpieLIBS = ['RTfactRTpie']
    if compiler == 'GCC' or (compiler == 'INTEL' and not isWin32):
        rtpieCCFLAGS = ['-mmmx', '-msse', '-msse2']
    elif compiler == 'MSVC':
        rtpieCCFLAGS = ['/arch:SSE2']
    else:
        rtpieCCFLAGS = []

    ctx.env.Append(LIBS=rtpieLIBS)
    ctx.env.Append(CCFLAGS=rtpieCCFLAGS)

    ret = ctx.TryLink("""
#include "RTpie/IRayTracer.hpp"

using namespace RTfact::RTpie;
    
int main(int argc, char **argv) {
  IRayTracer *r;
  HRESULT rv = CreateRayTracer(&r);
  if(SUCCEEDED(rv)){
  	r->Release();
  }
  return 0;
}
""",
                      extension='.cpp')

    if ret:
        ctx.env.DeclarePackage('rtpie',
                               LIBS=rtpieLIBS,
                               dependencies=[],
                               vars={
                                   'CPPDEFINES': [key],
                                   'CCFLAGS': rtpieCCFLAGS
                               },
                               trigger_libs=['RTfactRTpie'],
                               trigger_frameworks=['RTfactRTpie'])

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#5
0
def CheckSDL(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for SDL... ')
    confprefix = getAutoconfPrefix(ctx.env)
    platform = ctx.env['PLATFORM']

    if platform == 'win32':
        savedVars = ctx.env.SaveVars('LIBS')

        if ctx.env.IsMSVC_Debug():
            sdllibs = ['SDLd', 'SDLmaind']
        else:
            sdllibs = ['SDL', 'SDLmain']

        ctx.env.Append(LIBS=sdllibs)
        ret = ctx.TryLink("""
            #include <SDL.h>
            int main(int argc, char **argv)
            {
                SDL_Init(SDL_INIT_VIDEO);
                SDL_Quit();
                return 0;
            }
            """,
                          extension='.c')

        ctx.env.RestoreVars(savedVars)

        if ret:
            ctx.env.DeclarePackage('sdl',
                                   trigger_libs=['SDL', 'SDLmain'],
                                   trigger_frameworks=['SDL'],
                                   LIBS=sdllibs)
            ctx.env.Replace(LIBSDL=sdllibs)
    else:
        ret, output = ctx.TryAction('sdl-config --version')
        if ret:

            vars = ctx.env.ParseFlags('!sdl-config --cflags --libs')

            ctx.env.DeclarePackage('sdl',
                                   vars=vars,
                                   trigger_libs=['SDL', 'SDLmain'],
                                   trigger_frameworks=['SDL'])

            if add_to_compiler_env:
                ctx.env.Append(CPPPATH=vars.get('CPPPATH'))
                ctx.env.Append(LIBPATH=vars.get('LIBPATH'))
            ctx.env.Replace(LIBSDL=vars.get('LIBS'))

    key = confprefix + 'HAVE_LIBSDL'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
def CheckBoostRegex(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for Boost Regex Library... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_BOOST_REGEX'

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS')

    ret = 0

    code = """
        #include <boost/regex.hpp>
        int main(int argc, char** argv) {
            const boost::regex e("\\\\d{2}");
            return boost::regex_match("12", e);
        }
"""

    # On Windows MSVC and Intel compiler automatically find out the correct
    # library name.
    if isWin32 and compiler in ('MSVC', 'INTEL', 'INTEL_NOGCC'):
        boost_regex_libs = []
        ret = ctx.TryLink(code, extension='.cpp')
    else:
        for lib in ('boost_regex-mt', 'boost_regex'):
            boost_regex_libs = [lib]

            ctx.env.AppendUnique(LIBS=boost_regex_libs)

            ret = ctx.TryLink(code, extension='.cpp')

            ctx.env.RestoreVars(savedVars)

            if ret:
                break

    if ret:
        ctx.env.DeclarePackage('boost_regex',
                               LIBS=boost_regex_libs,
                               dependencies=[],
                               vars={'CPPDEFINES': [key]},
                               trigger_libs=['boost_regex'],
                               trigger_frameworks=['boost_regex'])

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#7
0
def CheckSpiderMonkey(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for Mozilla SpiderMonkey...')
    confprefix = getAutoconfPrefix(ctx.env)

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS CCFLAGS')

    # FIXME: Detection should work independently of DevEnv
    # find SpiderMonkey relative to DevEnv
    SPIDERMONKEY_PATH = '../../js-1.8.0-rc1/src'
    SPIDERMONKEY_OBJ_PATH = SPIDERMONKEY_PATH + '/Linux_All_DBG.OBJ'

    smCCFLAGS = ['-DXP_UNIX']
    smLIBS = ['js', 'm']
    #smCPPPATH = [SPIDERMONKEY_PATH, SPIDERMONKEY_OBJ_PATH]
    #smLIBPATH = [SPIDERMONKEY_OBJ_PATH]

    # add paths
    # TODO I think this should be a package
    ctx.env.Append(LIBS=smLIBS)
    ctx.env.Append(CCFLAGS=smCCFLAGS)

    ret = ctx.TryLink("""
    #include <jsatom.h>

int main(int argc, char **argv) {
  JSString *jsString;
  JSAtom *jsAtom;
  return 0;
}
""",
                      extension='.c')
    if ret:
        ctx.env.DeclarePackage('spidermonkey',
                               LIBS=smLIBS,
                               dependencies=[],
                               vars={'CCFLAGS': smCCFLAGS},
                               trigger_libs=['spidermonkey', 'js'],
                               trigger_frameworks=['spidermonkey', 'js'])

    ctx.env.RestoreVars(savedVars)

    key = confprefix + 'HAVE_SPIDERMONKEY'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#8
0
def CheckRTSG_OpenRT(ctx, write_config_h=False, add_to_compiler_env=False):
    # We assume here that RTSG is available
    ctx.Message('Checking for RTSG/OpenRT library... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']

    OPENRT_INCLUDE_DIR = ctx.env.get('OPENRT_INCLUDE_DIR', '')

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS LIBPATH CPPPATH')

    if ctx.env.GetPackage('rtsg'):
        ctx.env.RequirePackage('rtsg')

    rtsgopenrtlibs = ['rtsgortext']

    ctx.env.Append(LIBS=rtsgopenrtlibs)
    ctx.env.Append(CPPPATH=OPENRT_INCLUDE_DIR)
    ret = ctx.TryLink("""
        #include <openrt/rt.h>
        #include <openrt/types.h>
        #include <rtsg/ortext/OpenRTRenderer.hpp>
        int main(int argc, char **argv) {
            ortext::OpenRTRenderer *r = 0;
            return 0;
        }
""",
                      extension='.cpp')

    ctx.env.RestoreVars(savedVars)

    if ret:
        ctx.env.DeclarePackage('rtsg_openrt',
                               LIBS=[rtsgopenrtlibs],
                               CPPPATH=[OPENRT_INCLUDE_DIR],
                               dependencies=['rtsg'],
                               trigger_libs=[
                                   'RTSG_OpenRT', 'rtsg_openrt', 'rtsgort',
                                   'rtsgortext'
                               ],
                               trigger_frameworks=['RTSG_OpenRT'])
        ctx.env.Replace(LIBRTSGOPENRT=rtsgopenrtlibs)

    key = confprefix + 'HAVE_LIBRTSG_OPENRT'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#9
0
def CheckSSE3(ctx, write_config_h=False):
    ctx.Message('Checking for SSE3 availability... ')
    confprefix = getAutoconfPrefix(ctx.env)
    
    has_sse3 = cpu.has_sse3() is not None
    
    key = confprefix + 'HAVE_SSE3'
    if not (write_config_h and AddConfigKey(ctx, key, has_sse3)):
        # no config file is specified or it is disabled, use compiler options
        if has_sse3:
            ctx.env.Append(CPPDEFINES=[key])
    
    ctx.Result(has_sse3)
        
    return has_sse3
示例#10
0
def CheckPNG(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for libpng... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']
    lastLIBS = list(ctx.env.get('LIBS', []))

    if platform == 'win32':
        if ctx.env.IsMSVC_Debug():
            ZLIB = ['zlibd']
            pngLibNames = ['pngd']
        else:
            ZLIB = ['zlib']
            pngLibNames = ['png', 'libpng', '"libpng"']
    else:
        ZLIB = ['z']
        pngLibNames = ['png', 'libpng', '"libpng"']

    ret = 0
    # "libpng" variant is required here because scons seems to remove
    # remove sometimes lib prefix (at least in mingw mode)
    #for pnglib in ('png', 'libpng', '"libpng"'):
    for pnglib in pngLibNames:
        for includeDir in ('', 'libpng/'):
            ctx.env.Append(LIBS=[pnglib] + ZLIB)
            ret = ctx.TryLink("""
                #include <%spng.h>
                int main(int argc, char **argv) {
                  png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
                  return 0;
                }
""" % includeDir,
                              extension='.c')
            ctx.env.Replace(LIBS=lastLIBS)
            if ret:
                ctx.env.Replace(LIBPNG=[pnglib] + ZLIB)
                break
        if ret:
            break

    key = confprefix + 'HAVE_LIBPNG'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#11
0
def CheckSDLTTF(ctx, write_config_h=False, add_to_compiler_env=False):
    # We assume here that SDL is available
    ctx.Message('Checking for SDL_ttf... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']

    savedLIBS = ctx.env.SaveVars('LIBS')

    sdllibs = ctx.env.get('LIBSDL', [])
    sdlttflibs = ['SDL_ttf']

    savedVars = None
    if ctx.env.GetPackage('sdl'):
        savedVars = ctx.env.RequirePackage('sdl')

    ctx.env.Append(LIBS=sdlttflibs + sdllibs)
    ret = ctx.TryLink("""
        #include <SDL_ttf.h>
        int main(int argc, char **argv) {
            TTF_Init();
            TTF_Quit();
            return 0;
        }
        """,
                      extension='.c')

    ctx.env.RestoreVars(savedLIBS)

    if savedVars:
        ctx.env.RestoreVars(savedVars)

    if ret:
        ctx.env.DeclarePackage('sdlttf',
                               vars={'LIBS': sdlttflibs},
                               dependencies='sdl',
                               trigger_libs=['SDL_ttf'])
        ctx.env.Replace(LIBSDLTTF=sdlttflibs)

    key = confprefix + 'HAVE_LIBSDL_TTF'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#12
0
def CheckXflow(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for Xflow library... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_XFLOW'

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS CCFLAGS')

    xflowLIBS = ['DFC', 'Xflow']
    xflowCCFLAGS = []

    ctx.env.Append(LIBS=xflowLIBS)
    ctx.env.Append(CCFLAGS=xflowCCFLAGS)

    ret = ctx.TryLink("""
#include <Xflow/Graph/Graph.hpp>

int main(int argc, char **argv) {
  Xflow::Graph::Ptr graph = new Xflow::Graph();
  return 0;
}
""",
                      extension='.cpp')

    if ret:
        ctx.env.DeclarePackage('xflow',
                               LIBS=xflowLIBS,
                               dependencies=['dfccdd'],
                               vars={
                                   'CPPDEFINES': [key],
                                   'CCFLAGS': xflowCCFLAGS
                               },
                               trigger_libs=['Xflow'],
                               trigger_frameworks=['Xflow'])

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#13
0
def CheckOpenCL(ctx,
                write_config_h=False,
                add_to_compiler_env=False,
                min_version=None,
                max_version=None):
    ctx.Message('Checking for OpenCL Library... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']

    if min_version is not None:
        min_version = Version(min_version)
    if max_version is not None:
        max_version = Version(max_version)

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS CPPPATH')

    ret = 0
    ctx.env.Append(LIBS=['OpenCL'])
    ret, outputStr = ctx.TryRun("""
   #include <CL/cl.h>

   int main(int argc, char** argv)
   {
   cl_uint numEntries=2;
   cl_platform_id platforms[2];
   cl_uint numPlatforms;

   clGetPlatformIDs(numEntries,
              (cl_platform_id*) platforms,
              &numPlatforms);

   printf("%d", CL_VERSION_1_0);
   return 0;
   }
   """,
                                extension='.c')

    ctx.env.RestoreVars(savedVars)

    # define
    # if ret:
    #   key = confprefix + 'HAVE_OPENCL'

    ctx.Result(ret)
    return ret
示例#14
0
def CheckImageMagick(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for ImageMagick... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_LIBMAGICK'

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    varNames = 'LIBS FRAMEWORKS CPPPATH CCFLAGS CXXFLAGS LINKFLAGS'
    varNamesList = ctx.env.Split(varNames)

    savedVars = ctx.env.SaveVars(varNames)

    ret, output = ctx.TryAction('Magick-config --version')
    if ret:
        # removed --cflags due to the problems with some options:
        #                  conflicts between icc and g++ options

        # Reset all flags so we can find everything what is changed
        for var in varNamesList:
            ctx.env[var] = []

        ctx.env.ParseConfig('Magick-config --cppflags --ldflags --libs')
        if ctx.env.get('CCFLAGS'):
            ctx.env['CCFLAGS'] = filterOut('-no-undefined', ctx.env['CCFLAGS'])

        vars = {}
        for var in varNamesList:
            vars[var] = ctx.env[var]

        package = ctx.env.DeclarePackage(
            'magick',
            vars=vars,
            trigger_libs=['magick', 'Magick', 'MagickCore', 'ImageMagick'])

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#15
0
def CheckJitRT(ctx, write_config_h=False, add_to_cppdefines=False):
    ctx.Message('Checking for jitRT library... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']

    haveLLVM = ctx.env.GetPackage('llvm')

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS')

    jitrtlibs = ['jitRT']

    ctx.env.Append(LIBS=jitrtlibs)

    ret = ctx.TryLink("""
#include <jitRT/llvmWrapper.h>

int main(int argc, char **argv)
{
    llvm::Module* mod = jitRT::createModuleFromFile("file");
    return 0;
}
""",
                      extension='.cpp')

    ctx.env.RestoreVars(savedVars)

    if ret:
        ctx.env.DeclarePackage('jitrt',
                               vars={
                                   'LIBS': jitrtlibs,
                                   'CPPDEFINES': confprefix + 'HAVE_ANYSL'
                               },
                               trigger_libs=['jitrt', 'jitRT'],
                               trigger_frameworks=['jitRT'])

    key = confprefix + 'HAVE_ANYSL'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_cppdefines:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#16
0
def CheckOpenSSL(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for OpenSSL... ')
    confprefix = getAutoconfPrefix(ctx.env)
    platform = ctx.env['PLATFORM']

    savedVars = ctx.env.SaveVars('LIBS')

    if platform == 'win32':
        if ctx.env.IsMSVC_Debug():
            libs = ['libeay32', 'ssleay32']
        else:
            libs = ['libeay32', 'ssleay32']
    else:
        libs = ['ssl', 'crypto']

    ctx.env.Append(LIBS=libs)
    ret = ctx.TryLink("""
        #include <openssl/ssl.h>
        int main(int argc, char **argv)
        {
            SSL_load_error_strings();
            SSL_library_init ();
            return 0;
        }
        """,
                      extension='.c')

    ctx.env.RestoreVars(savedVars)

    if ret:
        ctx.env.DeclarePackage('openssl',
                               trigger_libs=['ssl', 'openssl', 'OpenSSL'],
                               trigger_frameworks=['OpenSSL'],
                               LIBS=libs)

    key = confprefix + 'HAVE_OPENSSL'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#17
0
def CheckCurl(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for libcurl... ')
    confprefix = getAutoconfPrefix(ctx.env)
    platform = ctx.env['PLATFORM']

    savedVars = ctx.env.SaveVars('LIBS')

    if platform == 'win32':
        if ctx.env.IsMSVC_Debug() :
            libs = ['libcurl_imp']
        else:
            libs = ['libcurl_imp']
    else:
        libs = ['curl']

    ctx.env.Append(LIBS = libs)
    ret = ctx.TryLink("""
        #include <curl/curl.h>
        int main(int argc, char **argv)
        {
            CURL * curlHandle = curl_easy_init();
            curl_easy_cleanup(curlHandle);
            return 0;
        }
        """, extension='.c')

    ctx.env.RestoreVars(savedVars)

    if ret:
        ctx.env.DeclarePackage('curl',
                               trigger_libs=['curl', 'Curl'],
                               trigger_frameworks=['Curl'],
                               LIBS = libs)

    key = confprefix+'HAVE_CURL'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#18
0
def CheckOpenFI(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for openFI library ... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_OPENFI'

    platform = ctx.env['PLATFORM']

    savedVars = ctx.env.SaveVars('LIBS')

    if platform == 'win32' and ctx.env.IsMSVC_Debug():
        openFILibs = ['openFId']
    else:
        openFILibs = ['openFI']

    ctx.env.Append(LIBS=openFILibs)

    ret = ctx.TryLink("""
#include <xiot/FIEncoder.h>

int main(int argc, char **argv) {
  FI::FIEncoder enc;
  enc.reset();

  return 0;
}
""",
                      extension='.cpp')

    if ret:
        ctx.env.DeclarePackage('openfi',
                               LIBS=openFILibs,
                               trigger_libs=['openFI'])

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#19
0
def CheckImageMagick(ctx, write_config_h=True):
    ctx.Message('Checking for ImageMagick... ')
    confprefix = getAutoconfPrefix(ctx.env)
    
    ret, output = ctx.TryAction('Magick-config --version')
    if ret:
        # removed --cflags due to the problems with some options:
        #                  conflicts between icc and g++ options
        ctx.env.ParseConfig('Magick-config --cppflags --ldflags')
        if ctx.env.get('CCFLAGS'):
            ctx.env['CCFLAGS'] = filterOut('-no-undefined', ctx.env['CCFLAGS'])

    key = confprefix+'HAVE_LIBMAGICK'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret:
            ctx.env.Append(CPPDEFINES=[key])
    
    ctx.Result(ret)
    return ret
示例#20
0
def CheckRTSG_OpenRT(ctx, write_config_h=True):
    # We assume here that RTSG is available
    ctx.Message('Checking for RTSG/OpenRT library... ')
    confprefix = getAutoconfPrefix(ctx.env)
    
    platform = ctx.env['PLATFORM']

    OPENRT_INCLUDE_DIR = ctx.env.get('OPENRT_INCLUDE_DIR', '')
    
    lastLIBS = list(ctx.env.get('LIBS', []))
    lastCPPPATH = list(ctx.env.get('CPPPATH', []))
    
    rtsglibs = ['rtsg']
    
    rtsgopenrtlibs = ['rtsgortext']
        
    ctx.env.Append(LIBS = rtsgopenrtlibs + rtsglibs)
    ctx.env.Append(CPPPATH = OPENRT_INCLUDE_DIR)
    ret = ctx.TryLink("""
        #include <openrt/rt.h>
        #include <openrt/types.h>
        #include <rtsg/openrt/OpenRTRenderer.hpp>
        int main(int argc, char **argv) {
            ortext::OpenRTRenderer *r = 0;
            return 0;
        }
""", extension='.cpp')
    ctx.env.Replace(LIBS = lastLIBS)
    ctx.env.Replace(CPPPATH = lastCPPPATH)
    if ret:
        ctx.env.Replace(LIBRTSGOPENRT=rtsgopenrtlibs)
        
    key = confprefix+'HAVE_LIBRTSG_OPENRT'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret:
            ctx.env.Append(CPPDEFINES=[key])
        
    ctx.Result(ret)
    return ret
示例#21
0
def CheckRTfact(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for RTfact library... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']
    compiler = ctx.env['compiler']
    isGCC = (compiler == 'GCC')

    lastCCFLAGS = list(ctx.env.get('CCFLAGS', []))

    if isGCC:
        ctx.env.AppendUnique(CCFLAGS=['-fpermissive'])

    ret = ctx.TryLink("""
    #include "URayUtils/Config/URayConfig.hpp"
    #include "RTfact/Config/Config.hpp"
    #include "RTfact/Concept/Scene.hpp"

    using namespace URay::RTfact;
    using namespace URay;
    
    int main(int argc, char **argv) {
      uint32 i = 0;
      return 0;
    }
""",
                      extension='.cpp')

    key = confprefix + 'HAVE_RTFACT'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.env.Replace(CCFLAGS=lastCCFLAGS)

    ctx.Result(ret)
    return ret
示例#22
0
def CheckGoogleSparseHash(ctx, write_config_h=True, add_to_cppdefines=False):
    ctx.Message('Checking for Google\'s Sparse Hash... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_GOOGLE_SPARSEHASH'

    haveHeaders = ctx.TryLink("""
            #include <google/dense_hash_map>
            #include <google/sparse_hash_map>
            int main(int argc, char** argv) {
                google::dense_hash_map<int, int> map1;
                google::sparse_hash_map<int, int> map2;

                return 0;
            }
            """,
                              extension='.cpp')

    if not (write_config_h and AddConfigKey(ctx, key, haveHeaders)):
        # no config file is specified or it is disabled, use compiler options
        if haveHeaders and add_to_cppdefines:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(haveHeaders)
    return haveHeaders
def CheckBoostProgramOptions(ctx,
                             write_config_h=False,
                             add_to_compiler_env=False):
    ctx.Message('Checking for Boost Program Options Library... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_BOOST_PROGRAM_OPTIONS'

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS')

    ret = 0

    code = """
        #include <boost/program_options.hpp>
        void func() { }

        int main(int argc, char** argv) {
            boost::program_options::options_description desc("Test");
            desc.add_options()
                 ("help", "produce this help message");
            return 0;
        }
"""

    # On Windows MSVC and Intel compiler automatically find out the correct
    # library name.
    if isWin32 and compiler in ('MSVC', 'INTEL', 'INTEL_NOGCC'):
        boost_program_options_libs = []
        ret = ctx.TryLink(code, extension='.cpp')
    else:
        for lib in ('boost_program_options-mt', 'boost_program_options'):
            boost_program_options_libs = [lib]

            ctx.env.AppendUnique(LIBS=boost_program_options_libs)

            ret = ctx.TryLink(code, extension='.cpp')

            ctx.env.RestoreVars(savedVars)

            if ret:
                break

    if ret:
        ctx.env.DeclarePackage('boost_program_options',
                               LIBS=boost_program_options_libs,
                               dependencies=[],
                               vars={'CPPDEFINES': [key]},
                               trigger_libs=['boost_program_options'],
                               trigger_frameworks=['boost_program_options'])

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#24
0
def CheckInImage(ctx, write_config_h=True, add_to_cppdefines=False):
    ctx.Message('Checking for InImage library... ')
    confprefix = getAutoconfPrefix(ctx.env)
    
    platform = ctx.env['PLATFORM']
    ROOT_DIR = ctx.env.GetRootDir()
    INIMAGE_DIST_DIR = ctx.env.GetEnvVar('INIMAGE_DIST_DIR')

    if not INIMAGE_DIST_DIR:
        # is inImage a sub module ?
        p = os.path.join(ROOT_DIR, 'inImage')
        if not os.path.exists(p):
            # is inImage one dir higher ?
            p = os.path.join(ROOT_DIR, '..', 'inImage')

        if os.path.exists(p):
            INIMAGE_DIST_DIR = p
        else:
            INIMAGE_DIST_DIR = None
            ctx.Message('Warning: could not find inImage, you need to define INIMAGE_DIST_DIR environment variable. ')


    if INIMAGE_DIST_DIR:
        
        if platform == 'win32':
            imgLibFile = 'InImage.dll'
        else:
            imgLibFile = 'libInImage.so'

        libDir = os.path.join(INIMAGE_DIST_DIR, 'lib')
        imgLib = os.path.join(libDir, imgLibFile)
        if not os.path.exists(imgLib):
            libDir = os.path.join(INIMAGE_DIST_DIR, 'build', 'lib')
            imgLib = os.path.join(libDir, imgLibFile)
            if not os.path.exists(imgLib):
                ctx.Message('Warning: could not find inImage library %s. ' % (imgLib,))
                if write_config_h:
                    AddConfigKey(ctx, confprefix+'HAVE_LIBINIMAGE', 0)
                ctx.Result(0)
                return 0
                
        incDir = os.path.join(INIMAGE_DIST_DIR, 'include')
        if not os.path.exists(incDir):
            incDir = os.path.join(INIMAGE_DIST_DIR, '..', 'include')
            if not os.path.exists(incDir):
                ctx.Message('Warning: could not find inImage include dir %s. ' % (incDir,))
                if write_config_h:
                    AddConfigKey(ctx, confprefix+'HAVE_LIBINIMAGE', 0)
                ctx.Result(0)
                return 0

        ctx.env.Replace(INIMAGE_LIB_DIR=os.path.abspath(libDir))
        ctx.env.Replace(INIMAGE_INCLUDE_DIR=os.path.abspath(incDir))

        ctx.env.DeclarePackage('inimage',
                               CPPPATH=[os.path.abspath(incDir)],
                               LIBPATH=[os.path.abspath(libDir)],
                               LIBS=['InImage'],
                               trigger_libs=['InImage', 'inimage'])
        
        ret = 1
    else:
        ret = 0

    key = confprefix+'HAVE_LIBINIMAGE'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_cppdefines:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#25
0
def CheckPacketizer(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for Packetizer... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_PACKETIZER'

    platform = ctx.env['PLATFORM']

    # If LLVM is not available Packetizer cannot be used as it linked statically
    # and do not contain any LLVM symbols
    if not ctx.env.GetPackage('llvm'):
        ctx.Message('No LLVM detected')
        if write_config_h:
            AddConfigKey(ctx, key, 0)
        ctx.Result(0)
        return 0

    packetizerlibs = ['Packetizer']

    # RequirePackage('llvm') will add all libraries needed for linking with
    # LLVM and return dictionary of all modified variables with original
    # values.
    savedVars = ctx.env.RequirePackage('llvm')

    # Note: order of adding to LIBS variable is important for static
    # libraries, Packetizer library need to be added before LLVM so
    # LLVM symbols not found in Packetizer library will be found in the
    # LLVM library after it.
    ctx.env.Prepend(LIBS=packetizerlibs)

    ret = ctx.TryLink("""
#define PACKETIZER_STATIC_LIBS
#include <Packetizer/api.h>

int main(int argc, char **argv)
{
    Packetizer::Packetizer* packetizer = Packetizer::getPacketizer(false, false);
    Packetizer::addFunctionToPacketizer(packetizer, "test", "test_simd", 4);
    return 0;
}
""",
                      extension='.cpp')

    ctx.env.RestoreVars(savedVars)

    if ret:
        ctx.env.DeclarePackage('packetizer',
                               vars={
                                   'LIBS': packetizerlibs,
                                   'CPPDEFINES': confprefix + 'HAVE_PACKETIZER'
                               },
                               dependencies='llvm',
                               trigger_libs=['packetizer', 'Packetizer'],
                               trigger_frameworks=['Packetizer'])

        if ctx.env.GetPackage('llvm_shared'):
            ctx.env.DeclarePackage(
                'packetizer_shared',
                vars={
                    'LIBS': packetizerlibs,
                    'CPPDEFINES': confprefix + 'HAVE_PACKETIZER'
                },
                dependencies='llvm_shared',
                trigger_libs=['packetizer_shared', 'Packetizer_shared'],
                trigger_frameworks=['Packetizer_shared'])

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
def CheckBoostPython(ctx, write_config_h=False, add_to_compiler_env=False):
    ctx.Message('Checking for Boost Python Library... ')

    try:
        import distutils.sysconfig
        python_includes = [distutils.sysconfig.get_python_inc()]
        python_libs = ['python'+distutils.sysconfig.get_python_version()]
    except ImportError:
        ctx.Message('No distutils package, use default paths')
        python_includes = []
        python_libs = None
    
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix+'HAVE_BOOST_PYTHON'
    
    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS CPPPATH')

    ret = 0

    code = """
    #include <boost/python.hpp>
    using namespace boost::python;

    char const* greet()
    {
      return "hello, world";
    }

    BOOST_PYTHON_MODULE(hello)
    {
      def("greet", greet);
    }

    // dummy main func
    int main(int argc, char **argv) { }
    """

    def doCheck(python_includes, python_libs, boost_python_libs):
        if boost_python_libs:
            ctx.env.AppendUnique(LIBS = boost_python_libs)

        ctx.env.AppendUnique(CPPPATH = python_includes)
        if python_libs:
            ctx.env.AppendUnique(LIBS=python_libs+boost_python_libs)
            return ctx.TryLink(code, extension='.cpp')
        else:
            return ctx.TryCompile(code, extension='.cpp')


    # MSVC and Intel compiler automatically find out the correct library name
    if compiler not in ('MSVC', 'INTEL', 'INTEL_NOGCC'):
        boost_python_libs_alt = [['boost_python-mt'], ['boost_python']]
    else:
        boost_python_libs_alt = [[]]

    for libs in boost_python_libs_alt:
        boost_python_libs = libs
        ret = doCheck(python_includes, python_libs, boost_python_libs)
        ctx.env.RestoreVars(savedVars)
        if ret:
            break

    if ret:

        vars = {'CPPDEFINES' : [key], 'SHLIBPREFIX' : '',
                'CPPPATH' : python_includes}

        if platform == 'win32':
            vars['SHLIBSUFFIX'] = '.pyd'
        
        ctx.env.DeclarePackage('boost_python', LIBS=boost_python_libs,
                               dependencies=[],
                               vars=vars,
                               trigger_libs=['boost_python'],
                               trigger_frameworks=['boost_python'])

        if python_libs:
            ctx.env.Replace(LIBBOOST_PYTHON=['boost_python'])
            ctx.env.Replace(LIBPYTHON=python_libs)

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])
    
    ctx.Result(ret)
    return ret
示例#27
0
def CheckOgre(ctx,
              write_config_h=False,
              add_to_compiler_env=False,
              min_version=None,
              max_version=None):
    ctx.Message('Checking for Ogre Library... ')
    confprefix = getAutoconfPrefix(ctx.env)

    platform = ctx.env['PLATFORM']

    if min_version is not None:
        min_version = Version(min_version)
    if max_version is not None:
        max_version = Version(max_version)

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS CPPPATH')

    ctx.env.Replace(OGRE_INCLUDES=[])

    ret = 0

    if platform == 'win32':
        # on windows, Ogre include path should be in $PATH
        if ctx.env.IsMSVC_Debug():
            # debug version of library ends with '_d'
            ogreLibName = 'OgreMain_d'
        else:
            ogreLibName = 'OgreMain'
        ctx.env.Append(LIBS=[ogreLibName])
        ret, outputStr = ctx.TryRun("""
            #include <Ogre.h>
            #include <iostream>

            Ogre::Root* makeRoot() { return new Ogre::Root(""); }

            int main(int argc, char** argv)
            {
                std::cout<<OGRE_VERSION_MAJOR<<"."
                         <<OGRE_VERSION_MINOR<<"."
                         <<OGRE_VERSION_PATCH
                         <<std::endl;
                return 0;
            }
            """,
                                    extension='.cpp')

        if ret:
            ogreVersion = Version(outputStr)
            ctx.Message('version %s ' % ogreVersion)

            if ogreVersion.compatible(min_version, max_version):
                ogrePackage = ctx.env.DeclarePackage(
                    'ogre',
                    LIBS=[ogreLibName],
                    OGRE_VERSION=ogreVersion,
                    trigger_libs=['Ogre', 'OgreMain', 'ogre'])
            else:
                ctx.Message('is not within required [%s, %s] version range ' % \
                            (min_version, max_version))
                ret = 0

        ctx.env.RestoreVars(savedVars)

    else:

        # on linux, search in some common locations
        for includeDir in ('', '/usr/include/OGRE', '/usr/local/include/OGRE'):
            ctx.env.Append(LIBS=['OgreMain'])
            ctx.env.Append(CPPPATH=[includeDir])
            ret, outputStr = ctx.TryRun("""
                #include <Ogre.h>

                Ogre::Root* makeRoot() { return new Ogre::Root(""); }

                int main(int argc, char** argv)
                {
                    std::cout<<OGRE_VERSION_MAJOR<<"."
                             <<OGRE_VERSION_MINOR<<"."
                             <<OGRE_VERSION_PATCH
                             <<std::endl;
                    return 0;
                }
                """,
                                        extension='.cpp')

            ctx.env.RestoreVars(savedVars)

            if ret:
                ogreVersion = Version(outputStr)
                ctx.Message('version %s ' % ogreVersion)
                if ogreVersion.compatible(min_version, max_version):
                    ogrePackage = ctx.env.DeclarePackage(
                        'ogre',
                        CPPPATH=[includeDir],
                        LIBS=['OgreMain'],
                        OGRE_VERSION=ogreVersion,
                        trigger_libs=['Ogre', 'OgreMain', 'ogre'])
                    ctx.env.Replace(OGRE_INCLUDES=[includeDir])
                else:
                    ctx.Message(
                        'is not within required [%s, %s] version range ' % \
                        (min_version, max_version))
                    ret = 0
                break

    key = confprefix + 'HAVE_OGRE'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#28
0
def CheckDFC(ctx,
             write_config_h=False,
             add_to_compiler_env=False,
             enable_package_cppdefines=False):
    ctx.Message('Checking for DFC library... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_DFC'

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    haveBoostThread = ctx.env.GetPackage('boost_thread')
    if not haveBoostThread:
        ctx.Message('Warning ! Please check for boost_thread first !')
        savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS CCFLAGS')
    else:
        savedVars = ctx.env.RequirePackage('boost_thread')

    dfcLIBS = ['DFC']
    dfcCCFLAGS = []

    ctx.env.Append(LIBS=dfcLIBS)
    ctx.env.Append(CCFLAGS=dfcCCFLAGS)

    ret = ctx.TryLink("""
#include <DFC/Base/Core/LibraryInit.hpp>

int main(int argc, char **argv) {
  DFC::LibraryInit init;
  return 0;
}
""",
                      extension='.cpp')

    if ret:

        deps = ''
        if haveBoostThread:
            deps += 'boost_thread'

        vars = {'CCFLAGS': dfcCCFLAGS}
        if enable_package_cppdefines:
            vars.update({'CPPDEFINES': [key]})

        ctx.env.DeclarePackage('dfc',
                               LIBS=dfcLIBS,
                               dependencies=deps,
                               vars=vars,
                               trigger_libs=['DFC'],
                               trigger_frameworks=['DFC'])
        ctx.env.DeclarePackage('dfccdd',
                               LIBS=['DFCCDD'],
                               dependencies=['dfc'],
                               vars=vars,
                               trigger_libs=['DFCCDD'],
                               trigger_frameworks=['DFCCDD'])

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
示例#29
0
def CheckAssimp(ctx,
                write_config_h=False,
                add_to_compiler_env=False,
                min_version=None,
                max_version=None):
    ctx.Message('Checking for Assimp library... ')
    confprefix = getAutoconfPrefix(ctx.env)

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    if min_version is not None:
        min_version = Version(min_version)
    if max_version is not None:
        max_version = Version(max_version)

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS CCFLAGS')

    assimpLIBS = ['assimp']
    assimpCCFLAGS = []

    ctx.env.Append(LIBS=assimpLIBS)
    ctx.env.Append(CCFLAGS=assimpCCFLAGS)

    ret, outputStr = ctx.TryRun("""
#include "assimp.h"
#include "aiVersion.h"
#include <stdio.h>  
int main(int argc, char **argv) {
  printf("%i.%i.%i\\n", aiGetVersionMajor(), aiGetVersionMinor(), aiGetVersionRevision());
  return 0;
}
""",
                                extension='.c')

    if ret:
        assimpVersion = Version(outputStr.strip())
        ctx.Message('version %s ' % assimpVersion)

        if assimpVersion.compatible(min_version, max_version):
            ctx.env.DeclarePackage('assimp',
                                   LIBS=assimpLIBS,
                                   ASSIMP_VERSION=assimpVersion,
                                   CCFLAGS=assimpCCFLAGS,
                                   trigger_libs=['assimp'],
                                   trigger_frameworks=['assimp'])
        else:
            ctx.Message('is not within required [%s, %s] version range ' % \
                        (min_version, max_version))

            ret = 0

    ctx.env.RestoreVars(savedVars)

    key = confprefix + 'HAVE_ASSIMP'
    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret
def CheckBoostSerialization(ctx,
                            write_config_h=False,
                            add_to_compiler_env=False,
                            enable_package_cppdefines=False):
    ctx.Message('Checking for Boost Serialization Library... ')
    confprefix = getAutoconfPrefix(ctx.env)
    key = confprefix + 'HAVE_BOOST_SERIALIZATION'

    compiler = ctx.env['compiler']
    platform = ctx.env['PLATFORM']
    isWin32 = (platform == 'win32')

    savedVars = ctx.env.SaveVars('LIBS FRAMEWORKS')

    ret = 0

    code = """
        #include <fstream>
        #include <boost/archive/text_oarchive.hpp>
        #include <boost/archive/text_iarchive.hpp>
        int main(int argc, char** argv)
        {
          std::ofstream ofs("filename");
          {
            boost::archive::text_oarchive oa(ofs);
            double d = 2.0;
            oa << d;
          }
          return 0;
        }
"""

    # On Windows MSVC and Intel compiler automatically find out the correct
    # library name.
    if isWin32 and compiler in ('MSVC', 'INTEL', 'INTEL_NOGCC'):
        boost_serialization_libs = []
        ret = ctx.TryLink(code, extension='.cpp')
    else:
        for lib in ('boost_serialization-mt', 'boost_serialization'):
            boost_serialization_libs = ctx.env.Split(lib)

            ctx.env.AppendUnique(LIBS=boost_serialization_libs)

            ret = ctx.TryLink(code, extension='.cpp')

            ctx.env.RestoreVars(savedVars)

            if ret:
                break

    if ret:
        vars = {}
        if enable_package_cppdefines:
            vars.update({'CPPDEFINES': [key]})
        ctx.env.DeclarePackage('boost_serialization',
                               LIBS=boost_serialization_libs,
                               dependencies=[],
                               vars=vars,
                               trigger_libs=['boost_serialization'],
                               trigger_frameworks=['boost_serialization'])

    ctx.env.RestoreVars(savedVars)

    if not (write_config_h and AddConfigKey(ctx, key, ret)):
        # no config file is specified or it is disabled, use compiler options
        if ret and add_to_compiler_env:
            ctx.env.Append(CPPDEFINES=[key])

    ctx.Result(ret)
    return ret