/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 1387 by jpye, Sat Apr 7 14:43:31 2007 UTC revision 2001 by jpye, Thu Feb 26 23:47:49 2009 UTC
# Line 1  Line 1 
1  import sys, os, commands, platform, distutils.sysconfig, os.path, re  import sys, os, commands, platform, distutils.sysconfig, os.path, re, types
2    version = "0.9.5.116"
3    
4  version = "0.9.5.108"  pyversion = "%d.%d" % (sys.version_info[0],sys.version_info[1])
5    
6  #------------------------------------------------------  #------------------------------------------------------
7  # OPTIONS  # OPTIONS
# Line 11  version = "0.9.5.108" Line 12  version = "0.9.5.108"
12  opts = Options(['options.cache', 'config.py'])  opts = Options(['options.cache', 'config.py'])
13  #print "PLATFORM = ",platform.system()  #print "PLATFORM = ",platform.system()
14    
15    default_tcl_cpppath = "$TCL/include"
16    default_tron_envvar="TRON_PATH"
17    default_conopt_envvar="CONOPT_PATH"
18    default_with_graphviz = True
19    
20  if platform.system()=="Windows":  if platform.system()=="Windows":
21      default_tcl_lib = "tcl84"      default_tcl_lib = "tcl84"
22      default_tk_lib = "tk84"      default_tk_lib = "tk84"
# Line 18  if platform.system()=="Windows": Line 24  if platform.system()=="Windows":
24      default_install_assets = "glade/"      default_install_assets = "glade/"
25      icon_extension = '.png'      icon_extension = '.png'
26      default_tcl = "c:\\Tcl"      default_tcl = "c:\\Tcl"
27      if os.environ.get('MSYSTEM')=="MINGW32":      if os.environ.get('MSYSTEM'):
28          default_tcl_libpath="$TCL\\bin"          default_tcl_libpath="$TCL\\bin"
29      else:      else:
30          default_tcl_libpath="$TCL\\lib"          default_tcl_libpath="$TCL\\lib"
# Line 32  if platform.system()=="Windows": Line 38  if platform.system()=="Windows":
38      default_conopt_prefix = "c:\\Program Files\\CONOPT"      default_conopt_prefix = "c:\\Program Files\\CONOPT"
39      default_conopt_libpath="$CONOPT_PREFIX"      default_conopt_libpath="$CONOPT_PREFIX"
40      default_conopt_cpppath="$CONOPT_PREFIX"      default_conopt_cpppath="$CONOPT_PREFIX"
41        default_conopt_dlpath="$CONOPT_PREFIX"
42      default_conopt_lib="conopt3"      default_conopt_lib="conopt3"
43      default_conopt_envvar="CONOPT_PATH"  
44        default_tron_prefix="c:\\Program Files\\TRON"
45        default_tron_dlpath="$TRON_PREFIX"
46        default_tron_lib="tron1"
47    
48      default_prefix="c:\\MinGW"      default_prefix="c:\\MinGW"
49      default_libpath="$DEFAULT_PREFIX\\lib"      default_libpath="$DEFAULT_PREFIX\\lib"
# Line 43  if platform.system()=="Windows": Line 53  if platform.system()=="Windows":
53          default_conopt_prefix = None          default_conopt_prefix = None
54                    
55      need_libm = False      need_libm = False
56      python_exe = "c:\\Python24\\python.exe"      python_exe = sys.executable
57      default_with_scrollkeeper=False      default_with_scrollkeeper=False
58        pathsep = ";"
59        
60        default_fortran="g77"
61        default_f2c_lib="g2c"
62        
63        # still problems with Graphviz on Windows, leave it off now by default.
64        
65  else:  else:
66      default_tcl_lib = "tcl8.4"      default_tcl_lib = "tcl8.5"
67      default_tk_lib = "tk8.4"      default_tk_lib = "tk8.5"
68      default_tktable_lib = "Tktable2.8"      default_tktable_lib = "Tktable2.9"
69      default_install_assets = "$INSTALL_ASCDATA/glade/"      default_install_assets = "$INSTALL_ASCDATA/glade/"
70      icon_extension = '.svg'      icon_extension = '.svg'
71      default_tcl = '/usr'      default_tcl = '/usr'
72      default_tcl_libpath = "$TCL/lib"          default_tcl_libpath = "$TCL/lib"
73    
74        if os.path.exists("/etc/debian_version"):
75            default_tcl_cpppath = "/usr/include/tcl8.4"
76            default_tcl_lib = "tcl8.4"
77            default_tk_lib = "tk8.4"
78            default_tktable_lib = "Tktable2.8"
79    
80      default_rel_distdir = '../share/ascend'      default_rel_distdir = '../share/ascend'
81      default_absolute_paths = True      default_absolute_paths = True
82      default_ida_prefix="/usr/local"      default_ida_prefix="/usr"
83      default_conopt_prefix="/usr"      default_conopt_prefix="/usr"
84      default_conopt_libpath="$CONOPT_PREFIX/lib"      default_conopt_libpath="$CONOPT_PREFIX/lib"
85      default_conopt_cpppath="$CONOPT_PREFIX/include"      default_conopt_cpppath="$CONOPT_PREFIX/include"
86        default_conopt_dlpath= default_conopt_libpath + ":/usr/local/lib"
87      default_conopt_lib="consub3"      default_conopt_lib="consub3"
88      default_conopt_envvar="CONOPT_PATH"  
89        default_tron_prefix="/usr"
90        default_tron_dlpath="$TRON_PREFIX/lib"
91        default_tron_lib="tron1"
92    
93      default_prefix="/usr"      default_prefix="/usr"
94      default_libpath="$DEFAULT_PREFIX/lib"      default_libpath="$DEFAULT_PREFIX/lib"
# Line 71  else: Line 99  else:
99          default_tcl = '/usr'          default_tcl = '/usr'
100      python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"      python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"
101      default_with_scrollkeeper=False      default_with_scrollkeeper=False
102        pathsep = ":"
103        
104        default_fortran="gfortran"
105        default_f2c_lib="gfortran"
106    
107        
108        #default_graphviz_libs=["graph","cdt","gvc"]
109        #default_graphviz_libpath = default_libpath
110        #if os.path.exists("/usr/lib/graphviz/libgraph.so"):
111        #   # for Ubuntu 7.04
112        #   default_graphviz_libpath="/usr/lib/graphviz"
113        #   default_graphviz_rpath="$GRAPHVIZ_LIBPATH"
114        
115  opts.Add(  opts.Add(
116      'CC'      'CC'
117      ,'C Compiler command'      ,'C Compiler command'
# Line 90  opts.Add(BoolOption( Line 130  opts.Add(BoolOption(
130      , False      , False
131  ))  ))
132    
 # Package linking option  
 opts.Add(EnumOption(  
     'PACKAGE_LINKING'  
     , 'Style of linking for external libraries'  
     , 'DYNAMIC_PACKAGES'  
     , ['DYNAMIC_PACKAGES', 'STATIC_PACKAGES', 'NO_PACKAGES']  
 ))  
   
