/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 562 by johnpye, Thu May 4 08:25:01 2006 UTC revision 993 by johnpye, Fri Dec 22 11:03:51 2006 UTC
# Line 1  Line 1 
1  import os, commands, platform, distutils.sysconfig, os.path  import sys, os, commands, platform, distutils.sysconfig, os.path, re
2    
3  version = "0.9.5.90"  version = "0.9.5.104"
4    
5  #------------------------------------------------------  #------------------------------------------------------
6  # OPTIONS  # OPTIONS
# Line 12  opts = Options(['options.cache', 'config Line 12  opts = Options(['options.cache', 'config
12  #print "PLATFORM = ",platform.system()  #print "PLATFORM = ",platform.system()
13    
14  if platform.system()=="Windows":  if platform.system()=="Windows":
15      default_tcl_lib = "tcl83"      default_tcl_lib = "tcl84"
16      default_tk_lib = "tk83"      default_tk_lib = "tk84"
17      default_tktable_lib = "Tktable28"      default_tktable_lib = "Tktable28"
18      default_install_assets = "glade/"      default_install_assets = "glade/"
19      icon_extension = '.png'      icon_extension = '.png'
20      default_tcl = "c:\\Tcl"      default_tcl = "c:\\Tcl"
21      default_tcl_libpath = "$TCL\\bin"      if os.environ.get('MSYSTEM')=="MINGW32":
22            default_tcl_libpath="$TCL\\bin"
23        else:
24            default_tcl_libpath="$TCL\\lib"
25        default_rel_distdir = '.'
26        default_absolute_paths = False
27        
28        default_ida_prefix = "c:\\MinGW"
29        if not os.path.exists(default_ida_prefix):
30            default_ida_prefix = None
31    
32        default_conopt_prefix = "c:\\Program Files\\CONOPT"
33        default_conopt_libpath="$CONOPT_PREFIX"
34        default_conopt_cpppath="$CONOPT_PREFIX"
35        default_conopt_lib="conopt3"
36        default_conopt_envvar="CONOPT_PATH"
37    
38        default_prefix="c:\\MinGW"
39        default_libpath="$DEFAULT_PREFIX\\lib"
40        default_cpppath="$DEFAULT_PREFIX\\include"
41        
42        if not os.path.exists(default_conopt_prefix):
43            default_conopt_prefix = None
44            
45        need_libm = False
46        python_exe = "c:\\Python24\\python.exe"
47        default_with_scrollkeeper=False
48  else:  else:
49      default_tcl_lib = "tcl8.3"      default_tcl_lib = "tcl8.4"
50      default_tk_lib = "tk8.3"      default_tk_lib = "tk8.4"
51      default_tktable_lib = "Tktable2.8"      default_tktable_lib = "Tktable2.8"
52      default_install_assets = "$INSTALL_DATA/ascend/glade/"      default_install_assets = "$INSTALL_ASCDATA/glade/"
53      icon_extension = '.svg'      icon_extension = '.svg'
54      default_tcl = os.path.expanduser("~/activetcl")      default_tcl = '/usr'
55      default_tcl_libpath = "$TCL/lib"          default_tcl_libpath = "$TCL/lib"    
56        default_rel_distdir = '../share/ascend'
57        default_absolute_paths = True
58        default_ida_prefix="/usr/local"
59        default_conopt_prefix="/usr"
60        default_conopt_libpath="$CONOPT_PREFIX/lib"
61        default_conopt_cpppath="$CONOPT_PREFIX/include"
62        default_conopt_lib="consub3"
63        default_conopt_envvar="CONOPT_PATH"
64    
65        default_prefix="/usr"
66        default_libpath="$DEFAULT_PREFIX/lib"
67        default_cpppath="$DEFAULT_PREFIX/include"
68    
69        need_libm = True
70      if not os.path.isdir(default_tcl):      if not os.path.isdir(default_tcl):
71          default_tcl = '/usr'          default_tcl = '/usr'
72        python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"
73        default_with_scrollkeeper=False
74    
75  opts.Add(  opts.Add(
76      'CC'      'CC'
# Line 43  opts.Add( Line 84  opts.Add(
84      ,None      ,None
85  )  )
86    
87    opts.Add(BoolOption(
88        'GCOV'
89        , 'Whether to enable coverage testing in object code'
90        , False
91    ))
92    
93  # Package linking option  # Package linking option
94  opts.Add(EnumOption(  opts.Add(EnumOption(
95      'PACKAGE_LINKING'      'PACKAGE_LINKING'
# Line 60  opts.Add(BoolOption( Line 107  opts.Add(BoolOption(
107  # You can turn off building of Tcl/Tk interface  # You can turn off building of Tcl/Tk interface
108  opts.Add(BoolOption(  opts.Add(BoolOption(
109      'WITH_TCLTK'      'WITH_TCLTK'
110      ,"Set to True if you don't want to build the original Tcl/Tk GUI."      ,"Set to False if you don't want to build the original Tcl/Tk GUI."
111      , True      , True
112  ))  ))
113    
114  # You can turn off the building of the Python interface  # You can turn off the building of the Python interface
115  opts.Add(BoolOption(  opts.Add(BoolOption(
116      'WITH_PYTHON'      'WITH_PYTHON'
117      ,"Set to True if you don't want to build Python wrappers."      ,"Set to False if you don't want to build Python wrappers."
118      , True      , True
119  ))  ))
120    
# Line 76  opts.Add(ListOption( Line 123  opts.Add(ListOption(
123      'WITH_SOLVERS'      'WITH_SOLVERS'
124      ,"List of the solvers you want to build. The default is the minimum that"        ,"List of the solvers you want to build. The default is the minimum that"  
125          +" works."          +" works."
126      ,["QRSLV","CMSLV"]      ,["QRSLV","CMSLV","LSOD","IDA","CONOPT","LRSLV"]
127      ,['QRSLV','MPS','SLV','OPTSQP'      ,['QRSLV','MPS','SLV','OPTSQP'
128          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
129          ,'LSOD','OPTSQP'          ,'LSOD','OPTSQP',"IDA"
130       ]       ]
131  ))  ))
132    
# Line 104  opts.Add( Line 151  opts.Add(
151      'DEFAULT_ASCENDLIBRARY'      'DEFAULT_ASCENDLIBRARY'
152      ,"Set the default value of the ASCENDLIBRARY -- the location where"      ,"Set the default value of the ASCENDLIBRARY -- the location where"
153          +" ASCEND will look for models when running ASCEND"          +" ASCEND will look for models when running ASCEND"
154      ,"$INSTALL_DATA/models"      ,"$INSTALL_ASCDATA/models"
155  )  )
156    
157  # Where is SWIG?  # Where is SWIG?
# Line 117  opts.Add( Line 164  opts.Add(
164    
165  # Build the test suite?  # Build the test suite?
166  opts.Add(BoolOption(  opts.Add(BoolOption(
167      'WITH_CUNIT_TESTS'      'WITH_CUNIT'
168      ,"Whether to build the CUnit tests. Default is off. If set to on,"      ,"You can disable CUnit tests with this option. This will basically stop"
169          +" you must have CUnit installed somewhere that SCons can"          +" SCons from parsing the SConscript files relating to the 'test'"
170          +" find it, or else use the CUNIT_* options to specify."          +" target, which just might make things marginally faster. Probably"
171      ,False          +" you can just ignore this option though. SCons will sniff for Cunit"
172            +" but build the tests only if you specify the 'test' target."
173        ,True
174    ))
175    
176    # Build with MMIO matrix export support?
177    opts.Add(BoolOption(
178        'WITH_MMIO'
179        ,"Include support for exporting matrices in Matrix Market format"
180        ,True
181    ))
182    
183    #----- default paths -----
184    opts.Add(PackageOption(
185        'DEFAULT_PREFIX'
186        ,"Where are most of the shared libraries located on your system?"
187        ,default_prefix
188    ))
189    
190    #------ install location for python extensions ------
191    
192    # (removed for the moment)
193    
194    #------ cunit --------
195    # Where was CUNIT installed?
196    opts.Add(PackageOption(
197        'CUNIT_PREFIX'
198        ,"Where are your CUnit files?"
199        ,"$DEFAULT_PREFIX"
200  ))  ))
201    
202  # Where are the CUnit includes?  # Where are the CUnit includes?
203  opts.Add(PackageOption(  opts.Add(PackageOption(
204      'CUNIT_CPPPATH'      'CUNIT_CPPPATH'
205      ,"Where are your CUnit include files?"      ,"Where are your CUnit include files?"
206      ,'off'      ,"$CUNIT_PREFIX/include"
207  ))  ))
208    
209  # Where are the CUnit libraries?  # Where are the CUnit libraries?
210  opts.Add(PackageOption(  opts.Add(PackageOption(
211      'CUNIT_LIBPATH'      'CUNIT_LIBPATH'
212      ,"Where are your CUnit libraries?"      ,"Where are your CUnit libraries?"
213      ,'off'      ,"$CUNIT_PREFIX/lib"
214  ))  ))
215    
216    #-------- ida -------
217    
218    opts.Add(PackageOption(
219        "IDA_PREFIX"
220        ,"Prefix for your IDA install (IDA ./configure --prefix)"
221        ,default_ida_prefix
222    ))
223    
224    opts.Add(
225        "IDA_LIB"
226        ,"Libraries linked to for IDA"
227        ,['sundials_nvecserial','sundials_ida','m']
228    )
229    
230    opts.Add(
231        'IDA_CPPPATH'
232        ,"Where is your ida.h?"
233        ,"$IDA_PREFIX/include"
234    )
235    
236    opts.Add(
237        'IDA_LIBPATH'
238        ,"Where are your SUNDIALS libraries installed?"
239        ,"$IDA_PREFIX/lib"
240    )
241    
242    # ----- conopt-----
243    
244    opts.Add(PackageOption(
245        "CONOPT_PREFIX"
246        ,"Prefix for your CONOPT install (CONOPT ./configure --prefix)"
247        ,default_conopt_prefix
248    ))
249    
250    opts.Add(
251        "CONOPT_LIB"
252        ,"Library linked to for CONOPT"
253        ,default_conopt_lib
254    )
255    
256    opts.Add(
257        'CONOPT_CPPPATH'
258        ,"Where is your conopt.h?"
259        ,default_conopt_cpppath
260    )
261    
262    opts.Add(
263        'CONOPT_LIBPATH'
264        ,"Where is your CONOPT libraries installed?"
265        ,default_conopt_libpath
266    )
267    
268    opts.Add(
269        'CONOPT_ENVVAR'
270        ,"What environment variable should be used at runtime to override the default search location for CONOPT DLL/SO?"
271        ,default_conopt_envvar
272    )
273    
274    #-------- f2c ------
275    
276    opts.Add(
277        "F2C_LIB"
278        ,"F2C library (eg. g2c, gfortran, f2c)"
279        ,"g2c"
280    )
281    
282    opts.Add(PackageOption(
283        "F2C_LIBPATH"
284        ,"Directory containing F2C library (i.e. g2c, gfortran, f2c, etc.), if not already accessible"
285        ,"off"
286    ))
287    
288    #------- tcl/tk --------
289    
290  opts.Add(  opts.Add(
291      'TCL'      'TCL'
# Line 237  opts.Add( Line 385  opts.Add(
385      ,'X11'      ,'X11'
386  )  )
387    
388    #----- installed file locations (for 'scons install') -----
389    
390  opts.Add(  opts.Add(
391      'INSTALL_PREFIX'      'INSTALL_PREFIX'
392      ,'Root location for installed files'      ,'Root location for installed files'
# Line 251  opts.Add( Line 401  opts.Add(
401    
402  opts.Add(  opts.Add(
403      'INSTALL_LIB'      'INSTALL_LIB'
404      ,'Location to put binaries during installation'      ,'Location to put libraries during installation'
405      ,"$INSTALL_PREFIX/lib"      ,"$INSTALL_PREFIX/lib"
406  )  )
407    
408  opts.Add(  opts.Add(
409      'INSTALL_DATA'      'INSTALL_SHARE'
410      ,'Location to put data files during installation'      ,'Common shared-file location on this system'
411      ,"$INSTALL_PREFIX/share"      ,"$INSTALL_PREFIX/share"
412  )  )
413    
414  opts.Add(  opts.Add(
415        'INSTALL_DOC'
416        ,'Location to install documentation files'
417        ,"$INSTALL_SHARE/doc"
418    )
419    
420    opts.Add(
421        'INSTALL_ASCDATA'
422        ,"Location of ASCEND shared data (TK, python, models etc)"
423        ,"$INSTALL_SHARE/ascend"
424    )
425    
426    opts.Add(
427      'INSTALL_INCLUDE'      'INSTALL_INCLUDE'
428      ,'Location to put header files during installation'      ,'Location to put header files during installation'
429      ,"$INSTALL_PREFIX/include"      ,"$INSTALL_PREFIX/include"
430  )  )
431    
432    
433    opts.Add(
434        'INSTALL_ROOT'
435        ,'For use by RPM only: location of %{buildroot} during rpmbuild'
436        ,""
437    )
438    
439    #----------------------
440    
441  opts.Add(  opts.Add(
442      'PYGTK_ASSETS'      'PYGTK_ASSETS'
443      ,'Default location for Glade assets (placed in pygtk/config.py)'      ,'Default location for Glade assets (placed in pygtk/config.py)'
# Line 279  opts.Add(BoolOption( Line 450  opts.Add(BoolOption(
450      ,False      ,False
451  ))  ))
452    
453    opts.Add(BoolOption(
454        'MALLOC_DEBUG'
455        ,"Compile with debugging version of MALLOC. Required for full CUnit testing"
456        ,False
457    ))
458    
459    #------ dmalloc --------
460    opts.Add(PackageOption(
461        'DMALLOC_PREFIX'
462        ,"Where are your dmalloc files?"
463        ,default_prefix
464    ))
465    
466    opts.Add(PackageOption(
467        'DMALLOC_CPPPATH'
468        ,"Where are your dmalloc include files?"
469        ,default_cpppath
470    ))
471    
472    opts.Add(PackageOption(
473        'DMALLOC_LIBPATH'
474        ,"Where are your dmalloc libraries?"
475        ,default_libpath
476    ))
477    
478    opts.Add(BoolOption(
479        'WITH_DMALLOC'
480        ,"Link to the DMALLOC library (if available) for debugging of memory usage."
481        ,False
482    ))
483    
484    #-----------------------
485    
486  opts.Add(  opts.Add(
487      'INSTALL_ROOT'      'DISTTAR_NAME'
488      ,'For use by RPM only: location of %{buildroot} during rpmbuild'      ,"Stem name of the tarball created by 'scons dist'. So for 'ascend-aaa.tar.bz2', set this to 'ascend-aaa'."
489      ,""      ,"ascend-"+version
490    )
491    
492    opts.Add(
493        'RELEASE'
494        ,"Release number for use in RPM spec file. This should always start with a zero for releases made by the ASCEND group, in order that third parties can make 'patch' releases of higher version numbers."
495        ,"0"
496  )  )
497    
498    opts.Add(BoolOption(
499        'ABSOLUTE_PATHS'
500        ,"Whether to use absolute or relative paths in the installed Tcl/Tk interface. If you want to build an RPM, set this to false."
501        ,default_absolute_paths
502    ))
503    
504    opts.Add(
505        'WIN_INSTALLER_NAME'
506        ,"Name of the installer .exe to create under Windows (minus the '.exe')"
507        ,"ascend-"+version
508    )
509    
510    opts.Add(BoolOption(
511        'WITH_XTERM_COLORS'
512        ,"Set to 0 if you don't want xterm colour codes in the console output"
513        ,True
514    ))
515    
516    opts.Add(BoolOption(
517        'WITH_EXTFNS'
518        ,"Set to 0 if you don't want to attempt to build external modules bundled"
519            + " with ASCEND."
520        ,True
521    ))
522    
523    opts.Add(BoolOption(
524        'WITH_SCROLLKEEPER'
525        ,"Set to to 1 if you want to install an OMF file that can be read by scrollkeeper (eg Yelp on GNOME)"
526        ,default_with_scrollkeeper
527    ))
528    
529  if platform.system()!="Windows":  if platform.system()!="Windows":
530      opts.Add(BoolOption(      opts.Add(BoolOption(
531          'WITH_GCCVISIBILITY'          'WITH_GCCVISIBILITY'
# Line 292  if platform.system()!="Windows": Line 533  if platform.system()!="Windows":
533          , True          , True
534      ))      ))
535    
536  if platform.system()=="Windows":  
     opts.Add(BoolOption(  
         'WITH_INSTALLER'  
         ,'Build the Windows Installer (setup program) using NSIS'  
         ,False  
     ))  
