Back to index

radiance  4R0+20100331
find_libs.py
Go to the documentation of this file.
00001 import os
00002 
00003 from SCons.SConf import SConf # aka Configure
00004 
00005 def find_radlib(env):
00006        v = env.FindFile('Verdana.fnt', './lib')
00007        if not v:
00008               print '''
00009        Radiance auxiliary support files not found.
00010        -> Download from radiance-online.org and extract.
00011        '''
00012               env.Exit()
00013 
00014 def find_x11(env):
00015        # Search for libX11, remember the X11 library and include dirs
00016        for d in ('/usr/X11R6', '/usr/X11', '/usr/openwin'):
00017               if os.path.isdir (d):
00018                      incdir = os.path.join(d, 'include')
00019                      libdir = os.path.join(d, 'lib')
00020                      env.Prepend(CPPPATH=[incdir]) # add temporarily
00021                      env.Prepend(LIBPATH=[libdir]) 
00022                      conf = SConf(env)
00023                      if conf.CheckLibWithHeader('X11', 'X11/X.h', 'C', autoadd=0):
00024                             env.Replace(X11INCLUDE=incdir)
00025                             env.Replace(X11LIB=libdir)
00026                      env['CPPPATH'].remove(incdir) # not needed for now
00027                      env['LIBPATH'].remove(libdir)
00028                      if env['X11INCLUDE']:
00029                             # Check for SGI stereo extension
00030                             if conf.CheckCHeader('X11/extensions/SGIStereo.h'):
00031                                    env['RAD_STEREO'] = '-DSTEREO'
00032                             else: env['RAD_STEREO'] = '-DNOSTEREO'
00033                             env = conf.Finish ()
00034                             break
00035                      env = conf.Finish ()
00036 
00037 
00038 def find_gl(env):
00039        # Check for libGL, set flag
00040        dl = [(None,None)] # standard search path
00041        if env.has_key('X11INCLUDE'): # sometimes found there (Darwin)
00042               dl.append((env['X11INCLUDE'], env['X11LIB']))
00043        for incdir, libdir in dl:
00044               if incdir: env.Prepend(CPPPATH=[incdir]) # add temporarily
00045               if libdir: env.Prepend(LIBPATH=[libdir])
00046               conf = SConf(env)
00047               if conf.CheckLibWithHeader('GL', 'GL/gl.h', 'C', autoadd=0):
00048                      env['OGL'] = 1
00049               if incdir: env['CPPPATH'].remove(incdir) # not needed for now
00050               if libdir: env['LIBPATH'].remove(libdir)
00051               if env.has_key('OGL'):
00052                      if incdir: env.Replace(OGLINCLUDE=[incdir])
00053                      #if libdir: env.Replace(OGLLIB=[libdir])
00054                      conf.Finish()
00055                      break
00056               conf.Finish()
00057 
00058 
00059 def find_libtiff(env):
00060        # Check for libtiff, set flag and include/lib directories
00061        dl = [ (None,None), ] # standard search path
00062        cfgi = env.get('TIFFINCLUDE')
00063        cfgl = env.get('TIFFLIB')
00064        if cfgi or cfgl:
00065               dl.insert(0,(cfgi, cfgl))
00066        for incdir, libdir in dl:
00067               if incdir: env.Prepend(CPPPATH=[incdir]) # add temporarily
00068               if libdir: env.Prepend(LIBPATH=[libdir])
00069               conf = SConf(env)
00070               if conf.CheckLib('tiff', 'TIFFInitSGILog',
00071                             header='void TIFFInitSGILog(void);', autoadd=0):
00072                      env['TIFFLIB_INSTALLED'] = 1
00073               if incdir: env['CPPPATH'].remove(incdir) # not needed for now
00074               if libdir: env['LIBPATH'].remove(libdir)
00075               if env.has_key('TIFFLIB_INSTALLED'):
00076                      if incdir: env.Replace(RAD_TIFFINCLUDE=[incdir])
00077                      if libdir: env.Replace(RAD_TIFFLIB=[libdir])
00078                      conf.Finish()
00079                      break
00080               conf.Finish()
00081