133  opts.Add(BoolOption(  opts.Add(BoolOption(
134      'WITH_GCCVISIBILITY'      'WITH_GCCVISIBILITY'
135      ,"Whether to use GCC Visibility features (only applicable if available)"      ,"Whether to use GCC Visibility features (only applicable if available)"
# Line 128  opts.Add(BoolOption( Line 160  opts.Add(BoolOption(
160  opts.Add(ListOption(  opts.Add(ListOption(
161      'WITH_SOLVERS'      'WITH_SOLVERS'
162      ,"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"  
163          +" works."          +" works. The option 'LSOD' is provided for backwards compatibility"
164      ,["QRSLV","CMSLV","LSOD","IDA","CONOPT","LRSLV"]          +"; the value 'LSODE' is preferred."
165        ,["QRSLV","CMSLV","LSODE","IDA","CONOPT","LRSLV","TRON","IPOPT","DOPRI5"]
166      ,['QRSLV','MPS','SLV','OPTSQP'      ,['QRSLV','MPS','SLV','OPTSQP'
167          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
168          ,'LSOD','OPTSQP',"IDA"          ,'LSODE','LSOD','OPTSQP',"IDA","TRON","IPOPT","DOPRI5"
169       ]       ]
170  ))  ))
171    
172  # Where will the local copy of the help files be kept?  # Where will the local copy of the help files be kept?
173  opts.Add(PackageOption(  opts.Add(BoolOption(
174      'WITH_LOCAL_HELP'      'WITH_DOC'
175      , "Directory containing the local copy of the help files (optional)"      , "Should we try to build and install help files? If not, ASCEND will access online help files"
176      , "no"      , True
177    ))
178    
179    opts.Add(BoolOption(
180        'WITH_DOC_BUILD'
181        , "If true, we'll attempt to build docs. Set false, we'll assume we already have then (eg from the tarball)"
182        , "$WITH_DOC"
183    ))
184    
185    opts.Add(BoolOption(
186        'WITH_DOC_INSTALL'
187        , "If true, SCons will install the documentation file(s). If false, assume rpm or dpkg is going to do it."
188        , "$WITH_DOC"
189  ))  ))
190    
191    opts.Add(
192        'HELP_ROOT'
193        , "Location of the main help file"
194        , "$INSTALL_DOC/book.pdf"
195    )
196    
197  # Will bintoken support be enabled?  # Will bintoken support be enabled?
198  opts.Add(BoolOption(  opts.Add(BoolOption(
199      'WITH_BINTOKEN'      'WITH_BINTOKEN'
# Line 157  opts.Add( Line 208  opts.Add(
208      'DEFAULT_ASCENDLIBRARY'      'DEFAULT_ASCENDLIBRARY'
209      ,"Set the default value of the ASCENDLIBRARY -- the location where"      ,"Set the default value of the ASCENDLIBRARY -- the location where"
210          +" ASCEND will look for models when running ASCEND"          +" ASCEND will look for models when running ASCEND"
211      ,"$INSTALL_ASCDATA/models"      ,"$INSTALL_MODELS"
212    )
213    
214    # What should the default ASCENDLIBRARY path be?
215    # Note: users can change it by editing their ~/.ascend.ini
216    opts.Add(
217        'DEFAULT_ASCENDSOLVERS'
218        ,"Set the default value of ASCENDSOLVERS -- the location where"
219            +" ASCEND will look for solver shared-library files"
220        ,"$INSTALL_SOLVERS"
221  )  )
222    
223  # Where is SWIG?  # Where is SWIG?
# Line 222  opts.Add(PackageOption( Line 282  opts.Add(PackageOption(
282  #-------- ida -------  #-------- ida -------
283    
284  opts.Add(PackageOption(  opts.Add(PackageOption(
285      "IDA_PREFIX"      "SUNDIALS_PREFIX"
286      ,"Prefix for your IDA install (IDA ./configure --prefix)"      ,"Prefix for your IDA install (IDA ./configure --prefix)"
287      ,default_ida_prefix      ,default_ida_prefix
288  ))  ))
289    
290  opts.Add(  opts.Add(
291      "IDA_LIB"      'SUNDIALS_CPPPATH'
292      ,"Libraries linked to for IDA"      ,"Where is your ida.h?"
293      ,['sundials_nvecserial','sundials_ida','m']      ,"$SUNDIALS_PREFIX/include"
294  )  )
295    
296    #
297  opts.Add(  opts.Add(
298      'IDA_CPPPATH'      'SUNDIALS_LIBPATH'
299      ,"Where is your ida.h?"      ,"Where are your SUNDIALS libraries installed?"
300      ,"$IDA_PREFIX/include"      ,"$SUNDIALS_PREFIX/lib"
301  )  )
302    
303  opts.Add(  opts.Add(
304      'IDA_LIBPATH'      'SUNDIALS_LIBS'
305      ,"Where are your SUNDIALS libraries installed?"      ,"What libraries are required for SUNDIALS?"
306      ,"$IDA_PREFIX/lib"      ,['sundials_nvecserial','sundials_ida','m']
307  )  )
308    
309  # ----- conopt-----  # ----- conopt-----
# Line 255  opts.Add(PackageOption( Line 316  opts.Add(PackageOption(
316    
317  opts.Add(  opts.Add(
318      "CONOPT_LIB"      "CONOPT_LIB"
319      ,"Library linked to for CONOPT"      ,"Library linked to for CONOPT. This is the name of the CONOPT .so or DLL. On Windows it seems to be called 'copopt3' but on linux it seems to be called 'consub3'."
320      ,default_conopt_lib      ,default_conopt_lib
321  )  )
322    
323    opts.Add(BoolOption(
324        "CONOPT_LINKED"
325        ,"Do you want to dynamically link to CONOPT (only possible if CONOPT is available at buildtime)"
326        ,False
327    ))
328    
329  opts.Add(  opts.Add(
330      'CONOPT_CPPPATH'      'CONOPT_CPPPATH'
331      ,"Where is your conopt.h?"      ,"Where is your conopt.h?"
# Line 267  opts.Add( Line 334  opts.Add(
334    
335  opts.Add(  opts.Add(
336      'CONOPT_LIBPATH'      'CONOPT_LIBPATH'
337      ,"Where is your CONOPT libraries installed?"      ,"Where is your CONOPT library installed?"
338      ,default_conopt_libpath      ,default_conopt_libpath
339  )  )
340    
341  opts.Add(  opts.Add(
342        'CONOPT_DLPATH'
343        ,"Default (fallback) search path that ASCEND should use when dlopening the CONOPT library at runtime? This is only used if the conopt environment variable doesn't exist and doesn't point to a location where the DLL/SO is found.  This is in platform-specific form (paths with ';' separator in Windows, ':' separator on Linux)."
344        ,default_conopt_dlpath
345    )
346    
347    opts.Add(
348      'CONOPT_ENVVAR'      'CONOPT_ENVVAR'
349      ,"What environment variable should be used at runtime to override the default search location for CONOPT DLL/SO?"      ,"Name of the optional environment variable which will be used for the value of the searchpath for the CONOPT DLL/SO."
350      ,default_conopt_envvar      ,default_conopt_envvar
351  )  )
352    
353    #------- IPOPT -------
354    
355    opts.Add(PackageOption(
356        "IPOPT_PREFIX"
357        ,"Prefix for your IPOPT install (IPOPT ./configure --prefix)"
358        ,default_conopt_prefix
359    ))
360    
361    opts.Add(
362        "IPOPT_LIBS"
363        ,"Library linked to for IPOPT"
364        ,["$F2C_LIB","blas","lapack","pthread","ipopt"]
365    )
366    
367    
368    opts.Add(
369        "IPOPT_LIBPATH"
370        ,"Where is your IPOPT library installed"
371        ,"$IPOPT_PREFIX/lib"
372    )
373    
374    opts.Add(
375        'IPOPT_CPPPATH'
376        ,"Where is your IPOPT coin/IpStdCInterface.h (do not include the 'coin' in the path)"
377        ,"$IPOPT_PREFIX/include"
378    )
379    
380    
381    #------- TRON -------
382    
383    opts.Add(
384        'TRON_ENVVAR'
385        ,"What environment variable should be used at runtime to override the default search location for TRON DLL/SO?"
386        ,default_tron_envvar
387    )
388    
389    opts.Add(
390        "TRON_LIB"
391        ,"Library linked to for TRON"
392        ,"tron"
393    )
394    
395    opts.Add(
396        "TRON_PREFIX"
397        ,"Prefix for your TRON install"
398        ,default_tron_prefix
399    )
400    
401    opts.Add(
402        'TRON_DLPATH'
403        ,"What is the default search path that ASCEND should use when dlopening the TRON library at runtime?"
404        ,default_tron_dlpath
405    )
406    
407  #-------- f2c ------  #-------- f2c ------
408    
409  opts.Add(  opts.Add(
410      "F2C_LIB"      "F2C_LIB"
411      ,"F2C library (eg. g2c, gfortran, f2c)"      ,"F2C library (eg. g2c, gfortran, f2c)"
412      ,"gfortran" # the default is gfortran now      ,default_f2c_lib # the default is gfortran now
413  )  )
414    
415  opts.Add(PackageOption(  opts.Add(PackageOption(
# Line 291  opts.Add(PackageOption( Line 418  opts.Add(PackageOption(
418      ,"off"      ,"off"
419  ))  ))
420    
421    opts.Add(
422        "FORTRAN"
423        ,"Fortran compiler (eg g77, gfortran)"
424        ,default_fortran
425    )
426    
427  #------- tcl/tk --------  #------- tcl/tk --------
428    
429  opts.Add(  opts.Add(
# Line 303  opts.Add( Line 436  opts.Add(
436  opts.Add(  opts.Add(
437      'TCL_CPPPATH'      'TCL_CPPPATH'
438      ,"Where are your Tcl include files?"      ,"Where are your Tcl include files?"
439      ,"$TCL/include"      ,default_tcl_cpppath
440  )  )
441    
442  # Where are the Tcl libs?  # Where are the Tcl libs?
# Line 424  opts.Add( Line 557  opts.Add(
557  )  )
558    
559  opts.Add(  opts.Add(
560        'INSTALL_MODELS'
561        ,"Location of ASCEND model files (.a4c,.a4l,.a4s)"
562        ,"$INSTALL_ASCDATA/models"
563    )
564    
565    opts.Add(
566        'INSTALL_SOLVERS'
567        ,"Location of ASCEND solvers"
568        ,"$INSTALL_ASCDATA/solvers"
569    )
570    
571    opts.Add(
572        'INSTALL_DOC'
573        ,"Location of ASCEND documentation files"
574        ,"$INSTALL_SHARE/doc/ascend-"+version
575    )
576    
577    opts.Add(
578      'INSTALL_INCLUDE'      'INSTALL_INCLUDE'
579      ,'Location to put header files during installation'      ,'Location to put header files during installation'
580      ,"$INSTALL_PREFIX/include"      ,"$INSTALL_PREFIX/include"
# Line 436  opts.Add( Line 587  opts.Add(
587      ,""      ,""
588  )  )
589    
590    opts.Add(
591        'EXTLIB_SUFFIX'
592        ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
593        ,"_ascend$SHLIBSUFFIX"
594    )
595    
596    opts.Add(
597        'EXTLIB_PREFIX'
598        ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
599        ,"$SHLIBPREFIX"
600    )
601    
602  #----------------------  #----------------------
603    
604  opts.Add(  opts.Add(
# Line 481  opts.Add(BoolOption( Line 644  opts.Add(BoolOption(
644      ,False      ,False
645  ))  ))
646    
647  #------ f --------  #------ Graphviz --------
648  opts.Add(PackageOption(  #   opts.Add(PackageOption(
649      'MFGRAPH_PREFIX'  #       'GRAPHVIZ_PREFIX'
650      ,"Where are your MFGRAPH files?"  #       ,"Where are your GRAPHVIZ files?"
651      ,default_prefix  #       ,default_prefix
652  ))  #   ))
653    #
654  opts.Add(PackageOption(  #   opts.Add(PackageOption(
655      'MFGRAPH_CPPPATH'  #       'GRAPHVIZ_CPPPATH'
656      ,"Where are your MFGRAPH include files?"  #       ,"Where are your GRAPHVIZ include files? (don't need the final '/graphviz')"
657      ,default_cpppath  #       ,default_cpppath
658  ))  #   ))
659    #
660  opts.Add(PackageOption(  #   opts.Add(PackageOption(
661      'MFGRAPH_LIBPATH'  #       'GRAPHVIZ_LIBPATH'
662      ,"Where are your MFGRAPH libraries?"  #       ,"Where are your GRAPHVIZ libraries?"
663      ,default_libpath  #       ,default_graphviz_libpath
664  ))  #   ))
665    #
666    #   opts.Add(
667    #       'GRAPHVIZ_LIBS'
668    #       ,"What are your GRAPHVIZ libraries named?"
669    #       ,default_graphviz_libs
670    #   )
671    #
672    #   opts.Add(PackageOption(
673    #       'GRAPHVIZ_RPATH'
674    #       ,"What is your GRAPHVIZ rpath for locating libraries at runtime? (only required for old Ubuntu)"
675    #       ,default_graphviz_rpath
676    #   ))
677    
678  opts.Add(BoolOption(  opts.Add(BoolOption(
679      'WITH_MFGRAPH'      'WITH_GRAPHVIZ'
680      ,"Link to the MFGRAPH library (if available, for generating incidence graphs)"      ,"Link to the GRAPHVIZ library (if available, for generating incidence graphs)"
681      ,True      ,default_with_graphviz
682  ))  ))
683    
684    
# Line 534  opts.Add(BoolOption( Line 709  opts.Add(BoolOption(
709    
710  #-----------------------  #-----------------------
711    
712    opts.Add(BoolOption(
713        'UPDATE_NO_YACC_LEX'
714        ,"Update the *_no_yacc* and *_no_lex* files in the source tree? (these files are created so that ASCEND can be compiled in the absence of those tools)"
715        ,False
716    ))
717    
718  opts.Add(  opts.Add(
719      'DISTTAR_NAME'      'DISTTAR_NAME'
720      ,"Stem name of the tarball created by 'scons dist'. So for 'ascend-aaa.tar.bz2', set this to 'ascend-aaa'."      ,"Stem name of the tarball created by 'scons dist'. So for 'ascend-aaa.tar.bz2', set this to 'ascend-aaa'."
# Line 555  opts.Add(BoolOption( Line 736  opts.Add(BoolOption(
736  opts.Add(  opts.Add(
737      'WIN_INSTALLER_NAME'      'WIN_INSTALLER_NAME'
738      ,"Name of the installer .exe to create under Windows (minus the '.exe')"      ,"Name of the installer .exe to create under Windows (minus the '.exe')"
739      ,"ascend-"+version      ,"ascend-"+version+"-py"+pyversion+".exe"
740  )  )
741    
742  opts.Add(BoolOption(  opts.Add(BoolOption(
# Line 566  opts.Add(BoolOption( Line 747  opts.Add(BoolOption(
747    
748  opts.Add(BoolOption(  opts.Add(BoolOption(
749      'WITH_EXTFNS'      'WITH_EXTFNS'
750      ,"Set to 0 if you don't want to attempt to build external modules bundled"      ,"Set to 0 if you don't want to attempt to build the external modules bundled with ASCEND"
         + " with ASCEND."  
751      ,True      ,True
752  ))  ))
753    
# Line 577  opts.Add(BoolOption( Line 757  opts.Add(BoolOption(
757      ,default_with_scrollkeeper      ,default_with_scrollkeeper
758  ))  ))
759    
760    opts.Add(BoolOption(
761        'WITH_MSVCR71'
762        ,"Attempt to link against MSVCR71.DLL, to enable passing of FILE* objects to/from python"
763        ,False
764    ))
765    
766  if platform.system()!="Windows":  if platform.system()!="Windows":
767      opts.Add(BoolOption(      opts.Add(BoolOption(
768          'WITH_GCCVISIBILITY'          'WITH_GCCVISIBILITY'
# Line 598  def c_escape(str): Line 784  def c_escape(str):
784    
785  envadditional={}  envadditional={}
786    
787    tools = [
788        'lex', 'yacc', 'fortran', 'swig', 'nsis', 'substinfile'
789        ,'disttar', 'tar', 'graphviz'
790    ]
791  if platform.system()=="Windows":  if platform.system()=="Windows":
792      if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):      if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
793          envenv = os.environ;          envenv = os.environ;
794          tools = ['mingw','lex','yacc','fortran','swig','disttar','nsis']          tools += ['mingw']
795          #TODO removed 'doxygen' for SCons 0.96.93          #TODO removed 'doxygen' for SCons 0.96.93
796          envadditional['IS_MINGW']=True          envadditional['IS_MINGW']=True
797      else:      else:
# Line 612  if platform.system()=="Windows": Line 802  if platform.system()=="Windows":
802              ,'LIB':os.environ['LIB']              ,'LIB':os.environ['LIB']
803              ,'MSVS_IGNORE_IDE_PATHS':1              ,'MSVS_IGNORE_IDE_PATHS':1
804          }          }
805          tools=['default','lex','yacc','fortran','swig','disttar','nsis']              tools += ['default']
806          #TODO removed 'doxygen' for SCons 0.96.93          #TODO removed 'doxygen' for SCons 0.96.93
807          envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']          envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
808  else:  else:
809      if os.environ.get('TARGET')=='mingw':      if os.environ.get('TARGET')=='mingw':
810          envenv = os.environ          envenv = os.environ
811          tools=['crossmingw','lex','yacc','disttar','nsis','doxygen']          tools += ['crossmingw']
812          envadditional['CPPPATH']=['/usr/local/lib/gcc/i386-mingw32/3.4.5/include','/usr/include']          envadditional['CPPPATH']=['/usr/lib/gcc/i586-mingw32msvc/3.4.5/include','/usr/include']
813            envadditional['LIBS']=['gcc']
814      else:      else:
815          envenv = os.environ          envenv = os.environ
816          tools=['default','lex','yacc','fortran','swig','disttar','nsis']          tools += ['default']
817          #TODO removed 'doxygen' for SCons 0.96.93          #TODO removed 'doxygen' for SCons 0.96.93
818            
819            
# Line 633  env = Environment( Line 824  env = Environment(
824      , **envadditional      , **envadditional
825  )  )
826    
827  print "PATH =",os.environ['PATH']  #print "PATH =",os.environ['PATH']
828    #print "PROGSUFFIX =",env['PROGSUFFIX']
829    #print "CPPPATH =",env['CPPPATH']
830    
831  opts.Update(env)  opts.Update(env)
832    
833    for l in ['SUNDIALS','IPOPT']:
834        var = "%s_LIBS" % l
835        if not isinstance(env[var],types.ListType):
836            env[var] = env[var].split(",")
837    
838    if 'LSOD' in env['WITH_SOLVERS']:
839        if 'LSODE' not in env['WITH_SOLVERS']:
840            env['WITH_SOLVERS'].append('LSODE')
841        env['WITH_SOLVERS'].remove('LSOD')
842    
843  opts.Save('options.cache',env)  opts.Save('options.cache',env)
844    
845  Help(opts.GenerateHelpText(env))  Help(opts.GenerateHelpText(env))
# Line 658  without_scrollkeeper_reason = "disabled Line 862  without_scrollkeeper_reason = "disabled
862  with_dmalloc = env.get('WITH_DMALLOC')  with_dmalloc = env.get('WITH_DMALLOC')
863  without_dmalloc_reason = "disabled by options/config.py"  without_dmalloc_reason = "disabled by options/config.py"
864    
865  with_mfgraph = env.get('WITH_MFGRAPH')  with_graphviz = env.get('WITH_GRAPHVIZ')
866  without_mfgraph_reason = "disabled by options/config.py"  without_graphiviz_reason = "disabled by options/config.py"
867    
868  with_ufsparse = env.get('WITH_UFSPARSE')  with_ufsparse = env.get('WITH_UFSPARSE')
869  without_ufsparse_reason = "disabled by options/config.py"  without_ufsparse_reason = "disabled by options/config.py"
# Line 670  without_mmio_reason = "disabled by optio Line 874  without_mmio_reason = "disabled by optio
874  with_signals = env.get('WITH_SIGNALS')  with_signals = env.get('WITH_SIGNALS')
875  without_signals_reason = "disabled by options/config.py"  without_signals_reason = "disabled by options/config.py"
876    
877    with_doc = env.get('WITH_DOC')
878    
879    with_doc_build = env.get('WITH_DOC_BUILD');
880    without_doc_build_reason = "disabled by options/config.py"
881    if not with_doc:
882        with_doc_build = False
883        without_doc_build_reason = "disabled by with_doc"
884    
885    with_latex2html = False
886    
887  if platform.system()=="Windows":  if platform.system()=="Windows":
888      with_installer=1      with_installer=1
889  else:  else:
890      with_installer=0      with_installer=0
891      without_installer_reason = "only possible under Windows"      without_installer_reason = "only possible under Windows"
892    
893  if 'LSOD' in env['WITH_SOLVERS']:  with_lsode = 'LSODE' in env['WITH_SOLVERS']
894      with_lsode=True  without_lsode_reason = "Not selected (see config option WITH_SOLVERS)"
 else:  
     with_lsode=False  
     without_lsode_reason = "not requested (WITH_SOLVERS)"  
       
 if 'IDA' in env['WITH_SOLVERS']:  
     with_ida=True  
 else:  
     with_ida=False  
     without_ida_reason = "not requested (WITH_SOLVERS)"  
895    
896    with_ida = 'IDA' in env['WITH_SOLVERS']
897    without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
898    
899  if 'CONOPT' in env['WITH_SOLVERS']:  with_dopri5 = 'DOPRI5' in env['WITH_SOLVERS']
900      with_conopt=True  without_dopri5_reason = "Not selected (see config option WITH_SOLVERS)"
901  else:  
902      with_conopt=False  with_conopt = 'CONOPT' in env['WITH_SOLVERS']
903      without_conopt_reason = "not requested (WITH_SOLVERS)"  without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
904    
905    with_ipopt = 'IPOPT' in env['WITH_SOLVERS']
906    without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
907    
908    
909  #print "SOLVERS:",env['WITH_SOLVERS']  #print "SOLVERS:",env['WITH_SOLVERS']
# Line 705  if platform.system()=='Windows': Line 915  if platform.system()=='Windows':
915      can_install = False      can_install = False
916    
917  env['CAN_INSTALL']=can_install  env['CAN_INSTALL']=can_install
 env['INSTALL_MODELS']=env['INSTALL_ASCDATA']+"/models/"  
918    
919    print "TCL=",env['TCL']
920  print "TCL_CPPPATH =",env['TCL_CPPPATH']  print "TCL_CPPPATH =",env['TCL_CPPPATH']
921  print "TCL_LIBPATH =",env['TCL_LIBPATH']  print "TCL_LIBPATH =",env['TCL_LIBPATH']
922  print "TCL_LIB =",env['TCL_LIB']  print "TCL_LIB =",env['TCL_LIB']
# Line 715  print "CXX =",env['CXX'] Line 925  print "CXX =",env['CXX']
925  print "FORTRAN=",env.get('FORTRAN')  print "FORTRAN=",env.get('FORTRAN')
926    
927  print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']  print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
928    print "INSTALL_ASCDATA =",env['INSTALL_ASCDATA']
929    print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
930    print "INSTALL_MODELS =",env['INSTALL_MODELS']
931    print "INSTALL_SOLVERS =",env['INSTALL_SOLVERS']
932    print "DEFAULT_ASCENDLIBRARY =",env['DEFAULT_ASCENDLIBRARY']
933    print "DEFAULT_ASCENDSOLVERS =",env['DEFAULT_ASCENDSOLVERS']
934    
935    
936  #------------------------------------------------------  #------------------------------------------------------
937  # SPECIAL CONFIGURATION TESTS  # SPECIAL CONFIGURATION TESTS
938    
939  need_fortran = False  need_fortran = False
940    need_fortran_reasons = []
941    
942    #----------------
943    # CC
944    
945    cc_test_text = """
946    int main(void){
947        return 0;
948    }
949    """;
950    
951    def CheckCC(context):
952        context.Message("Checking C compiler ('%s')... " % context.env.get('CC'))
953        is_ok = context.TryCompile(cc_test_text,".c")
954        context.Result(is_ok)
955        return is_ok
956    
957    #----------------
958    # CXX
959    
960    cxx_test_text = """
961    template<class X>
962    class pair{
963    public:
964        X a;
965        X b;
966    };
967    
968    int main(void){
969        pair<double> P;
970        P.a = 0;
971        return 0;
972    }
973    """;
974    
975    def CheckCXX(context):
976        context.Message("Checking C++ compiler ('%s')... " % context.env.get('CXX'))
977        if not context.env.get('CXX'):
978            context.Result("not found")
979            return False
980        is_ok = context.TryCompile(cxx_test_text,".cpp")
981        context.Result(is_ok)
982        return is_ok
983    
984  #----------------  #----------------
985    
986    f77_test_text = """
987    C     Hello World in Fortran 77
988    
989          PROGRAM HELLO
990          PRINT*, 'Hello World!'
991          END  
992    """;
993    
994    def CheckF77(context):
995        context.Message("Checking Fortran 77 compiler ('%s')..." % context.env.get('FORTRAN'))
996        if not context.env.get('FORTRAN'):
997            context.Result('not found')
998            return False
999        is_ok = context.TryCompile(f77_test_text,".f")
1000        context.Result(is_ok)
1001        return is_ok
1002        
1003    #----------------
1004  # SWIG  # SWIG
1005    
1006  import os,re  import os,re
# Line 811  class KeepContext: Line 1091  class KeepContext:
1091              if context.env.has_key(varprefix+'_LIB'):              if context.env.has_key(varprefix+'_LIB'):
1092                  context.env.Append(LIBS=[env[varprefix+'_LIB']])                  context.env.Append(LIBS=[env[varprefix+'_LIB']])
1093                  #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"                      #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"    
1094                elif context.env.has_key(varprefix+'_LIBS'):
1095                    context.env.AppendUnique(LIBS=env[varprefix+'_LIBS'])
1096    
1097      def restore(self,context):      def restore(self,context):
1098          #print "RESTORING CONTEXT"          #print "RESTORING CONTEXT"
# Line 825  class KeepContext: Line 1107  class KeepContext:
1107                  #print "Restoring %s to '%s'" %(k,self.keep.get(k))                  #print "Restoring %s to '%s'" %(k,self.keep.get(k))
1108                  context.env[k]=self.keep[k];                  context.env[k]=self.keep[k];
1109    
1110  def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False):  def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False,testname=None):
1111      """This method will check for variables LIBNAME_LIBPATH      """This method will check for variables LIBNAME_LIBPATH
1112      and LIBNAME_CPPPATH and try to compile and link the      and LIBNAME_CPPPATH and try to compile and link the
1113      file with the provided text, linking with the      file with the provided text, linking with the
1114      library libname."""      library libname."""
1115    
1116        if testname is None:
1117            testname = libname
1118    
1119      if static:      if static:
1120          context.Message( 'Checking for static '+libname+'... ' )          context.Message( 'Checking for static '+testname+'... ' )
1121      else:      else:
1122          context.Message( 'Checking for '+libname+'... ' )          context.Message( 'Checking for '+testname+'... ' )
1123                    
1124      if varprefix==None:      if varprefix==None:
1125          varprefix = libname.upper()          varprefix = libname.upper()
# Line 842  def CheckExtLib(context,libname,text,ext Line 1127  def CheckExtLib(context,libname,text,ext
1127      #print "LIBS is currently:",context.env.get('LIBS')      #print "LIBS is currently:",context.env.get('LIBS')
1128      keep = KeepContext(context,varprefix,static)      keep = KeepContext(context,varprefix,static)
1129    
1130      if not context.env.has_key(varprefix+'_LIB'):      if not context.env.has_key(varprefix+'_LIB') and not context.env.has_key(varprefix+'_LIBS'):
1131          # if varprefix_LIB were in env, KeepContext would          # if varprefix_LIB were in env, KeepContext would
1132          # have appended it already          # have appended it already
1133          context.env.Append(LIBS=[libname])          context.env.Append(LIBS=[libname])
# Line 995  dmalloc_test_text = """ Line 1280  dmalloc_test_text = """
1280    
1281  int main(void){  int main(void){
1282      char *c;      char *c;
1283      c = malloc(100*sizeof(char));      c = (char *)malloc(100*sizeof(char));
1284      free(c);      free(c);
1285      return 0;      return 0;
1286  }  }
# Line 1005  def CheckDMalloc(context): Line 1290  def CheckDMalloc(context):
1290      return CheckExtLib(context,'dmalloc',dmalloc_test_text)      return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1291    
1292  #----------------  #----------------
1293  # mfgraph test  # graphviz test
1294    
1295    graphviz_test_text = """
1296    #ifdef __WIN32__
1297    # include <gvc.h>
1298    #else
1299    # include <graphviz/gvc.h>
1300    #endif
1301    int main(void){
1302        Agraph_t *g;
1303        GVC_t *gvc;
1304        gvc = gvContext();
1305        g = agopen("g", AGDIGRAPH);
1306        return 0;
1307    }
1308    """
1309    
1310    def CheckGraphViz(context):
1311        return CheckExtLib(context,'graphviz',graphviz_test_text,ext=".c")
1312    
1313  mfgraph_test_text = """  graphviz_boolean_test = """
1314  #include <mfgraph/mfg_draw_graph.h>  #ifdef __WIN32__
1315    # include <types.h>
1316    #else
1317    # include <graphviz/types.h>
1318    #endif
1319    #ifndef GV_TYPES_H
1320    # error WHERE IS GV_TYPES_H?
1321    #endif
1322  int main(void){  int main(void){
1323      using namespace mfg;      boolean x;
1324      DrawGraph g;      x = TRUE;
1325      return 0;      return 0;
1326  }  }
1327  """  """
1328    
1329  def CheckMFGraph(context):  def CheckGraphVizBoolean(context):
1330      return CheckExtLib(context,'mfgraph',mfgraph_test_text,ext=".cpp")      return CheckExtLib(context,'graphviz',graphviz_boolean_test,ext=".c" \
1331            ,testname="graphviz 'boolean' definition"
1332        )
1333    
1334  #----------------  #----------------
1335  # ufsparse test  # ufsparse test
# Line 1058  int main(void){ Line 1370  int main(void){
1370      acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);      acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);
1371      j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);      j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);
1372      y0(x); y1(x); yn(i,x);      y0(x); y1(x); yn(i,x);
1373    /* this part causes problems with crossmingw... */
1374  #ifdef _THREAD_SAFE  #ifdef _THREAD_SAFE
1375      gamma_r(x,&i);      gamma_r(x,&i);
1376      lgamma_r(x,&i);      lgamma_r(x,&i);
# Line 1076  def CheckMath(context): Line 1389  def CheckMath(context):
1389      context.env.AppendUnique(LIBS=['m'])      context.env.AppendUnique(LIBS=['m'])
1390      is_ok=context.TryLink(math_test_text,".c")      is_ok=context.TryLink(math_test_text,".c")
1391      context.Result(is_ok)      context.Result(is_ok)
1392      if not is_ok:      if libsave is None:
1393            del(context.env['LIBS'])
1394        else:
1395          context.env['LIBS']=libsave          context.env['LIBS']=libsave
1396      return is_ok      return is_ok
1397    
1398  #----------------  #----------------
1399    # malloc.h test
1400    
1401    malloc_test_text = """
1402    #include <stdlib.h>
1403    int main(){
1404        double *x;
1405        x = malloc(sizeof(double)*5);
1406        x[4] = 3.3;
1407        free(x);
1408    }
1409    """
1410    
1411    def CheckMalloc(context):
1412        context.Message("Checking for malloc...")
1413        is_ok = context.TryLink(malloc_test_text,".c")
1414        context.Result(is_ok)
1415        return is_ok
1416    
1417    #----------------
1418    # dlopen test
1419    
1420    dlopen_test_text = """
1421    #ifdef __WIN32__
1422    # include <windows.h>
1423    #else
1424    # include <dlfcn.h>
1425    #endif
1426    int main(){
1427    #ifdef __WIN32__
1428        HINSTANCE d;
1429        LoadLibrary("imaginary_and_nonexistent.dll");
1430    #else
1431        void *d;
1432        d = dlopen("imaginary_and_nonexistent.so", 1);
1433    #endif
1434        return 0;
1435    }
1436    """
1437    
1438    def CheckDLOpen(context):
1439        context.Message("Checking for ability to load shared libraries at runtime...")
1440        libsave=context.env.get('LIBS');
1441        if platform.system()!="Windows":
1442            context.env.Append(LIBS=['dl'])
1443        is_ok = context.TryLink(dlopen_test_text,".c")
1444        context.Result(is_ok)
1445        context.env['LIBS'] = libsave
1446        return is_ok
1447    
1448    #----------------
1449  # libpython test  # libpython test
1450    
1451  libpython_test_text = """  libpython_test_text = """
# Line 1099  def CheckPythonLib(context): Line 1464  def CheckPythonLib(context):
1464          python_lib='python%d%d'          python_lib='python%d%d'
1465      else:      else:
1466          python_lib='python%d.%d'          python_lib='python%d.%d'
     python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]  