537    
538  # TODO: OTHER OPTIONS?  # TODO: OTHER OPTIONS?
539  # TODO: flags for optimisation  # TODO: flags for optimisation
# Line 306  if platform.system()=="Windows": Line 542  if platform.system()=="Windows":
542    
543  # Import the outside environment  # Import the outside environment
544    
545  if os.environ.has_key('OSTYPE') and os.environ['OSTYPE']=='msys':  def c_escape(str):
546      env = Environment(          return re.sub("\\\\","/",str)
         ENV=os.environ  
         , tools=['mingw','lex','yacc','fortran','swig','disttar']  
         , toolpath=['scons']  
     )  
     env['IS_MINGW']=True  
 else:  
     env = Environment(  
         ENV=os.environ  
         ,tools=['default','lex','yacc','fortran','swig','disttar']  
         , toolpath=['scons']  
     )  
547    
548  if platform.system()=='Windows' and env.has_key('MSVS'):  envadditional={}
549      print "INCLUDE =",env['ENV']['INCLUDE']  
550      print "LIB =",env['ENV']['LIB']  if platform.system()=="Windows":
551      print "PATH =",env['ENV']['PATH']      if os.environ.get('OSTYPE')=='msys':
552      env.Append(CPPPATH=env['ENV']['INCLUDE'])          envenv = os.environ;
553      env.Append(LIBPATH=env['ENV']['LIB'])          tools = ['mingw','lex','yacc','fortran','swig','disttar','nsis']
554            #TODO removed 'doxygen' for SCons 0.96.93
555            envadditional['IS_MINGW']=True
556        else:
557            envenv = {
558                'PATH':os.environ['PATH']
559                ,'INCLUDE':os.environ['INCLUDE']
560                ,'LIB':os.environ['LIB']
561                ,'MSVS_IGNORE_IDE_PATHS':1
562            }
563            tools=['default','lex','yacc','fortran','swig','disttar','nsis']    
564            #TODO removed 'doxygen' for SCons 0.96.93
565            envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
566    else:
567        if os.environ.get('TARGET')=='mingw':
568            envenv = os.environ
569            tools=['crossmingw','lex','yacc','disttar','nsis','doxygen']
570            envadditional['CPPPATH']=['/usr/local/lib/gcc/i386-mingw32/3.4.5/include','/usr/include']
571        else:
572            envenv = os.environ
573            tools=['default','lex','yacc','fortran','swig','disttar','nsis']
574            #TODO removed 'doxygen' for SCons 0.96.93
575        
576        
577    env = Environment(
578        ENV=envenv
579        , toolpath=['scons']
580        , tools=tools
581        , **envadditional
582    )
583    
584  opts.Update(env)  opts.Update(env)
585  opts.Save('options.cache',env)  opts.Save('options.cache',env)
# Line 338  without_tcltk_reason = "disabled by opti Line 592  without_tcltk_reason = "disabled by opti
592  with_python = env.get('WITH_PYTHON')  with_python = env.get('WITH_PYTHON')
593  without_python_reason = "disabled by options/config.py"  without_python_reason = "disabled by options/config.py"
594    
595  with_cunit_tests = env.get('WITH_CUNIT_TESTS')  with_cunit = env.get('WITH_CUNIT')
596  without_cunit_reason = "not requested"  without_cunit_reason = "not requested"
597    
598    with_extfns = env.get('WITH_EXTFNS')
599    without_extfn_reason = "disabled by options/config.py"
600    
601    with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
602    without_scrollkeeper_reason = "disabled by options/config.py"
603    
604    with_dmalloc = env.get('WITH_DMALLOC')
605    without_dmalloc_reason = "disabled by options/config.py"
606    
607    with_mmio = env.get('WITH_MMIO')
608    without_mmio_reason = "disabled by options/config.py"
609    
610    if platform.system()=="Windows":
611        with_installer=1
612    else:
613        with_installer=0
614        without_installer_reason = "only possible under Windows"
615    
616    if 'LSOD' in env['WITH_SOLVERS']:
617        with_lsode=True
618    else:
619        with_lsode=False
620        without_lsode_reason = "not requested (WITH_SOLVERS)"
621        
622    if 'IDA' in env['WITH_SOLVERS']:
623        with_ida=True
624    else:
625        with_ida=False
626        without_ida_reason = "not requested (WITH_SOLVERS)"
627    
628    
629    if 'CONOPT' in env['WITH_SOLVERS']:
630        with_conopt=True
631    else:
632        with_conopt=False
633        without_conopt_reason = "not requested (WITH_SOLVERS)"
634    
635    
636  #print "SOLVERS:",env['WITH_SOLVERS']  #print "SOLVERS:",env['WITH_SOLVERS']
637  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
638  #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']  #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
# Line 351  if platform.system()=='Windows': Line 643  if platform.system()=='Windows':
643    
644  env['CAN_INSTALL']=can_install  env['CAN_INSTALL']=can_install
645    
646    env['INSTALL_MODELS']=env['INSTALL_ASCDATA']+"/models/"
647    
648  print "TCL_CPPPATH =",env['TCL_CPPPATH']  print "TCL_CPPPATH =",env['TCL_CPPPATH']
649  print "TCL_LIBPATH =",env['TCL_LIBPATH']  print "TCL_LIBPATH =",env['TCL_LIBPATH']
650  print "TCL_LIB =",env['TCL_LIB']  print "TCL_LIB =",env['TCL_LIB']
651  print "CC =",env['CC']  print "CC =",env['CC']
652  print "CXX =",env['CXX']  print "CXX =",env['CXX']
653    print "FORTRAN=",env.get('FORTRAN')
654    
655    print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
656  #------------------------------------------------------  #------------------------------------------------------
657  # SPECIAL CONFIGURATION TESTS  # SPECIAL CONFIGURATION TESTS
658    
# Line 406  def CheckSwigVersion(context): Line 702  def CheckSwigVersion(context):
702          return 0;          return 0;
703    
704  #----------------  #----------------
705    # Scrollkeeper (Linux documentation system)
706    
707    def get_scrollkeeper_omfdir(env):
708        cmd = 'scrollkeeper-config --omfdir'
709        (cin,coutcerr) = os.popen4(cmd)
710        output = coutcerr.read()
711        return output.strip()
712    
713    def CheckScrollkeeperConfig(context):
714        try:
715            context.Message("Checking for scrollkeeper...")
716            dir=get_scrollkeeper_omfdir(context.env)
717        except:
718            context.Result("Failed to run 'scrollkeeper-config'")
719            return 0
720        context.env['OMFDIR']=dir
721        context.Result("OK, %s" % dir)
722        return 1
723    
724    #----------------
725  # General purpose library-and-header test  # General purpose library-and-header test
726    
727  class KeepContext:  class KeepContext:
728      def __init__(self,context,varprefix,static=False):      def __init__(self,context,varprefix,static=False):
729          self.keep = {}          self.keep = {}
730          for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:          for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:
731              if context.env.has_key(k):              #print "Keeping env %s = %s" % (k,context.env.get(k))
732                  self.keep[k] = context.env[k]              self.keep[k]=context.env.get(k)
             else:  
                 self.keep[k] = None  
