/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 403 by johnpye, Sat Apr 1 00:46:46 2006 UTC revision 404 by johnpye, Sat Apr 1 05:37:52 2006 UTC
# Line 75  opts.Add( Line 75  opts.Add(
75      'SWIG'      'SWIG'
76      ,"SWIG location, probably only required for MinGW and MSVC users."      ,"SWIG location, probably only required for MinGW and MSVC users."
77          +" Enter the location as a Windows-style path, for example"          +" Enter the location as a Windows-style path, for example"
78          +" 'c:\msys\1.0\home\john\swigwin-1.3.29\swig.exe'."          +" 'c:\\msys\\1.0\\home\\john\\swigwin-1.3.29\\swig.exe'."
79  )  )
80    
81  # Build the test suite?  # Build the test suite?
# Line 94  opts.Add(PackageOption( Line 94  opts.Add(PackageOption(
94      ,"off"      ,"off"
95  ))  ))
96    
97  # Where are the CUnit includes?  # Where are the CUnit libraries?
98  opts.Add(PackageOption(  opts.Add(PackageOption(
99      'CUNIT_LIBPATH'      'CUNIT_LIBPATH'
100      ,"Where are your CUnit include files?"      ,"Where are your CUnit libraries?"
101      ,"off"      ,"off"
102  ))  ))
103    
104    # Where are the Tcl includes?
105    opts.Add(PackageOption(
106        'TCL_CPPPATH'
107        ,"Where are your Tcl include files?"
108        ,None
109    ))
110    
111    # Where are the Tcl libs?
112    opts.Add(PackageOption(
113        'TCL_LIBPATH'
114        ,"Where are your Tcl libraries?"
115        ,None
116    ))
117    
118    
119  # TODO: OTHER OPTIONS?  # TODO: OTHER OPTIONS?
120    
121  # TODO: flags for optimisation  # TODO: flags for optimisation
# Line 179  def CheckSwigVersion(context): Line 194  def CheckSwigVersion(context):
194  #----------------  #----------------
195  # General purpose library-and-header test  # General purpose library-and-header test
196    
197    class KeepContext:
198        def __init__(self,context,varprefix):
199            self.keep = {}
200            for k in ['LIBS','LIBPATH','CPPPATH']:
201                if context.env.has_key(k):
202                    self.keep[k] = context.env[k]
203            
204            libpath_add = []
205            if context.env.has_key(varprefix+'_LIBPATH'):
206                libpath_add = [env[varprefix+'_LIBPATH']]
207    
208            cpppath_add = []
209            if context.env.has_key(varprefix+'_CPPPATH'):
210                cpppath_add = [env[varprefix+'_CPPPATH']]
211    
212        def restore(self,context):
213            for k in self.keep:
214                context.env[k]=self.keep[k];
215    
216  def CheckExtLib(context,libname,text,ext='.c',varprefix=None):  def CheckExtLib(context,libname,text,ext='.c',varprefix=None):
217      """This method will check for variables LIBNAME_LIBPATH      """This method will check for variables LIBNAME_LIBPATH
# Line 191  def CheckExtLib(context,libname,text,ext Line 224  def CheckExtLib(context,libname,text,ext
224      if varprefix==None:      if varprefix==None:
225          varprefix = libname.upper()          varprefix = libname.upper()
226            
227      keep = {}      keep = KeepContext(context,varprefix)
     for k in ['LIBS','LIBPATH','CPPPATH']:  
         if context.env.has_key(k):  
             keep[k] = context.env[k]  
       
     libpath_add = []  
     if context.env.has_key(varprefix+'_LIBPATH'):  
         libpath_add = [env[varprefix+'_LIBPATH']]  
   
     cpppath_add = []  
     if context.env.has_key(varprefix+'_CPPPATH'):  
         cpppath_add = [env[varprefix+'_CPPPATH']]  
228            
229      context.env.Append(      context.env.Append(
230          LIBS = libname          LIBS = libname
231          , LIBPATH = libpath_add          , LIBPATH = libpath_add
232          , CPPPATH = cpppath_add          , CPPPATH = cpppath_add
233      )      )
     ret = context.TryLink(cunit_test_text,ext)  