1467    
1468      python_cpppath = [distutils.sysconfig.get_python_inc()]      try:
1469      cfig = distutils.sysconfig.get_config_vars()              python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
1470            python_cpppath = [distutils.sysconfig.get_python_inc()]
1471            cfig = distutils.sysconfig.get_config_vars()    
1472        except:
1473            context.Result("not found")
1474            return 0        
1475            
1476      lastLIBS = context.env.get('LIBS')      lastLIBS = context.env.get('LIBS')
1477      lastLIBPATH = context.env.get('LIBPATH')      lastLIBPATH = context.env.get('LIBPATH')
# Line 1112  def CheckPythonLib(context): Line 1481  def CheckPythonLib(context):
1481      python_libpath = []      python_libpath = []
1482      python_linkflags = []      python_linkflags = []
1483      if platform.system()=="Windows":      if platform.system()=="Windows":
1484          python_libpath+=[cfig['prefix']]          python_libpath += [os.path.join(sys.prefix,"libs")]
1485      else:      else:
1486          # checked on Linux and SunOS          # checked on Linux and SunOS
1487          if cfig['LDLIBRARY']==cfig['LIBRARY']:          if cfig['LDLIBRARY']==cfig['LIBRARY']:
# Line 1158  int main(){ Line 1527  int main(){
1527  """  """
1528    
1529  ida_test_text = """  ida_test_text = """
1530  # include <ida/ida.h>  #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1531  # include <nvector/nvector_serial.h>  # include <sundials/sundials_config.h>
1532    # include <sundials/sundials_nvector.h>
1533    # include <nvector_serial.h>
1534    # include <ida.h>
1535  # include <ida/ida_spgmr.h>  # include <ida/ida_spgmr.h>
1536    #else
1537    # include <sundials/sundials_config.h>
1538    # include <nvector/nvector_serial.h>
1539    # include <ida/ida.h>
1540    #endif
1541  int main(){  int main(){
1542      void *ida_mem;      void *ida_mem;
1543      ida_mem = IDACreate();      ida_mem = IDACreate();
# Line 1168  int main(){ Line 1545  int main(){
1545  }  }
1546  """  """
1547    
 def CheckIDA(context):  
     context.Message( 'Checking for IDA (SUNDIALS)... ' )  
   
     keep = KeepContext(context,"IDA")  
       
     is_ok = context.TryLink(ida_test_text,".c")  
     context.Result(is_ok)  
       
     keep.restore(context)  
           
     return is_ok  
   