733                    
734          if context.env.has_key(varprefix+'_CPPPATH'):          if context.env.has_key(varprefix+'_CPPPATH'):
735              context.env.Append(CPPPATH=[env[varprefix+'_CPPPATH']])              context.env.AppendUnique(CPPPATH=[env[varprefix+'_CPPPATH']])
736              #print "Adding '"+str(cpppath_add)+"' to cpp path"              #print "Adding '"+str(env[varprefix+'_CPPPATH'])+"' to cpp path"
737    
738          if static:          if static:
739              staticlib=env[varprefix+'_LIB']              staticlib=env[varprefix+'_LIB']
# Line 430  class KeepContext: Line 744  class KeepContext:
744          else:          else:
745              if context.env.has_key(varprefix+'_LIBPATH'):              if context.env.has_key(varprefix+'_LIBPATH'):
746                  context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])                  context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])
747                  #print "Adding '"+str(libpath_add)+"' to lib path"                  #print "Adding '"+str(env[varprefix+'_LIBPATH'])+"' to lib path"
748    
749              if context.env.has_key(varprefix+'_LIB'):              if context.env.has_key(varprefix+'_LIB'):
750                  context.env.Append(LIBS=[env[varprefix+'_LIB']])                  context.env.Append(LIBS=[env[varprefix+'_LIB']])
751                  #print "Adding '"+str(libs_add)+"' to libs"                  #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"    
752    
753      def restore(self,context):      def restore(self,context):
754          #print "RESTORING CONTEXT"          #print "RESTORING CONTEXT"
# Line 446  class KeepContext: Line 760  class KeepContext:
760                      #print "Clearing "+str(k)                      #print "Clearing "+str(k)
761                      del context.env[k];                      del context.env[k];
762              else:              else:
763                  #print "Restoring "+str(k)+" to '"+self.keep[k]+"'"                              #print "Restoring %s to '%s'" %(k,self.keep.get(k))
764                  context.env[k]=self.keep[k];                  context.env[k]=self.keep[k];
765    
766  def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False):  def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False):
# Line 463  def CheckExtLib(context,libname,text,ext Line 777  def CheckExtLib(context,libname,text,ext
777      if varprefix==None:      if varprefix==None:
778          varprefix = libname.upper()          varprefix = libname.upper()
779            
780        #print "LIBS is currently:",context.env.get('LIBS')
781      keep = KeepContext(context,varprefix,static)      keep = KeepContext(context,varprefix,static)
782    
783      if not context.env.has_key(varprefix+'_LIB'):      if not context.env.has_key(varprefix+'_LIB'):
784          # if varprefix_LIB were in env, KeepContext would          # if varprefix_LIB were in env, KeepContext would
785          # have appended it already          # have appended it already
786          context.env.Append(LIBS=libname)          context.env.Append(LIBS=[libname])
787    
788      is_ok = context.TryLink(text,ext)      is_ok = context.TryLink(text,ext)
789            
# Line 477  def CheckExtLib(context,libname,text,ext Line 792  def CheckExtLib(context,libname,text,ext
792      keep.restore(context)      keep.restore(context)
793    
794  #   print "Restored CPPPATH="+str(context.env['CPPPATH'])  #   print "Restored CPPPATH="+str(context.env['CPPPATH'])
795  #   print "Restored LIBS="+libname  #   print "Restored LIBS="+str(context.env['LIBS'])
796  #   print "Restored LIBPATH="+str(context.env['LIBPATH'])  #   print "Restored LIBPATH="+str(context.env['LIBPATH'])
797    
798      context.Result(is_ok)      context.Result(is_ok)
# Line 531  def CheckGccVisibility(context): Line 846  def CheckGccVisibility(context):
846  # YACC  # YACC
847    
848  yacc_test_text = """  yacc_test_text = """
849  %start ROOT  %{
850     %token MSG  #include <stdio.h>
    %%  
851    
852     ROOT:  /* MSVC++ needs this before it can swallow Bison output */
853       MSG { print("HELLO"); }  #ifdef _MSC_VER
854     ;  # define __STDC__
855    #endif
856    %}
857    %token MSG
858    %start ROOT
859    %%
860    ROOT:
861        MSG { printf("HELLO"); }
862        ;
863    %%
864  """  """
865    
866  def CheckYacc(context):  def CheckYacc(context):
867      context.Message("Checking for Yacc... ")      context.Message("Checking for Yacc ('%s')... " % context.env.get('YACC'))
868      is_ok = context.TryCompile(yacc_test_text,".y")      is_ok = context.TryCompile(yacc_test_text,".y")
869      context.Result(is_ok)      context.Result(is_ok)
870      return is_ok      return is_ok
# Line 571  def CheckCUnit(context): Line 894  def CheckCUnit(context):
894      return CheckExtLib(context,'cunit',cunit_test_text)      return CheckExtLib(context,'cunit',cunit_test_text)
895    
896  #----------------  #----------------
897    # dmalloc test
898    
899    dmalloc_test_text = """
900    #include <stdlib.h>
901    #include <dmalloc.h>
902    
903    int main(void){
904        char *c;
905        c = malloc(100*sizeof(char));
906        free(c);
907        return 0;
908    }
909    """
910    
911    def CheckDMalloc(context):
912        return CheckExtLib(context,'dmalloc',dmalloc_test_text)
913    
914    #----------------
915    # MATH test
916    
917    math_test_text = """
918    #ifndef _ALL_SOURCE
919    # define _ALL_SOURCE
920    #endif
921    #ifndef _XOPEN_SOURCE
922    # define _XOPEN_SOURCE
923    #endif
924    #ifndef _XOPEN_SOURCE_EXTENDED
925    # define _XOPEN_SOURCE_EXTENDED 1
926    #endif
927    #include <math.h>
928    int main(void){
929        double x = 1.0; double y = 1.0; int i = 1;
930        acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);
931        j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);
932        y0(x); y1(x); yn(i,x);
933    #ifdef _THREAD_SAFE
934        gamma_r(x,&i);
935        lgamma_r(x,&i);
936    #else
937    gamma(x);
938        lgamma(x);
939    #endif
940        hypot(x,y); nextafter(x,y); remainder(x,y); scalb(x,y);
941        return 0;
942    }
943    """
944    
945    def CheckMath(context):
946        context.Message('Checking for IEEE math library... ')
947        libsave=context.env.get('LIBS');
948        context.env.AppendUnique(LIBS=['m'])
949        is_ok=context.TryLink(math_test_text,".c")
950        context.Result(is_ok)
951        if not is_ok:
952            context.env['LIBS']=libsave
953        return is_ok
954    
955    #----------------
956    # libpython test
957    
958    libpython_test_text = """
959    #include <Python.h>
960    int main(void){
961        PyObject *p;
962        p = Py_None;
963        return 0;
964    }
965    """
966    
967    def CheckPythonLib(context):
968        context.Message('Checking for libpython... ')
969    
970        if platform.system()=="Windows":
971            python_lib='python%d%d'
972        else:
973            python_lib='python%d.%d'
974        python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
975    
976        python_cpppath = [distutils.sysconfig.get_python_inc()]
977        cfig = distutils.sysconfig.get_config_vars()    
978        
979        lastLIBS = context.env.get('LIBS')
980        lastLIBPATH = context.env.get('LIBPATH')
981        lastCPPPATH = context.env.get('CPPPATH')
982        lastLINKFLAGS = context.env.get('LINKFLAGS')
983    
984        python_libpath = []
985        python_linkflags = []
986        if platform.system()=="Windows":
987            python_libpath+=[cfig['prefix']]
988        else:
989            # checked on Linux and SunOS
990            if cfig['LDLIBRARY']==cfig['LIBRARY']:
991                sys.stdout.write("(static)")
992                python_libpath += [cfig['LIBPL']]
993                python_linkflags += cfig['LIBS'].split(' ')
994    
995        context.env.AppendUnique(LIBS=python_libs)
996        context.env.AppendUnique(LIBPATH=python_libpath)
997        context.env.AppendUnique(CPPPATH=python_cpppath)
998        context.env.AppendUnique(LINKFLAGS=python_linkflags)
999        result = context.TryLink(libpython_test_text,".c");
1000    
1001        context.Result(result)  
1002    
1003        if(result):
1004            context.env['PYTHON_LIBPATH']=python_libpath
1005            context.env['PYTHON_LIB']=python_libs
1006            context.env['PYTHON_CPPPATH']=python_cpppath
1007            context.env['PYTHON_LINKFLAGS']=python_linkflags
1008    
1009        context.env['LIBS'] = lastLIBS
1010        context.env['LIBPATH'] = lastLIBPATH
1011        context.env['CPPPATH'] = lastCPPPATH
1012        context.env['LINKFLAGS'] = lastLINKFLAGS
1013    
1014        return result
1015    
1016    #----------------
1017    # IDA test
1018    
1019    sundials_version_major_required = 2
1020    sundials_version_minor_min = 2
1021    sundials_version_minor_max = 3
1022    
1023    sundials_version_text = """
1024    #include <sundials/sundials_config.h>
1025    #include <stdio.h>
1026    int main(){
1027        printf("%s",SUNDIALS_PACKAGE_VERSION);
1028        return 0;
1029    }
1030    """
1031    
1032    ida_test_text = """
1033    # include <ida/ida.h>
1034    # include <nvector/nvector_serial.h>
1035    # include <ida/ida_spgmr.h>
1036    int main(){
1037        void *ida_mem;
1038        ida_mem = IDACreate();
1039        return 0;
1040    }
1041    """
1042    
1043    def CheckIDA(context):
1044        context.Message( 'Checking for IDA (SUNDIALS)... ' )
1045    
1046        keep = KeepContext(context,"IDA")
1047        
1048        is_ok = context.TryLink(ida_test_text,".c")
1049        context.Result(is_ok)
1050        
1051        keep.restore(context)
1052            
1053        return is_ok
1054    
1055    # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1056    # so detect the version and act accordingly.
1057    def CheckIDAVersion(context):
1058        keep = KeepContext(context,'IDA')
1059        context.Message("Checking SUNDIALS version... ")
1060        (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1061        keep.restore(context)
1062        if not is_ok:
1063            context.Result("failed to run check")
1064            return 0
1065    
1066        major,minor,patch = tuple([int(i) for i in output.split(".")])
1067        context.env['SUNDIALS_VERSION_MAJOR'] = major
1068        context.env['SUNDIALS_VERSION_MINOR'] = minor
1069        if major != sundials_version_major_required \
1070                or minor < sundials_version_minor_min \
1071                or minor > sundials_version_minor_max:
1072            context.Result(output+" (bad version)")
1073            # bad version
1074            return 0
1075            
1076        # good version
1077        context.Result(output+", good")
1078        return 1
1079        
1080    #----------------
1081    # CONOPT test
1082    
1083    conopt_test_text = """
1084    #if !defined(_WIN32)
1085    # define FNAME_LCASE_DECOR
1086    #endif
1087    
1088    #include <conopt.h>
1089    #include <stdlib.h>
1090    int main(){
1091        int s, *v, e;
1092        s = COIDEF_Size();
1093        v = (int *)malloc(s*sizeof(int));
1094        e = COIDEF_Ini(v);
1095        return e;
1096    }
1097    """
1098    
1099    def CheckCONOPT(context):
1100        context.Message( 'Checking for CONOPT... ' )
1101    
1102        keep = KeepContext(context,"CONOPT")
1103        
1104        is_ok = context.TryLink(conopt_test_text,".c")
1105        context.Result(is_ok)
1106        
1107        keep.restore(context)
1108            
1109        return is_ok
1110    
1111    #----------------
1112  # Tcl test  # Tcl test
1113    
1114  # TCL and TK required version 8.1, 8.2, 8.3, or 8.4:  # TCL and TK required version 8.1, 8.2, 8.3, or 8.4:
# Line 620  int main(void){ Line 1158  int main(void){
1158  }  }
1159  """  """
1160  def CheckTk(context):  def CheckTk(context):
1161      return CheckExtLib(context,'tk',tcl_check_text,static=env['STATIC_TCLTK'])      return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1162    
1163    
1164  def CheckTkVersion(context):  def CheckTkVersion(context):
# Line 677  def CheckX11(context): Line 1215  def CheckX11(context):
1215      return CheckExtLib(context,'X11',x11_check_text)      return CheckExtLib(context,'X11',x11_check_text)
1216    
1217  #----------------  #----------------
1218    # Check that we can raise and catch sigint
1219    
1220    sigint_test_text = r"""
1221    #include <signal.h>
1222    #include <setjmp.h>
1223    #include <stdlib.h>
1224    static jmp_buf g_jmpenv;
1225    void sighandler(int sig){
1226        longjmp(g_jmpenv,sig);
1227    }
1228    void testsigint(){
1229        raise(SIGINT);
1230    }
1231    int main(void){
1232        signal(SIGINT,&sighandler);
1233        switch(setjmp(g_jmpenv)){
1234            case 0:
1235                testsigint();
1236                exit(1);
1237            case SIGINT:
1238                exit(0);
1239            default:
1240                exit(2);
1241        }
1242    }
1243    """
1244    
1245    def CheckSIGINT(context):
1246        context.Message("Checking SIGINT is catchable... ")
1247        (is_ok,output)=context.TryRun(sigint_test_text,".c")
1248        context.Result(is_ok)
1249        return is_ok
1250    
1251    #----------------
1252    # Check that we're able to catch floating point errors
1253    
1254    sigfpe_test_text = r"""
1255    #include <signal.h>
1256    #include <setjmp.h>
1257    #include <stdlib.h>
1258    #include <fenv.h>
1259    static jmp_buf g_jmpenv;
1260    void fpehandler(int sig){
1261        longjmp(g_jmpenv,sig);
1262    }
1263    int main(void){
1264        fenv_t myfenv;
1265        fegetenv(&myfenv);
1266        fesetenv(&myfenv);
1267        feenableexcept(FE_ALL_EXCEPT);
1268        signal(SIGFPE,&fpehandler);
1269        double x;
1270        switch(setjmp(g_jmpenv)){
1271            case 0:
1272                x = 1.0 / 0.0;
1273                /* failed to catch */
1274                exit(1);            
1275            case SIGFPE:
1276                exit(0);
1277        }
1278    }
1279    """
1280    
1281    def CheckFPE(context):
1282        context.Message("Checking C99 FPE behaviour... ")
1283        (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1284        context.Result(is_ok)
1285        return is_ok
1286    
1287    #----------------
1288    # signal reset needed?
1289    
1290    sigreset_test_text = r"""
1291    #include <signal.h>
1292    #include <setjmp.h>
1293    #include <stdlib.h>
1294    #include <stdio.h>
1295    typedef void SigHandlerFn(int);
1296    static jmp_buf g_jmpenv;
1297    void sighandler(int sig){
1298        longjmp(g_jmpenv,sig);
1299    }
1300    void testsigint(){
1301        fprintf(stderr,"Raising SIGINT\n");
1302        raise(SIGINT);
1303    }
1304    int main(void){
1305        SigHandlerFn *last,*saved;
1306        saved = signal(SIGINT,&sighandler);
1307        if(saved!=SIG_DFL){
1308            fprintf(stderr,"Default handler was not correctly set\n");
1309            exit(3);
1310        }
1311        switch(setjmp(g_jmpenv)){
1312            case 0:
1313                testsigint();
1314                fprintf(stderr,"Back from SIGINT\n");
1315                exit(1);
1316            case SIGINT:
1317                break;
1318            default:
1319                exit(2);
1320        };
1321        last = signal(SIGINT,(saved!=NULL)?saved:SIG_DFL);
1322        if(last!=&sighandler){
1323            printf("1");
1324            exit(0);
1325        }
1326        printf("0");
1327        exit(0);
1328    }
1329    """
1330    
1331    def CheckSigReset(context):
1332        context.Message("Checking signal handler reset... ")
1333        (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1334        if not is_ok:
1335            context.Result("ERROR")
1336            return 0
1337        if(int(output)):
1338            context.Result("required");
1339            context.env['ASC_RESETNEEDED'] = True
1340        else:
1341            context.Result("not required");
1342            context.env['ASC_RESETNEEDED'] = False
1343        return is_ok
1344    
1345    #----------------
1346  # GCC Version sniffing  # GCC Version sniffing
1347    
1348  # TODO FIXME  # TODO FIXME
# Line 688  gcc_version4 = False Line 1354  gcc_version4 = False
1354    
1355  conf = Configure(env  conf = Configure(env
1356      , custom_tests = {      , custom_tests = {
1357          'CheckSwigVersion' : CheckSwigVersion          'CheckMath' : CheckMath
1358            , 'CheckSwigVersion' : CheckSwigVersion
1359            , 'CheckPythonLib' : CheckPythonLib
1360          , 'CheckCUnit' : CheckCUnit          , 'CheckCUnit' : CheckCUnit
1361            , 'CheckDMalloc' : CheckDMalloc
1362          , 'CheckTcl' : CheckTcl          , 'CheckTcl' : CheckTcl
1363          , 'CheckTclVersion' : CheckTclVersion          , 'CheckTclVersion' : CheckTclVersion
1364          , 'CheckTk' : CheckTk          , 'CheckTk' : CheckTk
# Line 699  conf = Configure(env Line 1368  conf = Configure(env
1368          , 'CheckYacc' : CheckYacc          , 'CheckYacc' : CheckYacc
1369          , 'CheckTkTable' : CheckTkTable          , 'CheckTkTable' : CheckTkTable
1370          , 'CheckX11' : CheckX11          , 'CheckX11' : CheckX11
1371            , 'CheckIDA' : CheckIDA
1372            , 'CheckIDAVersion' : CheckIDAVersion
1373            , 'CheckCONOPT' : CheckCONOPT
1374            , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1375            , 'CheckFPE' : CheckFPE
1376            , 'CheckSIGINT' : CheckSIGINT
1377            , 'CheckSigReset' : CheckSigReset
1378  #       , 'CheckIsNan' : CheckIsNan  #       , 'CheckIsNan' : CheckIsNan
1379  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig
1380      }      }
1381  #   , config_h = "config.h"  #   , config_h = "config.h"
1382  )  )
1383    
1384    # stdio -- just to check that compiler is behaving
1385    
1386    if not conf.CheckHeader('stdio.h'):
1387        print "CPPPATH =",env.get('CPPPATH')
1388        print "Did not find 'stdio.h'! Check your compiler configuration."
1389        Exit(1)
1390    
1391  # Math library  # Math library
1392    
1393  #if not conf.CheckFunc('sinh') and not conf.CheckLibWithHeader(['m','c','libc'], 'math.h', 'C'):  if need_libm:
1394  #   print 'Did not find math library, exiting!'      if not conf.CheckMath():
1395  #   Exit(1)          print 'Did not find math library, exiting!'
1396            Exit(1)
1397        #pass
1398    
1399  # Where is 'isnan'?  # Where is 'isnan'?
1400    
1401  if not conf.CheckFunc('isnan'):  if not conf.CheckFunc('isnan') and not conf.CheckFunc('_isnan'):
1402      print "Didn't find isnan"      print "Didn't find isnan"
1403  #   Exit(1)  #   Exit(1)
1404    
# Line 726  if conf.CheckGcc(): Line 1410  if conf.CheckGcc():
1410          conf.env['HAVE_GCCVISIBILITY']=True;          conf.env['HAVE_GCCVISIBILITY']=True;
1411          conf.env.Append(CCFLAGS=['-fvisibility=hidden'])          conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
1412          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
1413        conf.env.Append(CCFLAGS=['-Wall'])
1414    
1415    # Catching SIGINT
1416    
1417    if not conf.CheckSIGINT():
1418        print "SIGINT unable to be caught. Aborting."
1419        exit(1)
1420    
1421    # Catching SIGFPE
1422    
1423    if conf.CheckFPE():
1424        conf.env['HAVE_C99FPE']=True
1425    else:
1426        conf.env['HAVE_C99FPE']=False
1427    
1428    # Checking for signal reset requirement
1429    
1430    if not conf.CheckSigReset():
1431        print "Unable to determine if signal reset is required"
1432        exit(1)
1433    
1434  # YACC  # YACC
1435    
# Line 738  conf.env['HAVE_LEX']=True Line 1442  conf.env['HAVE_LEX']=True
1442    
1443  # Tcl/Tk  # Tcl/Tk
1444    
1445  if conf.CheckTcl():  if with_tcltk:
1446      if with_tcltk and conf.CheckTclVersion():      if conf.CheckTcl():
1447          if conf.CheckTk():          if conf.CheckTclVersion():
1448              if with_tcltk and conf.CheckTkVersion():              if conf.CheckTk():
1449                  if env['STATIC_TCLTK']:                  if with_tcltk and conf.CheckTkVersion():
1450                      if conf.CheckTkTable():                      if env['STATIC_TCLTK']:
1451                          pass                          if conf.CheckTkTable():
1452                      else:                              pass
1453                          without_tcltk_reason = "TkTable not found"                          else:
1454                          with_tcltk = False                              without_tcltk_reason = "TkTable not found"
1455                                with_tcltk = False
1456                    else:
1457                        without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
1458                        with_tcltk = False
1459              else:              else:
1460                  without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"                  without_tcltk_reason = "Tk not found."
1461                  with_tcltk = False                  with_tcltk = False
1462          else:          else:
1463              without_tcltk_reason = "Tk not found."              without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
1464              with_tcltk = False              with_tcltk = False
1465    
1466      else:      else:
1467          without_tcltk_reason = "Require Tcl <= 8.4 Tcl."          without_tcltk_reason = "Tcl not found."
1468          with_tcltk = False          with_tcltk = False
1469    
 else:  
     without_tcltk_reason = "Tcl not found."  
     with_tcltk = False  
   
1470  if env['STATIC_TCLTK']:  if env['STATIC_TCLTK']:
1471      conf.CheckX11()      conf.CheckX11()
1472    
1473  # Python... obviously we're already running python, so we just need to  # Python... obviously we're already running python, so we just need to
1474  # check that we can link to the python library OK:  # check that we can link to the python library OK:
1475    
1476  if platform.system()=="Windows":  if not conf.CheckPythonLib():
1477      python_lib='python24'      without_python_reason = 'libpython2.x not found or not linkable'
1478  else:      with_python = False
1479      python_lib='python2.4'      env['WITH_PYTHON']=False
1480    
1481  # SWIG version  # SWIG version
1482    
1483  if not conf.CheckSwigVersion():  if with_python and not conf.CheckSwigVersion():
1484      without_python_reason = 'SWIG >= 1.3.24 is required'      without_python_reason = 'SWIG >= 1.3.24 is required'
1485      with_python = False      with_python = False
1486        env['WITH_PYTHON']=False
1487    
1488  # CUnit  # CUnit
1489    
1490  if with_cunit_tests:  if with_cunit:
1491      if not conf.CheckCUnit():      if not conf.CheckCUnit():
1492          without_cunit_reason = 'CUnit not found'          without_cunit_reason = 'CUnit not found'
1493            with_cunit = False
1494            #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
1495    
1496    # DMALLOC
1497    
1498    if with_dmalloc:
1499        if not conf.CheckDMalloc():
1500            without_dmalloc_reason = 'dmalloc not found'
1501            with_dmalloc = False
1502    
1503    # IDA
1504    
1505    if not with_ida:
1506        without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
1507    elif not conf.CheckIDA():
1508        with_ida = False
1509        without_ida_reason = "IDA not found"
1510    elif not conf.CheckIDAVersion():
1511        with_ida = False
1512        without_ida_reason = "Unsupported (or undetected) SUNDIALS version"
1513    
1514    # CONOPT
1515    
1516    if not with_conopt:
1517        without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
1518    elif not conf.CheckCONOPT():
1519        with_conopt = False
1520        without_conpt_reason = "CONOPT not found"
1521    
1522  # BLAS  # BLAS
1523    
1524  need_blas=False  need_blas=False
1525  if with_tcltk:  
1526    if with_lsode:
1527        need_fortran = True
1528      need_blas=True      need_blas=True
1529    
1530  if need_blas:  if need_blas:
1531      if conf.CheckLib('blas'):      if conf.CheckLib('blas'):
1532          with_local_blas = False          with_local_blas = False
# Line 797  if need_blas: Line 1534  if need_blas:
1534      else:      else:
1535          with_local_blas = True          with_local_blas = True
1536          need_fortran = True          need_fortran = True
1537    else:
1538        with_local_blas= False;
1539        without_local_blas_reason = "BLAS not required"
1540    
1541  # FORTRAN  # FORTRAN
1542    
1543  if need_fortran:  if need_fortran:
1544      conf.env.Tool('f77')      conf.env.Tool('fortran')
1545      detect_fortran = conf.env.Detect(['g77','f77'])      detect_fortran = conf.env.Detect(['g77','f77','gfortran'])
1546      if detect_fortran:      if detect_fortran:
1547          # For some reason, g77 doesn't get detected properly on MinGW          # For some reason, g77 doesn't get detected properly on MinGW
1548          if not env.has_key('F77'):          if not env.has_key('F77') and not env.has_key('FORTRAN'):
1549              conf.env.Replace(F77=detect_fortran)              conf.env.Replace(F77=detect_fortran)
1550              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
1551              conf.env.Replace(F77FLAGS='')              conf.env.Replace(F77FLAGS='')
# Line 819  if need_fortran: Line 1559  if need_fortran:
1559              )              )
1560              conf.env.Append(BUILDERS={'Fortran':fortran_builder})              conf.env.Append(BUILDERS={'Fortran':fortran_builder})
1561      else:      else:
1562          print "FORTRAN-77 required but not found"          with_lsode=False;
1563          Exit(1)          without_lsode_reason="FORTRAN-77 required but not found"
1564    
1565  #else:  #else:
1566  #   print "FORTRAN not required"  #   print "FORTRAN not required"
1567    
1568    # F2C
1569    
1570    if need_fortran:
1571        if platform.system()=="Windows":
1572            conf.env.Append(LIBPATH='c:\mingw\lib')
1573    
1574    # scrollkeeper
1575    
1576    if with_scrollkeeper:
1577        if not conf.CheckScrollkeeperConfig():
1578            with_scrollkeeper=False
1579            without_scrollkeeper_reason="unable to detect scrollkeeper-config"
1580    
1581  # TODO: -D_HPUX_SOURCE is needed  # TODO: -D_HPUX_SOURCE is needed
1582    
1583  # TODO: check size of void*  # TODO: check size of void*
# Line 831  if need_fortran: Line 1585  if need_fortran:
1585  # TODO: detect if dynamic libraries are possible or not  # TODO: detect if dynamic libraries are possible or not
1586    
1587  if platform.system()=="Windows" and env.has_key('MSVS'):  if platform.system()=="Windows" and env.has_key('MSVS'):
1588      if not conf.CheckHeader('windows.h') and env['PACKAGE_LINKING']=='DYNAMIC_PACKAGES':      _found_windows_h = conf.CheckHeader('Windows.h')
1589          print "Reverting to STATIC_PACKAGES since windows.h is not available. Probably you "\  
1590              +"need to install the Microsoft Windows Server 2003 Platform SDK, or similar."      if not _found_windows_h:
1591          env['PACKAGE_LINKING']='STATIC_PACKAGES'          print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
1592                    Exit(1)
1593    
1594      if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):      if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):
1595          with_python = 0;          with_python = 0;
1596          without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."          without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
# Line 844  conf.env.Append(CPPDEFINES=env['PACKAGE_ Line 1599  conf.env.Append(CPPDEFINES=env['PACKAGE_
1599    
1600  conf.Finish()  conf.Finish()
1601    
 env.Append(PYTHON_LIBPATH=[distutils.sysconfig.PREFIX+"/libs"])  
 env.Append(PYTHON_LIB=[python_lib])  
 env.Append(PYTHON_CPPPATH=[distutils.sysconfig.get_python_inc()])  
   