234    
235      for k in keep:      is_ok = context.TryLink(text,ext)
236          context.env[k]=keep[k];  
237        keep.restore()
238    
239      context.Result( ret )      context.Result(is_ok)
240      return ret      return is_ok
241    
242    #----------------
243    # CUnit test
244    
245  cunit_test_text = """  cunit_test_text = """
246  #include <CUnit/Cunit.h>  #include <CUnit/Cunit.h>
# Line 231  void test_maxi(void){ Line 256  void test_maxi(void){
256  }  }
257  int main(void){  int main(void){
258  /*  CU_initialize_registry() */  /*  CU_initialize_registry() */
259        return 0;
260  }  }
261  """  """
262    
263  def CheckCUnit(context):  def CheckCUnit(context):
264      return CheckExtLib(context      return CheckLib(context
265          ,'cunit'          ,'cunit'
266          ,cunit_test_text          ,cunit_test_text
267      )      )
268    
269    #----------------
270    # Tcl/Tk test
271    
272    tcl_check_text = r"""
273    #include <tcl.h>
274    #include <stdio.h>
275    int main(void){
276        printf("%s",TCL_PATCH_LEVEL);
277        return 0;
278    }
279    """
280    
281    tcl_test_text = open('checktcl.c').read()
282    
283    def CheckTcl(context):
284        keep = KeepContext(context,'TCL')
285        context.Message("Checking for Tcl library... ")
286        is_ok = context.TryLink(tcl_check_text,'.c')
287        context.Result(is_ok)
288        keep.restore(context)
289        if not is_ok:
290            return 0
291        return 1
292    
293    def CheckTclVersion(context):
294        keep = KeepContext(context,'TCL')
295        context.Message("Checking Tcl version... ")
296        (is_ok,output) = context.TryRun(tcl_check_text,'.c')
297        keep.restore(context)
298        if not is_ok:
299            context.Result("failed to run check")
300            return 0
301        context.Result(output)
302    
303        major,minor,patch = tuple(int(i) for i in output.split("."))
304        if major != 8 or minor > 3:
305            # bad version
306            return 0
307                    
308        # good version
309        return 1
310        
311  #------------------------------------------------------  #------------------------------------------------------
312  # CONFIGURATION  # CONFIGURATION
313    
# Line 248  conf = Configure(env Line 315  conf = Configure(env
315      , custom_tests = {      , custom_tests = {
316          'CheckSwigVersion' : CheckSwigVersion          'CheckSwigVersion' : CheckSwigVersion
317          , 'CheckCUnit' : CheckCUnit          , 'CheckCUnit' : CheckCUnit
318            , 'CheckTcl' : CheckTcl
319            , 'CheckTclVersion' : CheckTclVersion
320  #       , 'CheckIsNan' : CheckIsNan  #       , 'CheckIsNan' : CheckIsNan
321  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig
322      }      }
# Line 270  if not conf.CheckFunc('isnan'): Line 339  if not conf.CheckFunc('isnan'):
339      Exit(1)      Exit(1)
340    
341  # Tcl/Tk  # Tcl/Tk
 if not conf.CheckHeader('tcl.h'):  
     with_tcltk_gui = False  
342    
343  if not conf.CheckHeader('tk.h'):  if conf.CheckTcl():
344      with_tcltk_gui = False      if with_tcltk_gui and not conf.CheckTclVersion():
345            print "Wrong Tcl version used. Please specify you 8.3 Tcl installation"\
346                +" via the TCL_CPPPATH and TCL_LIBPATH options, or use"\
347                +" WITHOUT_TCLTK_GUI=1 to prevent build of Tcl/Tk components.\n"
348            with_tcltk_gui = False
349    
350  if not conf.CheckLib('tcl'):  if with_tcltk_gui and not conf.CheckHeader('tk.h'):
351      with_tcltk_gui = False      with_tcltk_gui = False
352    
353  if not conf.CheckLib('tk'):  if with_tcltk_gui and not conf.CheckLib('tk'):
354      with_tcktk_gui = False      with_tcktk_gui = False
355    
356  # Python... obviously we're already running python, so we just need to  # Python... obviously we're already running python, so we just need to
# Line 317  else: Line 388  else:
388  # CUnit  # CUnit
389    
390  if with_cunit_tests:  if with_cunit_tests:
391      conf.CheckCUnit()      if not conf.CheckCUnit():
392            print "CUnit not found. Use 'scons WITH_CUNIT_TESTS=0'"
393            Exit(1)
394    
395  # TODO: -D_HPUX_SOURCE is needed  # TODO: -D_HPUX_SOURCE is needed
396    

Legend:
Removed from v.403  
changed lines
  Added in v.404

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22