1548  # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,  # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1549  # so detect the version and act accordingly.  # so detect the version and act accordingly.
1550  def CheckIDAVersion(context):  def CheckSUNDIALS(context):
1551      keep = KeepContext(context,'IDA')      keep = KeepContext(context,'SUNDIALS')
1552      context.Message("Checking SUNDIALS version... ")      context.Message("Checking for SUNDIALS... ")
1553      (is_ok,output) = context.TryRun(sundials_version_text,'.c')      (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1554      keep.restore(context)      keep.restore(context)
1555      if not is_ok:      if not is_ok:
1556          context.Result("failed to run check")          context.Result(0)
1557          return 0          return 0
1558    
1559      major,minor,patch = tuple([int(i) for i in output.split(".")])      major,minor,patch = tuple([int(i) for i in output.split(".")])
# Line 1203  def CheckIDAVersion(context): Line 1568  def CheckIDAVersion(context):
1568                    
1569      # good version      # good version
1570      context.Result("%d.%d.%d, good" % (major,minor,patch))      context.Result("%d.%d.%d, good" % (major,minor,patch))
1571    
1572      return 1      return 1
1573            
1574    
1575    def CheckIDA(context):
1576        context.Message( 'Checking for IDA... ' )
1577    
1578        keep = KeepContext(context,"SUNDIALS")
1579    
1580        major = context.env['SUNDIALS_VERSION_MAJOR']
1581        minor = context.env['SUNDIALS_VERSION_MINOR']
1582    
1583        cppdef = context.env.get('CPPDEFINES')
1584    
1585        context.env.Append(CPPDEFINES=[
1586            ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1587            ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1588        ])
1589    
1590        context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1591        if major==2 and minor==2:
1592            context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1593    
1594        context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1595        context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1596        context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1597    
1598        is_ok = context.TryLink(ida_test_text,".c")
1599        context.Result(is_ok)
1600        
1601        if cppdef:
1602            context.env['CPPDEFINES']=cppdef
1603        else:
1604            del context.env['CPPDEFINES']
1605    
1606        keep.restore(context)
1607            
1608        return is_ok
1609    
1610    
1611  #----------------  #----------------
1612  # CONOPT test  # CONOPT test
1613    
# Line 1237  def CheckCONOPT(context): Line 1640  def CheckCONOPT(context):
1640      return is_ok      return is_ok
1641    
1642  #----------------  #----------------
1643    # IPOPT test
1644    
1645    ipopt_test_text = """
1646    #if !defined(_WIN32)
1647    # define FNAME_LCASE_DECOR
1648    #endif
1649    
1650    #include <coin/IpStdCInterface.h>
1651    int main(){
1652        Number n;
1653        IpoptProblem nlp = 0;
1654        n = 1;
1655        FreeIpoptProblem(nlp); // probably a crash if you run this
1656        return 0;
1657    }
1658    """
1659    
1660    def CheckIPOPT(context):
1661        context.Message( 'Checking for IPOPT... ' )
1662    
1663        keep = KeepContext(context,"IPOPT")
1664        is_ok = context.TryLink(ipopt_test_text,".c")
1665        context.Result(is_ok)
1666        
1667        keep.restore(context)
1668            
1669        return is_ok
1670    
1671    #----------------
1672  # Tcl test  # Tcl test
1673    
1674  # TCL and TK required version 8.1, 8.2, 8.3, or 8.4:  # TCL and TK required version 8.1 through 8.5:
1675  tcltk_minor_newest_acceptable = 4  tcltk_minor_newest_acceptable = 5
1676  tcltk_major_required = 8  tcltk_major_required = 8
1677    
1678  tcl_check_text = r"""  tcl_check_text = r"""
# Line 1458  int main(void){ Line 1890  int main(void){
1890    
1891  def CheckSigReset(context):  def CheckSigReset(context):
1892      context.Message("Checking signal handler reset... ")      context.Message("Checking signal handler reset... ")
1893        libsave=context.env.get('LIBS')
1894        context.env.AppendUnique(LIBS=['m'])
1895      (is_ok,output) = context.TryRun(sigreset_test_text,'.c')      (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1896    
1897        if libsave is None:
1898            del(context.env['LIBS'])
1899        else:
1900            context.env['LIBS']=libsave
1901    
1902      if not is_ok:      if not is_ok:
1903          context.Result("ERROR")          context.Result("ERROR")
1904          return False          return False
# Line 1468  def CheckSigReset(context): Line 1908  def CheckSigReset(context):
1908      else:      else:
1909          context.Result("not required");          context.Result("not required");
1910          context.env['ASC_RESETNEEDED'] = False          context.env['ASC_RESETNEEDED'] = False
1911        return True
1912    
1913    #----------------
1914    # LyX on this system?
1915    
1916    def CheckLyx(context):
1917        context.Message("Checking for LyX... ")
1918        r = context.env.WhereIs("lyx")
1919        if r:
1920            context.Result(r)
1921        else:
1922            context.Result(0)
1923        return r
1924    
1925    #----------------
1926    # Latex2HTML on this system?
1927    
1928    def CheckLatex2HTML(context):
1929        context.Message("Checking for latex2html...")
1930        if context.env.WhereIs("latex2html"):
1931            r = True
1932        else:
1933            r = False
1934        context.Result(r)
1935        return r
1936    
1937    #----------------
1938    # 'lmodern' package for LaTeX available?
1939    
1940    lmodern_test_text = r"""
1941    \documentclass{article}
1942    \usepackage{lmodern}
1943    \title{Cartesian closed categories and the price of eggs}
1944    \author{Jane Doe}
1945    \date{September 1994}
1946    \begin{document}
1947       \maketitle
1948       Hello world!
1949    \end{document}
1950    """;
1951    
1952    def CheckLModern(context):
1953        context.Message("Checking for lmodern...")
1954        b = context.env.get("DVI")
1955        if not b:
1956            context.Result(False)
1957            return False
1958        ff = context.env.get('LATEXFLAGS')
1959        context.env.Append(LATEXFLAGS=['-interaction=nonstopmode','-halt-on-error'])
1960        is_ok = context.TryBuild(builder=b,text=lmodern_test_text,extension=".latex")
1961        print "is_ok=",is_ok
1962        if ff is not None:
1963            context.env['LATEXFLAGS'] = ff
1964        else:
1965            del context.env['LATEXFLAGS']
1966        context.Result(is_ok)
1967      return is_ok      return is_ok
1968    
1969  #----------------  #----------------
# Line 1482  gcc_version4 = False Line 1978  gcc_version4 = False
1978    
1979  conf = Configure(env  conf = Configure(env
1980      , custom_tests = {      , custom_tests = {
1981          'CheckMath' : CheckMath          'CheckCC' : CheckCC
1982            , 'CheckCXX' : CheckCXX
1983            , 'CheckF77' : CheckF77
1984            , 'CheckMath' : CheckMath
1985            , 'CheckMalloc' : CheckMalloc
1986            , 'CheckDLOpen' : CheckDLOpen
1987          , 'CheckSwigVersion' : CheckSwigVersion          , 'CheckSwigVersion' : CheckSwigVersion
1988          , 'CheckPythonLib' : CheckPythonLib          , 'CheckPythonLib' : CheckPythonLib
1989          , 'CheckCUnit' : CheckCUnit          , 'CheckCUnit' : CheckCUnit
1990          , 'CheckDMalloc' : CheckDMalloc          , 'CheckDMalloc' : CheckDMalloc
1991          , 'CheckMFGraph' : CheckMFGraph          , 'CheckLyx' : CheckLyx
1992            , 'CheckLatex2HTML' : CheckLatex2HTML
1993            , 'CheckLModern' : CheckLModern
1994            , 'CheckGraphViz' : CheckGraphViz
1995            , 'CheckGraphVizBoolean' : CheckGraphVizBoolean
1996          , 'CheckUFSparse' : CheckUFSparse          , 'CheckUFSparse' : CheckUFSparse
1997          , 'CheckTcl' : CheckTcl          , 'CheckTcl' : CheckTcl
1998          , 'CheckTclVersion' : CheckTclVersion          , 'CheckTclVersion' : CheckTclVersion
# Line 1500  conf = Configure(env Line 2005  conf = Configure(env
2005          , 'CheckTkTable' : CheckTkTable          , 'CheckTkTable' : CheckTkTable
2006          , 'CheckX11' : CheckX11          , 'CheckX11' : CheckX11
2007          , 'CheckIDA' : CheckIDA          , 'CheckIDA' : CheckIDA
2008          , 'CheckIDAVersion' : CheckIDAVersion          , 'CheckSUNDIALS' : CheckSUNDIALS
2009          , 'CheckCONOPT' : CheckCONOPT          , 'CheckCONOPT' : CheckCONOPT
2010            , 'CheckIPOPT' : CheckIPOPT
2011          , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig          , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
2012          , 'CheckFPE' : CheckFPE          , 'CheckFPE' : CheckFPE
2013          , 'CheckSIGINT' : CheckSIGINT          , 'CheckSIGINT' : CheckSIGINT
# Line 1520  def sconsversioncheck(): Line 2026  def sconsversioncheck():
2026      import SCons      import SCons
2027      v = SCons.__version__.split(".")      v = SCons.__version__.split(".")
2028      if v[0] != '0':      if v[0] != '0':
2029            if v[0] == '1':
2030                return 1;
2031          return 0          return 0
2032        if int(v[1]) >= 97:
2033            return 1
2034      if v[1] != '96':      if v[1] != '96':
2035          return 0          return 0
2036      micro = int(v[2])      micro = int(v[2])
2037      if micro == 92 or micro == 93:      if micro == 92 or micro == 93 or micro == 96:
2038          return 1;          return 1;
2039      return 0      return 0
2040    
# Line 1535  if not sconsversioncheck(): Line 2045  if not sconsversioncheck():
2045      print "want to *force* SCons to continue."      print "want to *force* SCons to continue."
2046      Exit(1)      Exit(1)
2047    
2048    # check C compiler
2049    
2050    if conf.CheckCC() is False:
2051        print "Failed to build simple test file with your C compiler."
2052        print "Check your compiler is installed and running correctly."
2053        Exit(1)
2054    
2055    if conf.CheckCXX() is False:
2056        print "Failed to build simple test file with your C++ compiler."
2057        print "Check your compiler is installed and running correctly."
2058        print "You can set your C++ compiler using the CXX scons option."
2059        Exit(1)
2060    
2061  # stdio -- just to check that compiler is behaving  # stdio -- just to check that compiler is behaving
2062    
2063  if not conf.CheckHeader('stdio.h'):  if conf.CheckHeader('stdio.h') is False:
2064      print "CPPPATH =",env.get('CPPPATH')      print "CPPPATH =",env.get('CPPPATH')
2065      print "Did not find 'stdio.h'! Check your compiler configuration."      print "Did not find 'stdio.h'! Check your compiler configuration."
2066      print ""      print ""
# Line 1546  if not conf.CheckHeader('stdio.h'): Line 2069  if not conf.CheckHeader('stdio.h'):
2069          print "%-30s%s" % ("%s :" % k, v)          print "%-30s%s" % ("%s :" % k, v)
2070      Exit(1)      Exit(1)
2071    
2072  if not conf.CheckFunc('snprintf'):  if conf.CheckFunc('snprintf') is False:
2073      print "Didn't find snprintf";      print "Didn't find snprintf";
2074      exit(1)      exit(1)
2075    
2076    if conf.CheckFunc('strdup'):
2077        conf.env['HAVE_STRDUP'] = True
2078    
2079    if platform.system()=="Windows" and env.get('WITH_MSVCR71'):
2080        conf.env.Append(LIBS='msvcr71')
2081        
2082  # Math library  # Math library
2083    
2084  conf.env['HAVE_IEEE']=True  conf.env['HAVE_IEEE']=True
2085    
2086  if need_libm and not conf.CheckMath():  if need_libm and (conf.CheckMath() is False):
2087      conf.env['HAVE_IEEE']=False      conf.env['HAVE_IEEE']=False
2088      print 'Did not find math library, exiting!'      print 'Did not find math library, exiting!'
2089      Exit(1)      Exit(1)
2090    
2091    # Malloc
2092    
2093    if conf.CheckMalloc() is False:
2094        conf.env['HAVE_MALLOC']=False
2095        print "Did not find functioning 'malloc', exiting!"
2096        Exit(1)
2097    
2098    # dlopen/LoadLibrary
2099    
2100    # CURRENTLY BREAKS LATER TEST (libsave?)
2101    #if conf.CheckDLOpen() is False:
2102    #   print "Did not find functioning dlopen/LoadLibrary, exiting!"
2103    #   Exit(1)
2104    
2105  # Where is 'isnan'?  # Where is 'isnan'?
2106    
2107  if not conf.CheckFunc('isnan') and not conf.CheckFunc('_isnan'):  if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2108      print "Didn't find isnan"      print "Didn't find isnan"
2109  #   Exit(1)  #   Exit(1)
2110    
# Line 1591  else: Line 2134  else:
2134    
2135  # Checking for signal reset requirement  # Checking for signal reset requirement
2136    
2137  if not conf.CheckSigReset():  if conf.CheckSigReset() is False:
2138      print "Unable to determine if signal reset is required"      print "Unable to determine if signal reset is required"
2139      Exit(1)      Exit(1)
2140    
2141  # YACC  # YACC
2142    
2143  if not conf.CheckYacc():  if conf.CheckYacc():
     print "YACC NOT FOUND OR NOT WORKING"  
 else:  
2144      conf.env['HAVE_YACC']=True      conf.env['HAVE_YACC']=True
2145    
2146  if not conf.CheckLex():  if conf.CheckLex():
     print "YACC NOT FOUND OR NOT WORKING"  
 else:  
2147      conf.env['HAVE_LEX']=True      conf.env['HAVE_LEX']=True
2148    
2149  # Tcl/Tk  # Tcl/Tk
# Line 1647  if not conf.CheckPythonLib(): Line 2186  if not conf.CheckPythonLib():
2186    
2187  # SWIG version  # SWIG version
2188    
2189  if with_python and not conf.CheckSwigVersion():  if with_python and conf.CheckSwigVersion() is False:
2190      without_python_reason = 'SWIG >= 1.3.24 is required'      without_python_reason = 'SWIG >= 1.3.24 is required'
2191      with_python = False      with_python = False
2192      env['WITH_PYTHON']=False      env['WITH_PYTHON']=False
# Line 1667  if with_dmalloc: Line 2206  if with_dmalloc:
2206          without_dmalloc_reason = 'dmalloc not found'          without_dmalloc_reason = 'dmalloc not found'
2207          with_dmalloc = False          with_dmalloc = False
2208    
2209  # MFGRAPH  # GRAPHVIZ
2210    
2211  if with_mfgraph:  if with_graphviz:
2212      if not conf.CheckMFGraph():      if not conf.CheckGraphViz():
2213          without_mfgraph_reason = 'mfgraph not found'          without_graphviz_reason = 'graphviz not found'
2214          with_mfgraph = False          with_graphviz = False
2215          env['WITH_MFGRAPH'] = False          env['WITH_GRAPHVIZ'] = False
2216        env['HAVE_GRAPHVIZ_BOOLEAN'] = conf.CheckGraphVizBoolean()      
2217    
2218  # UFSPARSE  # UFSPARSE
2219    
2220  if with_ufsparse:  if with_ufsparse:
2221      if not conf.CheckUFSparse():      if not conf.CheckUFSparse():
2222          without_ufsparse_reason = 'mfgraph not found'          without_ufsparse_reason = 'ufsparse not found'
2223          with_ufsparse = False          with_ufsparse = False
2224          env['WITH_UFSPARSE'] = False          env['WITH_UFSPARSE'] = False
2225    
2226  # IDA  # IDA
2227    
2228  if not with_ida:  if with_ida:
2229      without_ida_reason = "Not selected (see config option WITH_SOLVERS)"      if not conf.CheckSUNDIALS():
2230  elif not conf.CheckIDA():          with_ida = False
2231      with_ida = False          without_ida_reason = "SUNDIALS not found, or bad version"
2232      without_ida_reason = "IDA not found"      elif not conf.CheckIDA():
2233  elif not conf.CheckIDAVersion():          with_ida = False
2234      with_ida = False          without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
     without_ida_reason = "Unsupported (or undetected) SUNDIALS version"  
2235    
2236  # CONOPT  # CONOPT
2237    
2238  if not with_conopt:  if not with_conopt:
2239      without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"      without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2240  elif not conf.CheckCONOPT():  elif conf.CheckCONOPT() is False:
2241      with_conopt = False      if conf.env.get('CONOPT_LINKED'):
2242      without_conpt_reason = "CONOPT not found"          conf.env['CONOPT_LINKED'] = False
2243        # we no longer require CONOPT at buildtime in order to build support for it
2244        #with_conopt = False
2245        #without_conpt_reason = "CONOPT not found"
2246    
2247    # IPOPT
2248    
2249    if not with_ipopt:
2250        without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2251    elif not conf.CheckIPOPT():
2252        with_ipopt = False
2253        without_ipopt_reason = "IPOPT not found"
2254    
2255  # BLAS  # BLAS
2256    
# Line 1708  need_blas=False Line 2258  need_blas=False
2258    
2259  if with_lsode:  if with_lsode:
2260      need_fortran = True      need_fortran = True
2261        need_fortran_reasons.append("LSODE")
2262        need_blas=True
2263    
2264    if with_ipopt:
2265      need_blas=True      need_blas=True
2266    
2267  if need_blas:  if need_blas:
# Line 1717  if need_blas: Line 2271  if need_blas:
2271      else:      else:
2272          with_local_blas = True          with_local_blas = True
2273          need_fortran = True          need_fortran = True
2274            need_fortran_reasons.append("BLAS")
2275  else:  else:
2276      with_local_blas= False;      with_local_blas= False;
2277      without_local_blas_reason = "BLAS not required"      without_local_blas_reason = "BLAS not required"
# Line 1724  else: Line 2279  else:
2279  # FORTRAN  # FORTRAN
2280    
2281  if need_fortran:  if need_fortran:
2282      conf.env.Tool('fortran')      print "NEED FORTRAN"
2283        import SCons
2284        if SCons.__version__[0:4]=="0.97":
2285            # Older SCons verions 0.97 (eg Ubuntu 8.04) doesn't have the 'gfortran' tool'.
2286            # On this system, the 'fortran' tool seems to detect gfortran OK.
2287            conf.env.Tool('fortran')
2288        else:
2289            conf.env.Tool('g77')
2290            conf.env.Tool('gfortran')
2291      detect_fortran = conf.env.Detect(['gfortran','g77'])      detect_fortran = conf.env.Detect(['gfortran','g77'])
2292      if detect_fortran:      if detect_fortran:
2293          # For some reason, g77 doesn't get detected properly on MinGW          # For some reason, g77 doesn't get detected properly on MinGW
# Line 1743  if need_fortran: Line 2306  if need_fortran:
2306              )              )
2307              conf.env.Append(BUILDERS={'Fortran':fortran_builder})              conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2308          if platform.system()=="Linux":          if platform.system()=="Linux":
2309                print "APPARENTLY FORTRAN WAS DETECTED"
2310              conf.env.Append(SHFORTRANFLAGS=['-fPIC'])              conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2311      else:      else:
2312            print "FAILED FORTRAN DETECTION"
2313          with_lsode=False;          with_lsode=False;
2314          without_lsode_reason="FORTRAN-77 required but not found"          without_lsode_reason="FORTRAN-77 required but not found"
2315    else:
2316        print "FORTRAN WAS NOT FOUND TO BE REQUIRED"
2317    
2318    if need_fortran and conf.CheckF77() is False:
2319        print "Failed to build simple test file with your Fortran compiler."
2320        print "Check your compiler is installed and running correctly."
2321        print "You can set your Fortran compiler using the FORTRAN scons option."
2322        print "The fortran compiler is REQUIRED to build:",", ".join(need_fortran_reasons)
2323        print "Perhaps try examining the value of your WITH_SOLVERS option (remove LSODE, etc)."
2324        Exit(1)
2325    
2326  #else:  #else:
2327  #   print "FORTRAN not required"  #   print "FORTRAN not required"
# Line 1761  if need_fortran: Line 2336  if need_fortran:
2336  # scrollkeeper  # scrollkeeper
2337    
2338  if with_scrollkeeper:  if with_scrollkeeper:
2339      if not conf.CheckScrollkeeperConfig():      if conf.CheckScrollkeeperConfig() is False:
2340          with_scrollkeeper=False          with_scrollkeeper=False
2341          without_scrollkeeper_reason="unable to detect scrollkeeper-config"          without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2342    
2343    # lyx
2344    
2345    if with_doc_build:
2346        if not conf.CheckLyx():
2347            with_doc_build = False
2348            without_doc_build_reason="unable to locate LyX"
2349    
2350        with_latex2html = conf.CheckLatex2HTML()
2351    
2352        if conf.CheckLModern() is False:
2353            with_doc_build = False
2354            without_doc_build_reason="'lmodern' is not available"
2355    
2356  # TODO: -D_HPUX_SOURCE is needed  # TODO: -D_HPUX_SOURCE is needed
2357    
2358  # TODO: check size of void*  # TODO: check size of void*
# Line 1778  if platform.system()=="Windows" and env. Line 2366  if platform.system()=="Windows" and env.
2366          print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."          print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2367          Exit(1)          Exit(1)
2368    
2369      if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):      if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2370          with_python = 0;          with_python = 0;
2371          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."
2372    
 conf.env.Append(CPPDEFINES=env['PACKAGE_LINKING'])  
   
2373  conf.Finish()  conf.Finish()
2374    
2375    print "-=-=-=-=-=-=-=-=- LIBS =",env.get('LIBS')
2376    
2377  #---------------------------------------  #---------------------------------------
2378  # SUBSTITUTION DICTIONARY for .in files  # SUBSTITUTION DICTIONARY for .in files
2379    
# Line 1797  if release=="0.": Line 2385  if release=="0.":
2385    
2386  subst_dict = {  subst_dict = {
2387      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2388        ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2389      , '@GLADE_FILE@':'ascend.glade'      , '@GLADE_FILE@':'ascend.glade'
2390      , '@HELP_ROOT@':''      , '@HELP_ROOT@':''
2391      , '@ICON_EXTENSION@':icon_extension      , '@ICON_EXTENSION@':icon_extension
# Line 1805  subst_dict = { Line 2394  subst_dict = {
2394      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2395      , '@INSTALL_LIB@':env['INSTALL_LIB']      , '@INSTALL_LIB@':env['INSTALL_LIB']
2396      , '@INSTALL_MODELS@':env['INSTALL_MODELS']      , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2397        , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2398      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2399      , '@VERSION@':version      , '@VERSION@':version
2400      , '@RELEASE@':release      , '@RELEASE@':release
2401      , '@DISTTAR_NAME@':env['DISTTAR_NAME']      , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2402      , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'      , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2403      , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']      , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2404      , '@SHLIBPREFIX@':env['SHLIBPREFIX']      , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2405        , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2406        , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2407      , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'      , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2408      , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir      , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
2409      , '@PYTHON@' : python_exe      , '@PYTHON@' : python_exe
2410      , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')      , '@PYVERSION@' : pyversion
     , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')  
     , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_LIBPATH"))  
2411      , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))      , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2412        , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2413  }  }
2414    
2415  if env.get('WITH_LOCAL_HELP'):  if env.get('WITH_DOC'):
2416      print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']      print "WITH_DOC:",env['WITH_DOC']
2417      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']      subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2418    
2419  # bool options...  # bool options...
2420  for k,v in {  for k,v in {
2421          'ASC_WITH_IDA':with_ida          'ASC_WITH_DMALLOC':with_dmalloc
         ,'ASC_WITH_DMALLOC':with_dmalloc  
         ,'ASC_WITH_MFGRAPH':with_mfgraph  
2422          ,'ASC_WITH_UFSPARSE':with_ufsparse          ,'ASC_WITH_UFSPARSE':with_ufsparse
         ,'ASC_WITH_CONOPT':with_conopt  
         ,'ASC_WITH_LSODE':with_lsode  
2423          ,'ASC_WITH_MMIO':with_mmio          ,'ASC_WITH_MMIO':with_mmio
2424          ,'ASC_SIGNAL_TRAPS':with_signals          ,'ASC_SIGNAL_TRAPS':with_signals
2425          ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')          ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2426          ,'HAVE_C99FPE':env.get('HAVE_C99FPE')          ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2427          ,'HAVE_IEEE':env.get('HAVE_IEEE')          ,'HAVE_IEEE':env.get('HAVE_IEEE')
2428          ,'ASC_ABSOLUTE_PATHS':env.get('ASC_ABSOLUTE_PATHS')          ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2429          ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')          ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2430          ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')          ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2431          }.iteritems():          }.iteritems():
# Line 1849  if with_python: Line 2436  if with_python:
2436      subst_dict['@ASCXX_USE_PYTHON@']="1"      subst_dict['@ASCXX_USE_PYTHON@']="1"
2437      env['WITH_PYTHON']=1;      env['WITH_PYTHON']=1;
2438    
2439    if with_latex2html:
2440        env['WITH_LATEX2HTML']=1
2441    
2442  if env.has_key('HAVE_GCCVISIBILITY'):  if env.has_key('HAVE_GCCVISIBILITY'):
2443      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2444    
# Line 1874  SWIGScanner = SCons.Scanner.ClassicCPP( Line 2464  SWIGScanner = SCons.Scanner.ClassicCPP(
2464  env.Append(SCANNERS=[SWIGScanner])  env.Append(SCANNERS=[SWIGScanner])
2465    
2466  #------------------------------------------------------  #------------------------------------------------------
 # RECIPE: 'SubstInFile', used in pygtk SConscript  
   
 import re  
 from SCons.Script import *  # the usual scons stuff you get in a SConscript  
   
 def TOOL_SUBST(env):  
     """Adds SubstInFile builder, which substitutes the keys->values of SUBST_DICT  
     from the source to the target.  
     The values of SUBST_DICT first have any construction variables expanded  
     (its keys are not expanded).  
     If a value of SUBST_DICT is a python callable function, it is called and  
     the result is expanded as the value.  
     If there's more than one source and more than one target, each target gets  
     substituted from the corresponding source.  
     """  
     env.Append(TOOLS = 'SUBST')  
     def do_subst_in_file(targetfile, sourcefile, dict):  
         """Replace all instances of the keys of dict with their values.  
         For example, if dict is {'%VERSION%': '1.2345', '%BASE%': 'MyProg'},  
         then all instances of %VERSION% in the file will be replaced with 1.2345 etc.  
         """  
         try:  
             f = open(sourcefile, 'rb')  
             contents = f.read()  
             f.close()  
         except:  
             raise SCons.Errors.UserError, "Can't read source file %s"%sourcefile  
         for (k,v) in dict.items():  
             try:  
                 #print "%s ---> %s" % (k,v)  
                 contents = re.sub(k, v, contents)  
             except Exception,e:  
                 sys.stderr.write("Failed to substute '%s' with '%s': %s\n" % (k,v,e))  
           
         try:  
             f = open(targetfile, 'wb')  
             f.write(contents)  
             f.close()  
         except:  
             raise SCons.Errors.UserError, "Can't write target file %s"%targetfile  
         return 0 # success  
   
     def subst_in_file(target, source, env):  
         if not env.has_key('SUBST_DICT'):  
             raise SCons.Errors.UserError, "SubstInFile requires SUBST_DICT to be set."  
         d = dict(env['SUBST_DICT']) # copy it  
         for (k,v) in d.items():  
             if callable(v):  
                 d[k] = env.subst(v())  
             elif SCons.Util.is_String(v):  
                 d[k]=env.subst(v)  
             else:  
                 raise SCons.Errors.UserError, "SubstInFile: key %s: %s must be a string or callable"%(k, repr(v))  
         for (t,s) in zip(target, source):  
             return do_subst_in_file(str(t), str(s), d)  
   
     def subst_in_file_string(target, source, env):  
         """This is what gets printed on the console."""  
         return '\n'.join(['Substituting vars from %s into %s'%(str(s), str(t))  
                           for (t,s) in zip(target, source)])  
   
     def subst_emitter(target, source, env):  
         """Add dependency from substituted SUBST_DICT to target.  
         Returns original target, source tuple unchanged.  
         """  
         d = env['SUBST_DICT'].copy() # copy it  
         for (k,v) in d.items():  
             if callable(v):  
                 d[k] = env.subst(v())  
             elif SCons.Util.is_String(v):  
                 d[k]=env.subst(v)  
         Depends(target, SCons.Node.Python.Value(d))  
         return target, source  
   
     subst_action=SCons.Action.Action(subst_in_file, subst_in_file_string)  
     env['BUILDERS']['SubstInFile'] = Builder(action=subst_action, emitter=subst_emitter)  
   
 TOOL_SUBST(env)  
   
 #------------------------------------------------------  