1602  #---------------------------------------  #---------------------------------------
1603  # SUBSTITUTION DICTIONARY for .in files  # SUBSTITUTION DICTIONARY for .in files
1604    
1605    release = env.get('RELEASE')
1606    if release=="0.":
1607        release="0"
1608    
1609    #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
1610    
1611  subst_dict = {  subst_dict = {
1612      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
1613      , '@GLADE_FILE@':'ascend.glade'      , '@GLADE_FILE@':'ascend.glade'
1614      , '@HELP_ROOT@':''      , '@HELP_ROOT@':''
1615      , '@ICON_EXTENSION@':icon_extension      , '@ICON_EXTENSION@':icon_extension
1616      , '@INSTALL_DATA@':env['INSTALL_DATA']      , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
1617      , '@INSTALL_BIN@':env['INSTALL_BIN']      , '@INSTALL_BIN@':env['INSTALL_BIN']
1618      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
1619        , '@INSTALL_LIB@':env['INSTALL_LIB']
1620        , '@INSTALL_MODELS@':env['INSTALL_MODELS']
1621      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
1622      , '@VERSION@':version      , '@VERSION@':version
1623        , '@RELEASE@':release
1624        , '@DISTTAR_NAME@':env['DISTTAR_NAME']
1625      , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'      , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'
1626      , '@ASC_SHLIBSUFFIX@':env['SHLIBSUFFIX']      , '@ASC_SHLIBSUFFIX@':env['SHLIBSUFFIX']
1627      , '@ASC_SHLIBPREFIX@':env['SHLIBPREFIX']      , '@ASC_SHLIBPREFIX@':env['SHLIBPREFIX']
1628        , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
1629        , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
1630        , '@PYTHON@' : python_exe
1631        , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
1632        , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
1633        , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_LIBPATH"))
1634        , '@SOURCE_ROOT@':os.path.abspath(str(env.Dir("#")))
1635  }  }
1636    
1637  if env['WITH_LOCAL_HELP']:  if env.get('WITH_LOCAL_HELP'):
1638      print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']      print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']
1639      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']
1640    
1641    # bool options...
1642    for k,v in {
1643            'ABSOLUTE_PATHS' : 'ASC_ABSOLUTE_PATHS'
1644            ,'WITH_XTERM_COLORS' : 'ASC_XTERM_COLORS'
1645            ,'MALLOC_DEBUG' : 'MALLOC_DEBUG'
1646    }.iteritems():
1647        if env.get(k):
1648    #       subst_dict['@'+v+'@']='1'
1649            subst_dict["/\\* #define "+v+' @'+v+"@ \\*/"]='# define '+v+' 1 '
1650    
1651    if with_ida:
1652        subst_dict["/\\* #define ASC_WITH_IDA @ASC_WITH_IDA@ \\*/"]='#define ASC_WITH_IDA '
1653    
1654    if with_dmalloc:
1655        subst_dict["/\\* #define ASC_WITH_DMALLOC @ASC_WITH_DMALLOC@ \\*/"]='#define ASC_WITH_DMALLOC '
1656    
1657    if with_conopt:
1658        subst_dict["/\\* #define ASC_WITH_CONOPT @ASC_WITH_CONOPT@ \\*/"]='#define ASC_WITH_CONOPT '
1659    
1660    if with_lsode:
1661        subst_dict["/\\* #define ASC_WITH_LSODE @ASC_WITH_LSODE@ \\*/"]='#define ASC_WITH_LSODE '
1662    
1663    if with_mmio:
1664        subst_dict["/\\* #define ASC_WITH_MMIO @ASC_WITH_MMIO@ \\*/"]='#define ASC_WITH_MMIO '
1665    
1666  if with_python:  if with_python:
1667      subst_dict['@ASCXX_USE_PYTHON@']="1"      subst_dict['@ASCXX_USE_PYTHON@']="1"
1668        env['WITH_PYTHON']=1;
1669    
1670  if env.has_key('HAVE_GCCVISIBILITY'):  if env.has_key('HAVE_GCCVISIBILITY'):
1671      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
1672    
1673    if env.get('ASC_RESETNEEDED'):
1674        subst_dict["/\\* #define ASC_RESETNEEDED @ASC_RESETNEEDED@ \\*/"]='#define ASC_RESETNEEDED '
1675    
1676    if env.get('HAVE_C99FPE'):
1677        subst_dict["/\\* #define HAVE_C99FPE @HAVE_C99FPE@ \\*/"]='#define HAVE_C99FPE '
1678    
1679  env.Append(SUBST_DICT=subst_dict)  env.Append(SUBST_DICT=subst_dict)
1680    
1681  #------------------------------------------------------  #------------------------------------------------------
1682    # RECIPE: Fix up long command-line bug on Win2k
1683    
1684    # Currently this is broken, awaiting help from the SCons users list
1685    
1686    if 0 and env['PLATFORM'] == 'win32':
1687        import win32file
1688        import win32event
1689        import win32process
1690        import win32security
1691        import string
1692    
1693        def my_spawn(sh, escape, cmd, args, spawnenv):
1694            for var in spawnenv:
1695                spawnenv[var] = spawnenv[var].encode('ascii', 'replace')
1696    
1697            sAttrs = win32security.SECURITY_ATTRIBUTES()
1698            StartupInfo = win32process.STARTUPINFO()
1699            newargs = string.join(map(escape, args[1:]), ' ')
1700            cmdline = cmd + " " + newargs
1701    
1702            # check for any special operating system commands
1703            if cmd == 'del':
1704                for arg in args[1:]:
1705                    win32file.DeleteFile(arg)
1706                exit_code = 0
1707            else:
1708                # otherwise execute the command.
1709                hProcess, hThread, dwPid, dwTid = win32process.CreateProcess(None, cmdline, None, None, 1, 0, spawnenv, None, StartupInfo)
1710                win32event.WaitForSingleObject(hProcess, win32event.INFINITE)
1711                exit_code = win32process.GetExitCodeProcess(hProcess)
1712                win32file.CloseHandle(hProcess);
1713                win32file.CloseHandle(hThread);
1714            return exit_code
1715    
1716        env['SPAWN'] = my_spawn
1717    
1718    #------------------------------------------------------
1719  # RECIPE: SWIG scanner  # RECIPE: SWIG scanner
1720    
1721  import SCons.Script  import SCons.Script
# Line 984  SConsEnvironment.InstallPerm = InstallPe Line 1821  SConsEnvironment.InstallPerm = InstallPe
1821            
1822  # define wrappers      # define wrappers    
1823  SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)    SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)  
1824  SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)      SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
1825    SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
 #------------------------------------------------------  
 # NSIS Support for SCons  
   
 # Adapted version by John Pye, April 2006.  
 # from http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/NsisSconsTool  
 # Written by Mike Elkins, January 2004.  
   
 #This tool provides SCons support for the Nullsoft Scriptable Install System  
 #a windows installer builder available at http://nsis.sourceforge.net/home  
   
 #In addition, if you set NSISDEFINES to a dictionary, those variables will be passed  
 #to NSIS.  
   
 import SCons.Builder  
 import SCons.Util  
 import SCons.Scanner  
 import SCons.Sig  
 import os.path  
 import glob  
   
 def nsis_parse( sources, keyword, multiple ):  
   """  
   A function that knows how to read a .nsi file and figure  
   out what files are referenced, or find the 'OutFile' line.  
   
   
   sources is a list of nsi files.  
   keyword is the command ('File' or 'OutFile') to look for  
   multiple is true if you want all the args as a list, false if you  
   just want the first one.  
   """  
   stuff = []  
   for s in sources:  
     c = s.get_contents()  
     for l in c.split('\n'):  
       semi = l.find(';')  
       if (semi != -1):  
         l = l[:semi]  
       hash = l.find('#')  
       if (hash != -1):  
         l = l[:hash]  
       # Look for the keyword  
       l = l.strip()  
       spl = l.split(None,1)  
       if len(spl) > 1:  
         if spl[0].capitalize() == keyword.capitalize():  
           arg = spl[1]  
           if arg.startswith('"') and arg.endswith('"'):  
             arg = arg[1:-1]  
           if multiple:  
             stuff += [ arg ]  
           else:  
             return arg  
   return stuff  
   
   
 def nsis_path( filename, nsisdefines, rootdir ):  
   """  
   Do environment replacement, and prepend with the SCons root dir if  
   necessary  
   """  
   # We can't do variables defined by NSIS itself (like $INSTDIR),  
   # only user supplied ones (like ${FOO})  
   varPos = filename.find('${')  
   while varPos != -1:  
     endpos = filename.find('}',varPos)  
     assert endpos != -1  
     if not nsisdefines.has_key(filename[varPos+2:endpos]):  
       raise KeyError ("Could not find %s in NSISDEFINES" % filename[varPos+2:endpos])  
     val = nsisdefines[filename[varPos+2:endpos]]  
     if type(val) == list:  
       if varPos != 0 or endpos+1 != len(filename):  
         raise Exception("Can't use lists on variables that aren't complete filenames")  
       return val  
     filename = filename[0:varPos] + val + filename[endpos+1:]  
     varPos = filename.find('${')  
   return filename  
   
   
 def nsis_scanner( node, env, path ):  
   """  
   The scanner that looks through the source .nsi files and finds all lines  
   that are the 'File' command, fixes the directories etc, and returns them.  
   """  
   nodes = node.rfile()  
   if not node.exists():  
     return []  
   nodes = []  
   source_dir = node.get_dir()  
   for include in nsis_parse([node],'file',1):  
     exp = nsis_path(include,env['NSISDEFINES'],source_dir)  
     if type(exp) != list:  
       exp = [exp]  
     for p in exp:  
       for filename in glob.glob( os.path.abspath(  
         os.path.join(str(source_dir),p))):  
           # Why absolute path?  Cause it breaks mysteriously without it :(  
           nodes.append(filename)  
   return nodes  
   
   
 def nsis_emitter( source, target, env ):  
   """  
   The emitter changes the target name to match what the command actually will  
   output, which is the argument to the OutFile command.  
   """  
   nsp = nsis_parse(source,'outfile',0)  
   if not nsp:  
     return (target,source)  
   x  = (  
     nsis_path(nsp,env['NSISDEFINES'],''),  
     source)  
   return x  
   
 def quoteIfSpaced(text):  
   if ' ' in text:  
     return '"'+text+'"'  
   else:  
     return text  
   
 def toString(item,env):  
   if type(item) == list:  
     ret = ''  
     for i in item:  
       if ret:  
         ret += ' '  
       val = toString(i,env)  
       if ' ' in val:  
         val = "'"+val+"'"  
       ret += val  
     return ret  
   else:  
     # For convienence, handle #s here  
     if str(item).startswith('#'):  
       item = env.File(item).get_abspath()  
     return str(item)  
   
 def runNSIS(source,target,env,for_signature):  
   ret = env['NSIS']+" "  
   if env.has_key('NSISFLAGS'):  
     for flag in env['NSISFLAGS']:  
       ret += flag  
       ret += ' '  
   if env.has_key('NSISDEFINES'):  
     for d in env['NSISDEFINES']:  
       ret += '/D'+d  
       if env['NSISDEFINES'][d]:  
         ret +='='+quoteIfSpaced(toString(env['NSISDEFINES'][d],env))  
       ret += ' '  
   for s in source:  
     ret += quoteIfSpaced(str(s))  
   return ret  
   
 def find_nsis(env):  
   """  
   Try and figure out if NSIS is installed on this machine, and if so,  
   where.  
   """  
   if SCons.Util.can_read_reg:  
     # If we can read the registry, get the NSIS command from it  
     try:  
       k = SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,  
                                   'SOFTWARE\\NSIS')  
       val, tok = SCons.Util.RegQueryValueEx(k,None)  
       ret = val + os.path.sep + 'makensis.exe'  
       if os.path.exists(ret):  
         return '"' + ret + '"'  
       else:  
         return None  
     except:  
       pass # Couldn't find the key, just act like we can't read the registry  
   # Hope it's on the path  
   return env.WhereIs('makensis.exe')  
   
 def nsis_exists(env):  
   """  
   Is NSIS findable on this machine?  
   """  
   if find_nsis(env) != None:  
     return 1  
   return 0  
   
 env['BUILDERS']['Nsis'] = SCons.Builder.Builder(generator=runNSIS,  
                                  src_suffix='.nsi',  
                                  emitter=nsis_emitter)  
   
 env.Append(SCANNERS = SCons.Scanner.Scanner( function = nsis_scanner,  
              skeys = ['.nsi']))  
   
 if not env.has_key('NSISDEFINES'):  
     env['NSISDEFINES'] = {}  
 env['NSIS'] = find_nsis(env)  
1826    
1827  #------------------------------------------------------  #------------------------------------------------------
1828  # BUILD...  # BUILD...
1829    
1830  # so that #include <modulename/headername.h> works across all modules...  # so that #include <modulename/headername.h> works across all modules...
1831  env.Append(CPPPATH=['#base/generic'])  env.AppendUnique(CPPPATH=['#base/generic'])
   
 if gcc_version4:  
     env.Append(CCFLAGS=['-fvisibility=hidden'])  
1832    
1833  if env['DEBUG']:  if env['DEBUG']:
1834      env.Append(CCFLAGS=['-g'])      env.Append(CCFLAGS=['-g'])
1835    
1836    if env['GCOV']:
1837        env.Append(
1838            CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
1839            , LIBS=['gcov']
1840            , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
1841        )
1842    
1843    if with_ida:
1844        env.Append(WITH_IDA=1)
1845    
1846    if with_conopt:
1847        env.Append(WITH_CONOPT=1)
1848    
1849  #-------------  #-------------
1850  # TCL/TK GUI  # TCL/TK GUI
1851    
1852  if with_tcltk:  if with_tcltk:
1853      if with_local_blas:      env.SConscript(['tcltk/generic/interface/SConscript'],'env')
         env.SConscript(['blas/SConscript'],'env')  
     else:  
         print "Skipping... BLAS won't be build:", without_local_blas_reason  
   
     env.SConscript(['lsod/SConscript'],'env')        
   
     env.SConscript(['linpack/SConscript'],'env')  
     env.SConscript(['tcltk98/generic/interface/SConscript'],'env')  