2467  # Recipe for 'CHMOD' ACTION        # Recipe for 'CHMOD' ACTION      
2468            
2469  import SCons      import SCons    
# Line 1981  env.AppendUnique(CPPPATH=['#base/generic Line 2491  env.AppendUnique(CPPPATH=['#base/generic
2491    
2492  if env['DEBUG']:  if env['DEBUG']:
2493      env.Append(CCFLAGS=['-g'])      env.Append(CCFLAGS=['-g'])
2494        env.Append(LINKFLAGS=['-g'])
2495    
2496  if env['GCOV']:  if env['GCOV']:
2497      env.Append(      env.Append(
# Line 1995  if with_ida: Line 2506  if with_ida:
2506  if with_conopt:  if with_conopt:
2507      env.Append(WITH_CONOPT=1)      env.Append(WITH_CONOPT=1)
2508    
2509    if with_ipopt:
2510        env.Append(WITH_IPOPT=1)
2511    
2512    if with_dopri5:
2513        env.Append(WITH_DOPRI5=1)
2514    
2515    if with_graphviz and env.get('GRAPHVIZ_RPATH'):
2516        env.Append(RPATH=env['GRAPHVIZ_RPATH'])
2517    
2518  #-------------  #-------------
2519  # TCL/TK GUI  # TCL/TK GUI
2520    
# Line 2014  else: Line 2534  else:
2534  #------------  #------------
2535  # BASE/GENERIC SUBDIRECTORIES  # BASE/GENERIC SUBDIRECTORIES
2536    
2537  libascend_env = env.Copy()  libascend_env = env.Clone()
2538    
2539  dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']  dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2540    
# Line 2026  for d in dirs: Line 2546  for d in dirs:
2546  #-------------  #-------------
2547  # IMPORTED CODE: LSODE, BLAS, etc  # IMPORTED CODE: LSODE, BLAS, etc
2548    
2549  if with_lsode:  #if with_lsode:
2550      srcs += env.SConscript(['lsod/SConscript'],'env')  #   srcs += env.SConscript(['lsod/SConscript'],'env')
2551      srcs += env.SConscript(['linpack/SConscript'],'env')  #   srcs += env.SConscript(['linpack/SConscript'],'env')
2552  else:  #else:
2553      print "Skipping... LSODE won't be built:", without_lsode_reason  #   print "Skipping... LSODE won't be built:", without_lsode_reason
2554    
2555  if with_local_blas:  if with_local_blas:
2556      srcs += env.SConscript(['blas/SConscript'],'env')      env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2557  else:  else:
2558        env['blasobjs'] = []
2559      print "Skipping... BLAS won't be built:", without_local_blas_reason      print "Skipping... BLAS won't be built:", without_local_blas_reason
2560    
2561  if not with_ida:  if not with_ida:
2562      print "Skipping... IDA won't be built:", without_ida_reason      print "Skipping... IDA won't be built:", without_ida_reason
2563    
2564    if not with_dopri5:
2565        print "Skipping... DOPRI5 won't be built:", without_dopri5_reason
2566    
2567  if with_mmio:  if with_mmio:
2568      srcs += env.SConscript(['mmio/SConscript'],'env')      srcs += env.SConscript(['mmio/SConscript'],'env')
2569  else:  else:
# Line 2055  if with_ufsparse: Line 2579  if with_ufsparse:
2579    
2580  libascend = libascend_env.SharedLibrary('ascend',srcs)  libascend = libascend_env.SharedLibrary('ascend',srcs)
2581    
2582    # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2583    env['libascend'] = libascend
2584    
2585  env.Alias('libascend',libascend)  env.Alias('libascend',libascend)
2586    
2587  #-------------  #-------------
2588  # UNIT TESTS (C CODE)  # UNIT TESTS (C CODE)
2589    
2590  if with_cunit:  if with_cunit:
2591      testdirs = ['general','solver','utilities','linear']      testdirs = ['general','solver','utilities','linear','compiler']
2592      testsrcs = []      testsrcs = []
2593      for testdir in testdirs:      for testdir in testdirs:
2594          path = 'base/generic/'+testdir+'/test/'          path = 'base/generic/'+testdir+'/test/'
# Line 2079  else: Line 2606  else:
2606      print "Skipping... CUnit tests aren't being built:",without_cunit_reason      print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2607    
2608  #-------------  #-------------
2609  # EXTERNAL FUNCTIONS  # EXTERNAL SOLVERS
2610    
2611  env['extfns']=[]  env['extfns']=[]
2612    
2613    env.SConscript(['solvers/SConscript'],'env')
2614    
2615    #-------------
2616    # EXTERNAL FUNCTIONS
2617    
2618  modeldirs = env.SConscript(['models/SConscript'],'env')  modeldirs = env.SConscript(['models/SConscript'],'env')
2619    
2620  if not with_extfns:  if not with_extfns:
# Line 2094  env.Alias('extfns',env['extfns']) Line 2627  env.Alias('extfns',env['extfns'])
2627    
2628  ascendconfig = env.SubstInFile('ascend-config.in')  ascendconfig = env.SubstInFile('ascend-config.in')
2629    
2630    
2631    #------------------------------------------------------
2632    # CREATE asc4dev scriptlet
2633    
2634    asc4devcmd = env.SubstInFile('tcltk/asc4dev.in')
2635    env.AddPostAction(asc4devcmd, 'chmod 755 $TARGET')
2636  #------------------------------------------------------  #------------------------------------------------------
2637  # INSTALLATION  # INSTALLATION
2638    
2639  if env.get('CAN_INSTALL'):  if env.get('CAN_INSTALL'):
2640    
2641      dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE']      dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2642      install_dirs = [env.Entry(env['INSTALL_ROOT']+env[d]) for d in dirs]      install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2643      install_dirs += modeldirs      install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2644    
2645      # TODO: add install options      # TODO: add install options
2646      env.Alias('install',install_dirs)      env.Alias('install',install_dirs)
2647    
2648      env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_LIB'],libascend)      env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2649    
2650      env.InstallProgram(env['INSTALL_ROOT']+env['INSTALL_BIN'],ascendconfig)      env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2651    
2652  #------------------------------------------------------  #------------------------------------------------------
2653  # WINDOWS INSTALLER  # WINDOWS INSTALLER
2654  # For the windows installer, please see pygtk/SConscript  
2655    if not env.get('NSIS'):
2656        with_installer = False
2657        without_installer_reason = "NSIS not found"
2658    
2659  if with_installer:  if with_installer:
2660      pass      env.Append(NSISDEFINES={
2661            'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2662            ,"VERSION":version
2663            ,'PYVERSION':pyversion
2664        })
2665        installer = env.Installer('nsis/installer.nsi')
2666        Depends(installer,["pygtk","tcltk","ascend.dll","models","solvers","ascend-config"])
2667        env.Alias('installer',installer)
2668  else:  else:
2669      print "Skipping... Windows installer isn't being built:",without_installer_reason      print "Skipping... Windows installer isn't being built:",without_installer_reason
2670    
2671    
2672  #------------------------------------------------------  #------------------------------------------------------
2673  # PROJECT FILE for MSVC  # PROJECT FILE for MSVC
2674    
# Line 2133  if platform.system()=="Linux": Line 2683  if platform.system()=="Linux":
2683  #------------------------------------------------------  #------------------------------------------------------
2684  # CREATE OMF FILE FOR USE WITH SCROLLKEEPER  # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2685    
2686  if with_scrollkeeper:  #if with_scrollkeeper:
2687      env.SubstInFile('#/pygtk/gnome/ascend.omf.in')  #   #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2688      env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")  #   #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2689    
2690  #------------------------------------------------------  #------------------------------------------------------
2691  # DISTRIBUTION TAR FILE  # DISTRIBUTION TAR FILE
2692    
2693  env['DISTTAR_FORMAT']='bz2'  env['DISTTAR_FORMAT']='bz2'
2694  env.Append(  env.Append(
2695      DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.cc','.cache','.pyc','.cvsignore','.dblite','.log','.pl','.out']      DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.lib','.cc','.cache',
2696      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist']          '.pyc','.cvsignore','.dblite','.log','.pl','.out','.exe','.aux','.idx',
2697            '.toc','.lof','.lot','.mm','.warnings','.tm2','.swp',',tmp','.gz',
2698            '.bz2','.7z','.deb','.dsc','.changes']
2699        , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2700  )  )
2701    
2702  tar = env.DistTar("dist/"+env['DISTTAR_NAME']  tar = env.DistTar("dist/"+env['DISTTAR_NAME']
# Line 2151  tar = env.DistTar("dist/"+env['DISTTAR_N Line 2704  tar = env.DistTar("dist/"+env['DISTTAR_N
2704  )  )
2705    
2706  env.Depends(tar,'ascend.spec')  env.Depends(tar,'ascend.spec')
2707    env.Depends(tar,'#doc/book.pdf')
2708    
2709  Alias('dist',tar)  #------------------------------------------------------
2710    # DISTRIBUTION TAR FILE (new style with AccumulateBuilder)
2711    
2712    # ...
2713    
2714  #------------------------------------------------------  #------------------------------------------------------
2715  # USER'S MANUAL  # DEBIAN TARBALL for use with Build Service
2716    
2717  env.SConscript('doc/SConscript',['env'])  import glob
2718    deb_manfiles = glob.glob('debian/*.man')
2719    
2720    deb_tar = env.Tar(
2721        'dist/debian.tar.gz'
2722        ,deb_manfiles + ['debian/rules','debian/control','debian/changelog','debian/compat','debian/copyright','debian/dirs'
2723            ,'debian/postinst','debian/postrm']
2724        ,TARFLAGS = ['cz']
2725    )
2726    
2727    Alias('dist',[tar,deb_tar])
2728    
2729  #------------------------------------------------------  #------------------------------------------------------
2730  # LIBASCEND DOXYGEN DOCUMENTATION  # DOCUMENTATION
2731    
2732    #print "WITH_DOC_BUILD = ",with_doc_build
2733    
2734    if not with_doc_build:
2735        print "Skipping... Documentation isn't being built:",without_doc_build_reason
2736    
2737    #user's manual
2738    env.SConscript('doc/SConscript',['env'])
2739    
2740    # doxygen documentation
2741  env.SConscript('base/doc/SConscript',['env'])  env.SConscript('base/doc/SConscript',['env'])
2742    
2743  #------------------------------------------------------  #------------------------------------------------------
# Line 2173  env.SConscript('base/doc/SConscript',['e Line 2749  env.SConscript('base/doc/SConscript',['e
2749  #------------------------------------------------------  #------------------------------------------------------
2750  # DEFAULT TARGETS  # DEFAULT TARGETS
2751    
2752  default_targets =['libascend']  default_targets =['libascend','solvers']
2753  if with_tcltk:  if with_tcltk:
2754      default_targets.append('tcltk')      default_targets.append('tcltk')
2755  if with_python:  if with_python:
# Line 2182  if with_installer: Line 2758  if with_installer:
2758      default_targets.append('installer')      default_targets.append('installer')
2759  if with_extfns:  if with_extfns:
2760      default_targets.append('extfns')      default_targets.append('extfns')
2761    if with_doc_build:
2762        default_targets.append('doc')
2763    
2764  env.Default(default_targets)  env.Default(default_targets)
2765    

Legend:
Removed from v.1387  
changed lines
  Added in v.2001

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