1854  else:  else:
1855      print "Skipping... Tcl/Tk GUI isn't being built:",without_tcltk_reason      print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
1856    
1857  #-------------  #-------------
1858  # PYTHON INTERFACE  # PYTHON INTERFACE
# Line 1213  else: Line 1860  else:
1860  if with_python:  if with_python:
1861      env.SConscript(['pygtk/SConscript'],'env')      env.SConscript(['pygtk/SConscript'],'env')
1862  else:  else:
1863      print "Skipping... Python GUI isn't being built:",without_python_reason      print "Skipping... Python bindings aren't being built:",without_python_reason
1864    
1865  #------------  #------------
1866  # BASE/GENERIC SUBDIRECTORIES  # BASE/GENERIC SUBDIRECTORIES
1867    
1868    libascend_env = env.Copy()
1869    
1870  dirs = ['general','utilities','compiler','solver','packages']  dirs = ['general','utilities','compiler','solver','packages']
1871    
1872  srcs = []  srcs = []
1873  for d in dirs:  for d in dirs:
1874      heresrcs = env.SConscript('base/generic/'+d+'/SConscript','env')      heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
1875      srcs += heresrcs      srcs += heresrcs
1876    
1877  #-------------  #-------------
1878    # IMPORTED CODE: LSODE, BLAS, etc
1879    
1880    if with_lsode:
1881        srcs += env.SConscript(['lsod/SConscript'],'env')
1882        srcs += env.SConscript(['linpack/SConscript'],'env')
1883    else:
1884        print "Skipping... LSODE won't be built:", without_lsode_reason
1885    
1886    if with_local_blas:
1887        srcs += env.SConscript(['blas/SConscript'],'env')
1888    else:
1889        print "Skipping... BLAS won't be built:", without_local_blas_reason
1890    
1891    if not with_ida:
1892        print "Skipping... IDA won't be built:", without_ida_reason
1893    
1894    if with_mmio:
1895        srcs += env.SConscript(['mmio/SConscript'],'env')
1896    else:
1897        print "Skipping... MMIO export won't be built:", without_mmio_reason
1898    #-------------
1899  # LIBASCEND -- all base/generic functionality  # LIBASCEND -- all base/generic functionality
1900    
1901  libascend = env.SharedLibrary('ascend',srcs)  if with_dmalloc:
1902        libascend_env.Append(LIBS=['dmalloc'])
1903    
1904    libascend = libascend_env.SharedLibrary('ascend',srcs)
1905    
1906    env.Alias('libascend',libascend)
1907    
1908  #-------------  #-------------
1909  # UNIT TESTS  # UNIT TESTS (C CODE)
1910    
1911  if with_cunit_tests:  if with_cunit:
1912      testdirs = ['general','solver','utilities']      testdirs = ['general','solver','utilities']
1913        testsrcs = []
1914      for testdir in testdirs:      for testdir in testdirs:
1915          path = 'base/generic/'+testdir+'/test/'          path = 'base/generic/'+testdir+'/test/'
1916          env.SConscript([path+'SConscript'],'env')          env.SConscript([path+'SConscript'],'env')
1917            testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
1918    
1919        #print "TESTSRCS =",testsrcs
1920            
1921      env.SConscript(['test/SConscript'],'env')      env.SConscript(['test/SConscript'],'env')
1922      env.SConscript(['base/generic/test/SConscript'],'env')      env.SConscript(['base/generic/test/SConscript'],'env')
1923        
1924        env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
1925            
1926  else:  else:
1927      print "Skipping... CUnit tests aren't being built:",without_cunit_reason      print "Skipping... CUnit tests aren't being built:",without_cunit_reason
1928    
1929    #-------------
1930    # EXTERNAL FUNCTIONS
1931    
1932    env['extfns']=[]
1933    modeldirs = env.SConscript(['models/SConscript'],'env')
1934    
1935    if not with_extfns:
1936        print "Skipping... External modules aren't being built:",without_extfns_reason
1937    
1938    env.Alias('extfns',env['extfns'])
1939    
1940    #------------------------------------------------------
1941    # CREATE ASCEND-CONFIG scriptlet
1942    
1943    ascendconfig = env.SubstInFile('ascend-config.in')
1944    
1945  #------------------------------------------------------  #------------------------------------------------------
1946  # INSTALLATION  # INSTALLATION
1947    
1948  if env.get('CAN_INSTALL'):  if env.get('CAN_INSTALL'):
     # the models directory only needs to be processed for installation, no other processing required.  
     env.SConscript(['models/SConscript'],'env')  
1949    
1950      dirs = ['INSTALL_BIN','INSTALL_DATA','INSTALL_LIB']      dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE', 'INSTALL_DOC']
1951      install_dirs = [env['INSTALL_ROOT']+env[d] for d in dirs]      install_dirs = [env.Entry(env['INSTALL_ROOT']+env[d]) for d in dirs]
1952        install_dirs += modeldirs
1953    
1954      # TODO: add install options      # TODO: add install options
1955      env.Alias('install',install_dirs)      env.Alias('install',install_dirs)
1956    
1957      env.Install(env['INSTALL_ROOT']+env['INSTALL_LIB'],libascend)      env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_LIB'],libascend)
1958    
1959        env.InstallProgram(env['INSTALL_ROOT']+env['INSTALL_BIN'],ascendconfig)
1960    
1961    #------------------------------------------------------
1962    # WINDOWS INSTALLER
1963    # For the windows installer, please see pygtk/SConscript
1964    
1965    if with_installer:
1966        pass
1967    else:
1968        print "Skipping... Windows installer isn't being built:",without_installer_reason
1969    
1970    #------------------------------------------------------
1971    # PROJECT FILE for MSVC
1972    
1973    env.SConscript(['base/msvc/SConscript'],['env','libascend']);
1974    
1975  #------------------------------------------------------  #------------------------------------------------------
1976  # CREATE the SPEC file for generation of RPM packages  # CREATE the SPEC file for generation of RPM packages
# Line 1268  if platform.system()=="Linux": Line 1979  if platform.system()=="Linux":
1979      env.SubstInFile('ascend.spec.in')      env.SubstInFile('ascend.spec.in')
1980    
1981  #------------------------------------------------------  #------------------------------------------------------
1982    # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
1983    
1984    if with_scrollkeeper:
1985        env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
1986        env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
1987    
1988    #------------------------------------------------------
1989  # DISTRIBUTION TAR FILE  # DISTRIBUTION TAR FILE
1990    
1991  env['DISTTAR_FORMAT']='bz2'  env['DISTTAR_FORMAT']='bz2'
1992  env.Append(  env.Append(
1993      DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.cc','.cache','.pyc','.cvsignore','.dblite','.log']      DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.cc','.cache','.pyc','.cvsignore','.dblite','.log','.pl','.out']
1994      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist']      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist']
1995  )  )
1996    
1997  tar = env.DistTar("dist/ascend-"+version  tar = env.DistTar("dist/"+env['DISTTAR_NAME']
1998      , [env.Dir('#')]      , [env.Dir('#')]
1999  )  )
2000    
2001    env.Depends(tar,'ascend.spec')
2002    
2003    Alias('dist',tar)
2004    
2005    #------------------------------------------------------
2006    # USER'S MANUAL
2007    
2008    env.SConscript('doc/SConscript',['env'])
2009    
2010    #------------------------------------------------------
2011    # LIBASCEND DOXYGEN DOCUMENTATION
2012    
2013    env.SConscript('base/doc/SConscript',['env'])
2014    
2015  #------------------------------------------------------  #------------------------------------------------------
2016  # RPM BUILD  # RPM BUILD
2017    
2018  #if platform.system()=="Linux":  # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
2019  #   pass  # (check * for the version number used to create the tarball)
2020    
2021  #------------------------------------------------------  #------------------------------------------------------
2022  # DEFAULT TARGETS  # DEFAULT TARGETS
2023    
2024  env.Default(['pygtk','tcltk98'])  default_targets =['libascend']
2025    if with_tcltk:
2026        default_targets.append('tcltk')
2027    if with_python:
2028        default_targets.append('pygtk')
2029    if with_installer:
2030        default_targets.append('installer')
2031    if with_extfns:
2032        default_targets.append('extfns')
2033    
2034    env.Default(default_targets)
2035    
2036    print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2037    
2038    # vim: set syntax=python:
2039    

Legend:
Removed from v.562  
changed lines
  Added in v.993

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