/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 960 by johnpye, Sun Dec 10 03:14:24 2006 UTC revision 1712 by jpye, Mon Jan 7 01:07:04 2008 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.114"
3    
4  version = "0.9.5.103"  pyversion = "%d.%d" % (sys.version_info[0],sys.version_info[1])
5    
6  #------------------------------------------------------  #------------------------------------------------------
7  # OPTIONS  # OPTIONS
# Line 11  version = "0.9.5.103" Line 12  version = "0.9.5.103"
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    
19  if platform.system()=="Windows":  if platform.system()=="Windows":
20      default_tcl_lib = "tcl84"      default_tcl_lib = "tcl84"
21      default_tk_lib = "tk84"      default_tk_lib = "tk84"
# Line 18  if platform.system()=="Windows": Line 23  if platform.system()=="Windows":
23      default_install_assets = "glade/"      default_install_assets = "glade/"
24      icon_extension = '.png'      icon_extension = '.png'
25      default_tcl = "c:\\Tcl"      default_tcl = "c:\\Tcl"
26      if os.environ.get('MSYSTEM')=="MINGW32":      if os.environ.get('MSYSTEM'):
27          default_tcl_libpath="$TCL\\bin"          default_tcl_libpath="$TCL\\bin"
28      else:      else:
29          default_tcl_libpath="$TCL\\lib"          default_tcl_libpath="$TCL\\lib"
# Line 32  if platform.system()=="Windows": Line 37  if platform.system()=="Windows":
37      default_conopt_prefix = "c:\\Program Files\\CONOPT"      default_conopt_prefix = "c:\\Program Files\\CONOPT"
38      default_conopt_libpath="$CONOPT_PREFIX"      default_conopt_libpath="$CONOPT_PREFIX"
39      default_conopt_cpppath="$CONOPT_PREFIX"      default_conopt_cpppath="$CONOPT_PREFIX"
40        default_conopt_dlpath="$CONOPT_PREFIX"
41      default_conopt_lib="conopt3"      default_conopt_lib="conopt3"
42      default_conopt_envvar="CONOPT_PATH"  
43        default_tron_prefix="c:\\Program Files\\TRON"
44        default_tron_dlpath="$TRON_PREFIX"
45        default_tron_lib="tron1"
46    
47      default_prefix="c:\\MinGW"      default_prefix="c:\\MinGW"
48      default_libpath="$DEFAULT_PREFIX\\lib"      default_libpath="$DEFAULT_PREFIX\\lib"
# Line 43  if platform.system()=="Windows": Line 52  if platform.system()=="Windows":
52          default_conopt_prefix = None          default_conopt_prefix = None
53                    
54      need_libm = False      need_libm = False
55      python_exe = "c:\\Python24\\python.exe"      python_exe = sys.executable
56      default_with_scrollkeeper=False      default_with_scrollkeeper=False
57        pathsep = ";"
58        
59        default_fortran="g77"
60        default_f2c_lib="g2c"
61        
62  else:  else:
63      default_tcl_lib = "tcl8.4"      default_tcl_lib = "tcl8.4"
64      default_tk_lib = "tk8.4"      default_tk_lib = "tk8.4"
# Line 52  else: Line 66  else:
66      default_install_assets = "$INSTALL_ASCDATA/glade/"      default_install_assets = "$INSTALL_ASCDATA/glade/"
67      icon_extension = '.svg'      icon_extension = '.svg'
68      default_tcl = '/usr'      default_tcl = '/usr'
69      default_tcl_libpath = "$TCL/lib"          default_tcl_libpath = "$TCL/lib"
70    
71        if os.path.exists("/etc/debian_version"):
72            default_tcl_cpppath = "/usr/include/tcl8.4"
73    
74      default_rel_distdir = '../share/ascend'      default_rel_distdir = '../share/ascend'
75      default_absolute_paths = True      default_absolute_paths = True
76      default_ida_prefix="/usr/local"      default_ida_prefix="/usr"
77      default_conopt_prefix="/usr"      default_conopt_prefix="/usr"
78      default_conopt_libpath="$CONOPT_PREFIX/lib"      default_conopt_libpath="$CONOPT_PREFIX/lib"
79      default_conopt_cpppath="$CONOPT_PREFIX/include"      default_conopt_cpppath="$CONOPT_PREFIX/include"
80        default_conopt_dlpath= default_conopt_libpath + ":/usr/local/lib"
81      default_conopt_lib="consub3"      default_conopt_lib="consub3"
82      default_conopt_envvar="CONOPT_PATH"  
83        default_tron_prefix="/usr"
84        default_tron_dlpath="$TRON_PREFIX/lib"
85        default_tron_lib="tron1"
86    
87      default_prefix="/usr"      default_prefix="/usr"
88      default_libpath="$DEFAULT_PREFIX/lib"      default_libpath="$DEFAULT_PREFIX/lib"
# Line 71  else: Line 93  else:
93          default_tcl = '/usr'          default_tcl = '/usr'
94      python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"      python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"
95      default_with_scrollkeeper=False      default_with_scrollkeeper=False
96        pathsep = ":"
97        
98        default_fortran="gfortran"
99        default_f2c_lib="gfortran"
100        
101  opts.Add(  opts.Add(
102      'CC'      'CC'
103      ,'C Compiler command'      ,'C Compiler command'
# Line 90  opts.Add(BoolOption( Line 116  opts.Add(BoolOption(
116      , False      , False
117  ))  ))
118    
 # Package linking option  
 opts.Add(EnumOption(  
     'PACKAGE_LINKING'  
     , 'Style of linking for external libraries'  
     , 'DYNAMIC_PACKAGES'  
     , ['DYNAMIC_PACKAGES', 'STATIC_PACKAGES', 'NO_PACKAGES']  
 ))  
   
119  opts.Add(BoolOption(  opts.Add(BoolOption(
120      'WITH_GCCVISIBILITY'      'WITH_GCCVISIBILITY'
121      ,"Whether to use GCC Visibility features (only applicable if available)"      ,"Whether to use GCC Visibility features (only applicable if available)"
122      ,True      ,True
123  ))  ))
124    
125    opts.Add(BoolOption(
126        'WITH_SIGNALS'
127        ,"Whether to permit use of signals for flow control in the C-level code"
128        ,True
129    ))
130    
131  # You can turn off building of Tcl/Tk interface  # You can turn off building of Tcl/Tk interface
132  opts.Add(BoolOption(  opts.Add(BoolOption(
133      'WITH_TCLTK'      'WITH_TCLTK'
# Line 122  opts.Add(BoolOption( Line 146  opts.Add(BoolOption(
146  opts.Add(ListOption(  opts.Add(ListOption(
147      'WITH_SOLVERS'      'WITH_SOLVERS'
148      ,"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"  
149          +" works."          +" works. The option 'LSOD' is provided for backwards compatibility"
150      ,["QRSLV","CMSLV","LSOD","IDA","CONOPT","LRSLV"]          +"; the value 'LSODE' is preferred."
151        ,["QRSLV","CMSLV","LSODE","IDA","CONOPT","LRSLV","TRON","IPOPT"]
152      ,['QRSLV','MPS','SLV','OPTSQP'      ,['QRSLV','MPS','SLV','OPTSQP'
153          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
154          ,'LSOD','OPTSQP',"IDA"          ,'LSODE','LSOD','OPTSQP',"IDA","TRON","IPOPT"
155       ]       ]
156  ))  ))
157    
158  # Where will the local copy of the help files be kept?  # Where will the local copy of the help files be kept?
159  opts.Add(PackageOption(  opts.Add(BoolOption(
160      'WITH_LOCAL_HELP'      'WITH_DOC'
161      , "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"
162      , "no"      , True
163    ))
164    
165    opts.Add(BoolOption(
166        'WITH_DOC_BUILD'
167        , "If true, we'll attempt to build docs. Set false, we'll assume we already have then (eg from the tarball)"
168        , "$WITH_DOC"
169  ))  ))
170    
171    opts.Add(BoolOption(
172        'WITH_DOC_INSTALL'
173        , "If true, SCons will install the documentation file(s). If false, assume rpm or dpkg is going to do it."
174        , "$WITH_DOC"
175    ))
176    
177    opts.Add(
178        'HELP_ROOT'
179        , "Location of the main help file"
180        , "$INSTALL_DOC/book.pdf"
181    )
182    
183  # Will bintoken support be enabled?  # Will bintoken support be enabled?
184  opts.Add(BoolOption(  opts.Add(BoolOption(
185      'WITH_BINTOKEN'      'WITH_BINTOKEN'
# Line 151  opts.Add( Line 194  opts.Add(
194      'DEFAULT_ASCENDLIBRARY'      'DEFAULT_ASCENDLIBRARY'
195      ,"Set the default value of the ASCENDLIBRARY -- the location where"      ,"Set the default value of the ASCENDLIBRARY -- the location where"
196          +" ASCEND will look for models when running ASCEND"          +" ASCEND will look for models when running ASCEND"
197      ,"$INSTALL_ASCDATA/models"      ,"$INSTALL_MODELS"
198    )
199    
200    # What should the default ASCENDLIBRARY path be?
201    # Note: users can change it by editing their ~/.ascend.ini
202    opts.Add(
203        'DEFAULT_ASCENDSOLVERS'
204        ,"Set the default value of ASCENDSOLVERS -- the location where"
205            +" ASCEND will look for solver shared-library files"
206        ,"$INSTALL_SOLVERS"
207  )  )
208    
209  # Where is SWIG?  # Where is SWIG?
# Line 173  opts.Add(BoolOption( Line 225  opts.Add(BoolOption(
225      ,True      ,True
226  ))  ))
227    
228    # Build with MMIO matrix export support?
229    opts.Add(BoolOption(
230        'WITH_MMIO'
231        ,"Include support for exporting matrices in Matrix Market format"
232        ,True
233    ))
234    
235  #----- default paths -----  #----- default paths -----
236  opts.Add(PackageOption(  opts.Add(PackageOption(
237      'DEFAULT_PREFIX'      'DEFAULT_PREFIX'
# Line 209  opts.Add(PackageOption( Line 268  opts.Add(PackageOption(
268  #-------- ida -------  #-------- ida -------
269    
270  opts.Add(PackageOption(  opts.Add(PackageOption(
271      "IDA_PREFIX"      "SUNDIALS_PREFIX"
272      ,"Prefix for your IDA install (IDA ./configure --prefix)"      ,"Prefix for your IDA install (IDA ./configure --prefix)"
273      ,default_ida_prefix      ,default_ida_prefix
274  ))  ))
275    
276  opts.Add(  opts.Add(
277      "IDA_LIB"      'SUNDIALS_CPPPATH'
278      ,"Libraries linked to for IDA"      ,"Where is your ida.h?"
279      ,['sundials_nvecserial','sundials_ida','m']      ,"$SUNDIALS_PREFIX/include"
280  )  )
281    
282    #
283  opts.Add(  opts.Add(
284      'IDA_CPPPATH'      'SUNDIALS_LIBPATH'
285      ,"Where is your ida.h?"      ,"Where are your SUNDIALS libraries installed?"
286      ,"$IDA_PREFIX/include"      ,"$SUNDIALS_PREFIX/lib"
287  )  )
288    
289  opts.Add(  opts.Add(
290      'IDA_LIBPATH'      'SUNDIALS_LIBS'
291      ,"Where are your SUNDIALS libraries installed?"      ,"What libraries are required for SUNDIALS?"
292      ,"$IDA_PREFIX/lib"      ,['sundials_nvecserial','sundials_ida','m']
293  )  )
294    
295  # ----- conopt-----  # ----- conopt-----
# Line 246  opts.Add( Line 306  opts.Add(
306      ,default_conopt_lib      ,default_conopt_lib
307  )  )
308    
309    opts.Add(BoolOption(
310        "CONOPT_LINKED"
311        ,"Do you want to dynamically link to CONOPT (only possible if CONOPT is available at buildtime)"
312        ,False
313    ))
314    
315  opts.Add(  opts.Add(
316      'CONOPT_CPPPATH'      'CONOPT_CPPPATH'
317      ,"Where is your conopt.h?"      ,"Where is your conopt.h?"
# Line 254  opts.Add( Line 320  opts.Add(
320    
321  opts.Add(  opts.Add(
322      'CONOPT_LIBPATH'      'CONOPT_LIBPATH'
323      ,"Where is your CONOPT libraries installed?"      ,"Where is your CONOPT library installed?"
324      ,default_conopt_libpath      ,default_conopt_libpath
325  )  )
326    
327  opts.Add(  opts.Add(
328        'CONOPT_DLPATH'
329        ,"What is the default search path that ASCEND should use when dlopening the CONOPT library at runtime?"
330        ,default_conopt_dlpath
331    )
332    
333    opts.Add(
334      'CONOPT_ENVVAR'      'CONOPT_ENVVAR'
335      ,"What environment variable should be used at runtime to override the default search location for CONOPT DLL/SO?"      ,"What environment variable should be used at runtime to override the default search location for CONOPT DLL/SO?"
336      ,default_conopt_envvar      ,default_conopt_envvar
337  )  )
338    
339    #------- IPOPT -------
340    
341    opts.Add(PackageOption(
342        "IPOPT_PREFIX"
343        ,"Prefix for your IPOPT install (IPOPT ./configure --prefix)"
344        ,default_conopt_prefix
345    ))
346    
347    opts.Add(
348        "IPOPT_LIBS"
349        ,"Library linked to for IPOPT"
350        ,["$F2C_LIB","blas","lapack","pthread","ipopt"]
351    )
352    
353    
354    opts.Add(
355        "IPOPT_LIBPATH"
356        ,"Where is your IPOPT library installed"
357        ,"$IPOPT_PREFIX/lib"
358    )
359    
360    opts.Add(
361        'IPOPT_CPPPATH'
362        ,"Where is your ipopt/IpStdCInterface.h (do not include the 'ipopt' in the path)"
363        ,"$IPOPT_PREFIX/include"
364    )
365    
366    
367    #------- TRON -------
368    
369    opts.Add(
370        'TRON_ENVVAR'
371        ,"What environment variable should be used at runtime to override the default search location for TRON DLL/SO?"
372        ,default_tron_envvar
373    )
374    
375    opts.Add(
376        "TRON_LIB"
377        ,"Library linked to for TRON"
378        ,"tron"
379    )
380    
381    opts.Add(
382        "TRON_PREFIX"
383        ,"Prefix for your TRON install"
384        ,default_tron_prefix
385    )
386    
387    opts.Add(
388        'TRON_DLPATH'
389        ,"What is the default search path that ASCEND should use when dlopening the TRON library at runtime?"
390        ,default_tron_dlpath
391    )
392    
393  #-------- f2c ------  #-------- f2c ------
394    
395  opts.Add(  opts.Add(
396      "F2C_LIB"      "F2C_LIB"
397      ,"F2C library (eg. g2c, gfortran, f2c)"      ,"F2C library (eg. g2c, gfortran, f2c)"
398      ,"g2c"      ,default_f2c_lib # the default is gfortran now
399  )  )
400    
401  opts.Add(PackageOption(  opts.Add(PackageOption(
# Line 278  opts.Add(PackageOption( Line 404  opts.Add(PackageOption(
404      ,"off"      ,"off"
405  ))  ))
406    
407    opts.Add(
408        "FORTRAN"
409        ,"Fortran compiler (eg g77, gfortran)"
410        ,default_fortran
411    )
412    
413  #------- tcl/tk --------  #------- tcl/tk --------
414    
415  opts.Add(  opts.Add(
# Line 290  opts.Add( Line 422  opts.Add(
422  opts.Add(  opts.Add(
423      'TCL_CPPPATH'      'TCL_CPPPATH'
424      ,"Where are your Tcl include files?"      ,"Where are your Tcl include files?"
425      ,"$TCL/include"      ,default_tcl_cpppath
426  )  )
427    
428  # Where are the Tcl libs?  # Where are the Tcl libs?
# Line 405  opts.Add( Line 537  opts.Add(
537  )  )
538    
539  opts.Add(  opts.Add(
     'INSTALL_DOC'  
     ,'Location to install documentation files'  
     ,"$INSTALL_SHARE/doc"  
 )  
   
 opts.Add(  
540      'INSTALL_ASCDATA'      'INSTALL_ASCDATA'
541      ,"Location of ASCEND shared data (TK, python, models etc)"      ,"Location of ASCEND shared data (TK, python, models etc)"
542      ,"$INSTALL_SHARE/ascend"      ,"$INSTALL_SHARE/ascend"
543  )  )
544    
545  opts.Add(  opts.Add(
546        'INSTALL_MODELS'
547        ,"Location of ASCEND model files (.a4c,.a4l,.a4s)"
548        ,"$INSTALL_ASCDATA/models"
549    )
550    
551    opts.Add(
552        'INSTALL_SOLVERS'
553        ,"Location of ASCEND solvers"
554        ,"$INSTALL_ASCDATA/solvers"
555    )
556    
557    opts.Add(
558        'INSTALL_DOC'
559        ,"Location of ASCEND documentation files"
560        ,"$INSTALL_SHARE/doc/ascend-"+version
561    )
562    
563    opts.Add(
564      'INSTALL_INCLUDE'      'INSTALL_INCLUDE'
565      ,'Location to put header files during installation'      ,'Location to put header files during installation'
566      ,"$INSTALL_PREFIX/include"      ,"$INSTALL_PREFIX/include"
# Line 429  opts.Add( Line 573  opts.Add(
573      ,""      ,""
574  )  )
575    
576    opts.Add(
577        'EXTLIB_SUFFIX'
578        ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
579        ,"_ascend$SHLIBSUFFIX"
580    )
581    
582    opts.Add(
583        'EXTLIB_PREFIX'
584        ,"Filename suffix for ASCEND 'external libraries' (for use with IMPORT"
585        ,"$SHLIBPREFIX"
586    )
587    
588  #----------------------  #----------------------
589    
590  opts.Add(  opts.Add(
# Line 474  opts.Add(BoolOption( Line 630  opts.Add(BoolOption(
630      ,False      ,False
631  ))  ))
632    
633    #------ f --------
634    opts.Add(PackageOption(
635        'GRAPHVIZ_PREFIX'
636        ,"Where are your GRAPHVIZ files?"
637        ,default_prefix
638    ))
639    
640    opts.Add(PackageOption(
641        'GRAPHVIZ_CPPPATH'
642        ,"Where are your GRAPHVIZ include files?"
643        ,default_cpppath
644    ))
645    
646    opts.Add(PackageOption(
647        'GRAPHVIZ_LIBPATH'
648        ,"Where are your GRAPHVIZ libraries?"
649        ,default_libpath
650    ))
651    
652    opts.Add(
653        'GRAPHVIZ_LIBS'
654        ,"What are your GRAPHVIZ libraries named?"
655        ,['gvc','graph','cdt']
656    )
657    
658    opts.Add(BoolOption(
659        'WITH_GRAPHVIZ'
660        ,"Link to the GRAPHVIZ library (if available, for generating incidence graphs)"
661        ,True
662    ))
663    
664    
665    #------ ufsparse --------
666    opts.Add(PackageOption(
667        'UFSPARSE_PREFIX'
668        ,"Where are your UFSPARSE files?"
669        ,default_prefix
670    ))
671    
672    opts.Add(PackageOption(
673        'UFSPARSE_CPPPATH'
674        ,"Where are your UFSPARSE include files?"
675        ,default_cpppath
676    ))
677    
678    opts.Add(PackageOption(
679        'UFSPARSE_LIBPATH'
680        ,"Where are your UFSPARSE libraries?"
681        ,default_libpath
682    ))
683    
684    opts.Add(BoolOption(
685        'WITH_UFSPARSE'
686        ,"Link to the UFSPARSE library (if available, for additional sparse matrix routines)"
687        ,True
688    ))
689    
690  #-----------------------  #-----------------------
691    
692    opts.Add(BoolOption(
693        'UPDATE_NO_YACC_LEX'
694        ,"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)"
695        ,False
696    ))
697    
698  opts.Add(  opts.Add(
699      'DISTTAR_NAME'      'DISTTAR_NAME'
700      ,"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 497  opts.Add(BoolOption( Line 716  opts.Add(BoolOption(
716  opts.Add(  opts.Add(
717      'WIN_INSTALLER_NAME'      'WIN_INSTALLER_NAME'
718      ,"Name of the installer .exe to create under Windows (minus the '.exe')"      ,"Name of the installer .exe to create under Windows (minus the '.exe')"
719      ,"ascend-"+version      ,"ascend-"+version+"-py"+pyversion+".exe"
720  )  )
721    
722  opts.Add(BoolOption(  opts.Add(BoolOption(
# Line 508  opts.Add(BoolOption( Line 727  opts.Add(BoolOption(
727    
728  opts.Add(BoolOption(  opts.Add(BoolOption(
729      'WITH_EXTFNS'      'WITH_EXTFNS'
730      ,"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."  
731      ,True      ,True
732  ))  ))
733    
# Line 519  opts.Add(BoolOption( Line 737  opts.Add(BoolOption(
737      ,default_with_scrollkeeper      ,default_with_scrollkeeper
738  ))  ))
739    
740    
741  if platform.system()!="Windows":  if platform.system()!="Windows":
742      opts.Add(BoolOption(      opts.Add(BoolOption(
743          'WITH_GCCVISIBILITY'          'WITH_GCCVISIBILITY'
# Line 540  def c_escape(str): Line 759  def c_escape(str):
759    
760  envadditional={}  envadditional={}
761    
762    tools = [
763        'lex', 'yacc', 'fortran', 'swig', 'nsis', 'substinfile'
764        ,'disttar', 'tar'
765    ]
766  if platform.system()=="Windows":  if platform.system()=="Windows":
767      if os.environ.get('OSTYPE')=='msys':      if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
768          envenv = os.environ;          envenv = os.environ;
769          tools = ['mingw','lex','yacc','fortran','swig','disttar','nsis']          tools += ['mingw']
770          #TODO removed 'doxygen' for SCons 0.96.93          #TODO removed 'doxygen' for SCons 0.96.93
771          envadditional['IS_MINGW']=True          envadditional['IS_MINGW']=True
772      else:      else:
773            print "Assuming VC++ build environment (Note: MinGW is preferred)"
774          envenv = {          envenv = {
775              'PATH':os.environ['PATH']              'PATH':os.environ['PATH']
776              ,'INCLUDE':os.environ['INCLUDE']              ,'INCLUDE':os.environ['INCLUDE']
777              ,'LIB':os.environ['LIB']              ,'LIB':os.environ['LIB']
778              ,'MSVS_IGNORE_IDE_PATHS':1              ,'MSVS_IGNORE_IDE_PATHS':1
779          }          }
780          tools=['default','lex','yacc','fortran','swig','disttar','nsis']              tools += ['default']
781          #TODO removed 'doxygen' for SCons 0.96.93          #TODO removed 'doxygen' for SCons 0.96.93
782          envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']          envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
783  else:  else:
784      if os.environ.get('TARGET')=='mingw':      if os.environ.get('TARGET')=='mingw':
785          envenv = os.environ          envenv = os.environ
786          tools=['crossmingw','lex','yacc','disttar','nsis','doxygen']          tools += ['crossmingw']
787          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']
788            envadditional['LIBS']=['gcc']
789      else:      else:
790          envenv = os.environ          envenv = os.environ
791          tools=['default','lex','yacc','fortran','swig','disttar','nsis']          tools += ['default']
792          #TODO removed 'doxygen' for SCons 0.96.93          #TODO removed 'doxygen' for SCons 0.96.93
793            
794            
# Line 574  env = Environment( Line 799  env = Environment(
799      , **envadditional      , **envadditional
800  )  )
801    
802    #print "PATH =",os.environ['PATH']
803    #print "PROGSUFFIX =",env['PROGSUFFIX']
804    #print "CPPPATH =",env['CPPPATH']
805    
806  opts.Update(env)  opts.Update(env)
807    
808    for l in ['GRAPHVIZ','SUNDIALS','IPOPT']:
809        var = "%s_LIBS" % l
810        if not isinstance(env[var],types.ListType):
811            env[var] = env[var].split(",")
812    
813    if 'LSOD' in env['WITH_SOLVERS']:
814        if 'LSODE' not in env['WITH_SOLVERS']:
815            env['WITH_SOLVERS'].append('LSODE')
816        env['WITH_SOLVERS'].remove('LSOD')
817    
818  opts.Save('options.cache',env)  opts.Save('options.cache',env)
819    
820  Help(opts.GenerateHelpText(env))  Help(opts.GenerateHelpText(env))
# Line 597  without_scrollkeeper_reason = "disabled Line 837  without_scrollkeeper_reason = "disabled
837  with_dmalloc = env.get('WITH_DMALLOC')  with_dmalloc = env.get('WITH_DMALLOC')
838  without_dmalloc_reason = "disabled by options/config.py"  without_dmalloc_reason = "disabled by options/config.py"
839    
840    with_graphviz = env.get('WITH_GRAPHVIZ')
841    without_graphiviz_reason = "disabled by options/config.py"
842    
843    with_ufsparse = env.get('WITH_UFSPARSE')
844    without_ufsparse_reason = "disabled by options/config.py"
845    
846    with_mmio = env.get('WITH_MMIO')
847    without_mmio_reason = "disabled by options/config.py"
848    
849    with_signals = env.get('WITH_SIGNALS')
850    without_signals_reason = "disabled by options/config.py"
851    
852    with_doc = env.get('WITH_DOC')
853    
854    with_doc_build = env.get('WITH_DOC_BUILD');
855    without_doc_build_reason = "disabled by options/config.py"
856    if not with_doc:
857        with_doc_build = False
858        without_doc_build_reason = "disabled by with_doc"
859    
860    with_latex2html = False
861    
862  if platform.system()=="Windows":  if platform.system()=="Windows":
863      with_installer=1      with_installer=1
864  else:  else:
865      with_installer=0      with_installer=0
866      without_installer_reason = "only possible under Windows"      without_installer_reason = "only possible under Windows"
867            
868  if 'LSOD' in env['WITH_SOLVERS']:  if 'LSODE' in env['WITH_SOLVERS']:
869      with_lsode=True      with_lsode=True
870  else:  else:
871      with_lsode=False      with_lsode=False
# Line 622  else: Line 884  else:
884      with_conopt=False      with_conopt=False
885      without_conopt_reason = "not requested (WITH_SOLVERS)"      without_conopt_reason = "not requested (WITH_SOLVERS)"
886    
887    if 'IPOPT' in env['WITH_SOLVERS']:
888        with_ipopt=True
889    else:
890        with_ipopt=False
891        without_ipopt_reason = "not requested (WITH_SOLVERS)"
892    
893    
894  #print "SOLVERS:",env['WITH_SOLVERS']  #print "SOLVERS:",env['WITH_SOLVERS']
895  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
# Line 633  if platform.system()=='Windows': Line 901  if platform.system()=='Windows':
901    
902  env['CAN_INSTALL']=can_install  env['CAN_INSTALL']=can_install
903    
904  env['INSTALL_MODELS']=env['INSTALL_ASCDATA']+"/models/"  print "TCL=",env['TCL']
   
905  print "TCL_CPPPATH =",env['TCL_CPPPATH']  print "TCL_CPPPATH =",env['TCL_CPPPATH']
906  print "TCL_LIBPATH =",env['TCL_LIBPATH']  print "TCL_LIBPATH =",env['TCL_LIBPATH']
907  print "TCL_LIB =",env['TCL_LIB']  print "TCL_LIB =",env['TCL_LIB']
# Line 643  print "CXX =",env['CXX'] Line 910  print "CXX =",env['CXX']
910  print "FORTRAN=",env.get('FORTRAN')  print "FORTRAN=",env.get('FORTRAN')
911    
912  print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']  print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
913    print "INSTALL_ASCDATA =",env['INSTALL_ASCDATA']
914    print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
915    print "INSTALL_MODELS =",env['INSTALL_MODELS']
916    print "INSTALL_SOLVERS =",env['INSTALL_SOLVERS']
917    print "DEFAULT_ASCENDLIBRARY =",env['DEFAULT_ASCENDLIBRARY']
918    print "DEFAULT_ASCENDSOLVERS =",env['DEFAULT_ASCENDSOLVERS']
919    
920    
921  #------------------------------------------------------  #------------------------------------------------------
922  # SPECIAL CONFIGURATION TESTS  # SPECIAL CONFIGURATION TESTS
923    
924  need_fortran = False  need_fortran = False
925    need_fortran_reasons = []
926    
927    #----------------
928    # CC
929    
930    cc_test_text = """
931    int main(void){
932        return 0;
933    }
934    """;
935    
936    def CheckCC(context):
937        context.Message("Checking C compiler ('%s')... " % context.env.get('CC'))
938        is_ok = context.TryCompile(cc_test_text,".c")
939        context.Result(is_ok)
940        return is_ok
941    
942    #----------------
943    # CXX
944    
945    cxx_test_text = """
946    template<class X>
947    class pair{
948    public:
949        X a;
950        X b;
951    };
952    
953    int main(void){
954        pair<double> P;
955        P.a = 0;
956        return 0;
957    }
958    """;
959    
960    def CheckCXX(context):
961        context.Message("Checking C++ compiler ('%s')... " % context.env.get('CXX'))
962        if not context.env.get('CXX'):
963            context.Result("not found")
964            return False
965        is_ok = context.TryCompile(cxx_test_text,".cpp")
966        context.Result(is_ok)
967        return is_ok
968    
969    #----------------
970    
971    f77_test_text = """
972    C     Hello World in Fortran 77
973    
974          PROGRAM HELLO
975          PRINT*, 'Hello World!'
976          END  
977    """;
978    
979    def CheckF77(context):
980        context.Message("Checking Fortran 77 compiler ('%s')..." % context.env.get('FORTRAN'))
981        if not context.env.get('FORTRAN'):
982            context.Result('not found')
983            return False
984        is_ok = context.TryCompile(f77_test_text,".f")
985        context.Result(is_ok)
986        return is_ok
987        
988  #----------------  #----------------
989  # SWIG  # SWIG
990    
# Line 739  class KeepContext: Line 1076  class KeepContext:
1076              if context.env.has_key(varprefix+'_LIB'):              if context.env.has_key(varprefix+'_LIB'):
1077                  context.env.Append(LIBS=[env[varprefix+'_LIB']])                  context.env.Append(LIBS=[env[varprefix+'_LIB']])
1078                  #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"                      #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"    
1079                elif context.env.has_key(varprefix+'_LIBS'):
1080                    context.env.AppendUnique(LIBS=env[varprefix+'_LIBS'])
1081    
1082      def restore(self,context):      def restore(self,context):
1083          #print "RESTORING CONTEXT"          #print "RESTORING CONTEXT"
# Line 770  def CheckExtLib(context,libname,text,ext Line 1109  def CheckExtLib(context,libname,text,ext
1109      #print "LIBS is currently:",context.env.get('LIBS')      #print "LIBS is currently:",context.env.get('LIBS')
1110      keep = KeepContext(context,varprefix,static)      keep = KeepContext(context,varprefix,static)
1111    
1112      if not context.env.has_key(varprefix+'_LIB'):      if not context.env.has_key(varprefix+'_LIB') and not context.env.has_key(varprefix+'_LIBS'):
1113          # if varprefix_LIB were in env, KeepContext would          # if varprefix_LIB were in env, KeepContext would
1114          # have appended it already          # have appended it already
1115          context.env.Append(LIBS=[libname])          context.env.Append(LIBS=[libname])
# Line 860  def CheckYacc(context): Line 1199  def CheckYacc(context):
1199      return is_ok      return is_ok
1200    
1201  #----------------  #----------------
1202    # LEX
1203    
1204    lex_test_text = """
1205    %{
1206    #include <stdio.h>
1207    %}
1208    DIGIT   [0-9]
1209    ID      [a-z][a-z0-9]*
1210    %%
1211    {DIGIT}+    {
1212            printf("A digit: %s\\n",yytext);
1213        }
1214    
1215    [ \\t\\n]+    /* ignore */
1216    
1217    .           {
1218            printf("Unrecognized guff");
1219        }
1220    %%
1221    main(){
1222        yylex();
1223    }
1224    """
1225    
1226    def CheckLex(context):
1227        context.Message("Checking for Lex ('%s')... " % context.env.get('LEX'))
1228        is_ok = context.TryCompile(lex_test_text,".l")
1229        context.Result(is_ok)
1230        return is_ok
1231    
1232    #----------------
1233  # CUnit test  # CUnit test
1234    
1235  cunit_test_text = """  cunit_test_text = """
# Line 902  def CheckDMalloc(context): Line 1272  def CheckDMalloc(context):
1272      return CheckExtLib(context,'dmalloc',dmalloc_test_text)      return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1273    
1274  #----------------  #----------------
1275    # graphviz test
1276    
1277    graphviz_test_text = """
1278    #include <graphviz/gvc.h>
1279    int main(void){
1280        Agraph_t *g;
1281        GVC_t *gvc;
1282        gvc = gvContext();
1283        g = agopen("g", AGDIGRAPH);
1284        return 0;
1285    }
1286    """
1287    
1288    def CheckGraphViz(context):
1289        return CheckExtLib(context,'graphviz',graphviz_test_text,ext=".c")
1290    
1291    #----------------
1292    # ufsparse test
1293    
1294    ufsparse_test_text = """
1295    #include <ufsparse/cs.h>
1296    int main(void){
1297        cs *A,*B,*C;
1298        C = cs_multiply(A,B);
1299        return 0;
1300    }
1301    """
1302    
1303    def CheckUFSparse(context):
1304        return CheckExtLib(context
1305            ,libname='cxsparse'
1306            ,varprefix='ufsparse'
1307            ,text=ufsparse_test_text
1308            ,ext=".c"
1309        )
1310    
1311    #----------------
1312  # MATH test  # MATH test
1313    
1314  math_test_text = """  math_test_text = """
# Line 920  int main(void){ Line 1327  int main(void){
1327      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);
1328      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);
1329      y0(x); y1(x); yn(i,x);      y0(x); y1(x); yn(i,x);
1330    /* this part causes problems with crossmingw... */
1331  #ifdef _THREAD_SAFE  #ifdef _THREAD_SAFE
1332      gamma_r(x,&i);      gamma_r(x,&i);
1333      lgamma_r(x,&i);      lgamma_r(x,&i);
# Line 943  def CheckMath(context): Line 1351  def CheckMath(context):
1351      return is_ok      return is_ok
1352    
1353  #----------------  #----------------
1354    # malloc.h test
1355    
1356    malloc_test_text = """
1357    #include <stdlib.h>
1358    int main(){
1359        double *x;
1360        x = malloc(sizeof(double)*5);
1361        x[4] = 3.3;
1362        free(x);
1363    }
1364    """
1365    
1366    def CheckMalloc(context):
1367        context.Message("Checking for malloc...")
1368        is_ok = context.TryLink(malloc_test_text,".c")
1369        context.Result(is_ok)
1370        return is_ok
1371    
1372    #----------------
1373    # dlopen test
1374    
1375    dlopen_test_text = """
1376    #ifdef __WIN32__
1377    # include <windows.h>
1378    #else
1379    # include <dlfcn.h>
1380    #endif
1381    int main(){
1382    #ifdef __WIN32__
1383        HINSTANCE d;
1384        LoadLibrary("imaginary_and_nonexistent.dll");
1385    #else
1386        void *d;
1387        d = dlopen("imaginary_and_nonexistent.so", 1);
1388    #endif
1389        return 0;
1390    }
1391    """
1392    
1393    def CheckDLOpen(context):
1394        context.Message("Checking for ability to load shared libraries at runtime...")
1395        libsave=context.env.get('LIBS');
1396        if platform.system()!="Windows":
1397            context.env.Append(LIBS=['dl'])
1398        is_ok = context.TryLink(dlopen_test_text,".c")
1399        context.Result(is_ok)
1400        context.env['LIBS'] = libsave
1401        return is_ok
1402    
1403    #----------------
1404  # libpython test  # libpython test
1405    
1406  libpython_test_text = """  libpython_test_text = """
# Line 973  def CheckPythonLib(context): Line 1431  def CheckPythonLib(context):
1431    
1432      python_libpath = []      python_libpath = []
1433      python_linkflags = []      python_linkflags = []
1434      if cfig['LDLIBRARY']==cfig['LIBRARY']:      if platform.system()=="Windows":
1435          sys.stdout.write("(static)")          python_libpath += [os.path.join(sys.prefix,"libs")]
1436          python_libpath += [cfig['LIBPL']]      else:
1437          python_linkflags += cfig['LIBS'].split(' ')          # checked on Linux and SunOS
1438            if cfig['LDLIBRARY']==cfig['LIBRARY']:
1439                sys.stdout.write("(static)")
1440                python_libpath += [cfig['LIBPL']]
1441                python_linkflags += cfig['LIBS'].split(' ')
1442    
1443      context.env.AppendUnique(LIBS=python_libs)      context.env.AppendUnique(LIBS=python_libs)
1444      context.env.AppendUnique(LIBPATH=python_libpath)      context.env.AppendUnique(LIBPATH=python_libpath)
# Line 1016  int main(){ Line 1478  int main(){
1478  """  """
1479    
1480  ida_test_text = """  ida_test_text = """
1481  # include <ida/ida.h>  #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1482  # include <nvector/nvector_serial.h>  # include <sundials/sundials_config.h>
1483    # include <sundials/sundials_nvector.h>
1484    # include <nvector_serial.h>
1485    # include <ida.h>
1486  # include <ida/ida_spgmr.h>  # include <ida/ida_spgmr.h>
1487    #else
1488    # include <sundials/sundials_config.h>
1489    # include <nvector/nvector_serial.h>
1490    # include <ida/ida.h>
1491    #endif
1492  int main(){  int main(){
1493      void *ida_mem;      void *ida_mem;
1494      ida_mem = IDACreate();      ida_mem = IDACreate();
# Line 1026  int main(){ Line 1496  int main(){
1496  }  }
1497  """  """
1498    
 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  
   
1499  # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,  # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1500  # so detect the version and act accordingly.  # so detect the version and act accordingly.
1501  def CheckIDAVersion(context):  def CheckSUNDIALS(context):
1502      keep = KeepContext(context,'IDA')      keep = KeepContext(context,'SUNDIALS')
1503      context.Message("Checking SUNDIALS version... ")      context.Message("Checking for SUNDIALS... ")
1504      (is_ok,output) = context.TryRun(sundials_version_text,'.c')      (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1505      keep.restore(context)      keep.restore(context)
1506      if not is_ok:      if not is_ok:
1507          context.Result("failed to run check")          context.Result(0)
1508          return 0          return 0
1509    
1510      major,minor,patch = tuple([int(i) for i in output.split(".")])      major,minor,patch = tuple([int(i) for i in output.split(".")])
# Line 1060  def CheckIDAVersion(context): Line 1518  def CheckIDAVersion(context):
1518          return 0          return 0
1519                    
1520      # good version      # good version
1521      context.Result(output+", good")      context.Result("%d.%d.%d, good" % (major,minor,patch))
1522    
1523      return 1      return 1
1524            
1525    
1526    def CheckIDA(context):
1527        context.Message( 'Checking for IDA... ' )
1528    
1529        keep = KeepContext(context,"SUNDIALS")
1530    
1531        major = context.env['SUNDIALS_VERSION_MAJOR']
1532        minor = context.env['SUNDIALS_VERSION_MINOR']
1533    
1534        cppdef = context.env.get('CPPDEFINES')
1535    
1536        context.env.Append(CPPDEFINES=[
1537            ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1538            ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1539        ])
1540    
1541        context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1542        if major==2 and minor==2:
1543            context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1544    
1545        context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1546        context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1547        context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1548    
1549        is_ok = context.TryLink(ida_test_text,".c")
1550        context.Result(is_ok)
1551        
1552        if cppdef:
1553            context.env['CPPDEFINES']=cppdef
1554        else:
1555            del context.env['CPPDEFINES']
1556    
1557        keep.restore(context)
1558            
1559        return is_ok
1560    
1561    
1562  #----------------  #----------------
1563  # CONOPT test  # CONOPT test
1564    
# Line 1095  def CheckCONOPT(context): Line 1591  def CheckCONOPT(context):
1591      return is_ok      return is_ok
1592    
1593  #----------------  #----------------
1594    # IPOPT test
1595    
1596    ipopt_test_text = """
1597    #if !defined(_WIN32)
1598    # define FNAME_LCASE_DECOR
1599    #endif
1600    
1601    #include <ipopt/IpStdCInterface.h>
1602    int main(){
1603        Number n;
1604        IpoptProblem nlp = 0;
1605        FreeIpoptProblem(nlp); // probably a crash if you run this
1606        return 0;
1607    }
1608    """
1609    
1610    def CheckIPOPT(context):
1611        context.Message( 'Checking for IPOPT... ' )
1612    
1613        keep = KeepContext(context,"IPOPT")
1614        is_ok = context.TryLink(ipopt_test_text,".c")
1615        context.Result(is_ok)
1616        
1617        keep.restore(context)
1618            
1619        return is_ok
1620    
1621    #----------------
1622  # Tcl test  # Tcl test
1623    
1624  # 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 1201  def CheckX11(context): Line 1725  def CheckX11(context):
1725      return CheckExtLib(context,'X11',x11_check_text)      return CheckExtLib(context,'X11',x11_check_text)
1726    
1727  #----------------  #----------------
1728    # Check that we can raise and catch sigint
1729    
1730    sigint_test_text = r"""
1731    #include <signal.h>
1732    #include <setjmp.h>
1733    #include <stdlib.h>
1734    static jmp_buf g_jmpenv;
1735    void sighandler(int sig){
1736        longjmp(g_jmpenv,sig);
1737    }
1738    void testsigint(){
1739        raise(SIGINT);
1740    }
1741    int main(void){
1742        signal(SIGINT,&sighandler);
1743        switch(setjmp(g_jmpenv)){
1744            case 0:
1745                testsigint();
1746                exit(1);
1747            case SIGINT:
1748                exit(0);
1749            default:
1750                exit(2);
1751        }
1752    }
1753    """
1754    
1755    def CheckSIGINT(context):
1756        context.Message("Checking SIGINT is catchable... ")
1757        (is_ok,output)=context.TryRun(sigint_test_text,".c")
1758        context.Result(is_ok)
1759        return is_ok
1760    
1761    #----------------
1762  # Check that we're able to catch floating point errors  # Check that we're able to catch floating point errors
1763    
1764  sigfpe_test_text = r"""  sigfpe_test_text = r"""
# Line 1231  int main(void){ Line 1789  int main(void){
1789  """  """
1790    
1791  def CheckFPE(context):  def CheckFPE(context):
1792      context.Message("Checking for C99 FPE behaviour... ")      context.Message("Checking C99 FPE behaviour... ")
1793      (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')      (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1794      context.Result(is_ok)      context.Result(is_ok)
1795      return is_ok      return is_ok
1796    
1797  #----------------  #----------------
1798    # signal reset needed?
1799    
1800    sigreset_test_text = r"""
1801    #include <signal.h>
1802    #include <setjmp.h>
1803    #include <stdlib.h>
1804    #include <stdio.h>
1805    typedef void SigHandlerFn(int);
1806    static jmp_buf g_jmpenv;
1807    void sighandler(int sig){
1808        longjmp(g_jmpenv,sig);
1809    }
1810    void testsigint(){
1811        /* fprintf(stderr,"Raising SIGINT\n"); */
1812        raise(SIGINT);
1813    }
1814    int main(void){
1815        SigHandlerFn *last,*saved;
1816        saved = signal(SIGINT,&sighandler);
1817        if(saved!=SIG_DFL){
1818            fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1819            exit(3);
1820        }
1821        switch(setjmp(g_jmpenv)){
1822            case 0:
1823                testsigint();
1824                fprintf(stderr,"Back from SIGINT\n");
1825                exit(1);
1826            case SIGINT:
1827                break;
1828            default:
1829                exit(2);
1830        };
1831        last = signal(SIGINT,SIG_DFL);
1832        if(last!=&sighandler){
1833            printf("1");
1834            exit(0);
1835        }
1836        printf("0");
1837        exit(0);
1838    }
1839    """
1840    
1841    def CheckSigReset(context):
1842        context.Message("Checking signal handler reset... ")
1843        (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1844        if not is_ok:
1845            context.Result("ERROR")
1846            return False
1847        if int(output)==1:
1848            context.Result("required");
1849            context.env['ASC_RESETNEEDED'] = True
1850        else:
1851            context.Result("not required");
1852            context.env['ASC_RESETNEEDED'] = False
1853        return True
1854    
1855    #----------------
1856    # LyX on this system?
1857    
1858    def CheckLyx(context):
1859        context.Message("Checking for LyX... ")
1860        r = context.env.WhereIs("lyx")
1861        if r:
1862            context.Result(r)
1863        else:
1864            context.Result(0)
1865        return r
1866    
1867    #----------------
1868    # Latex2HTML on this system?
1869    
1870    def CheckLatex2HTML(context):
1871        context.Message("Checking for latex2html...")
1872        if context.env.WhereIs("latex2html"):
1873            r = True
1874        else:
1875            r = False
1876        context.Result(r)
1877        return r
1878    
1879    #----------------
1880    # 'lmodern' package for LaTeX available?
1881    
1882    lmodern_test_text = """
1883    \documentclass{article}
1884    \title{Cartesian closed categories and the price of eggs}
1885    \author{Jane Doe}
1886    \date{September 1994}
1887    \begin{document}
1888       \maketitle
1889       Hello world!
1890    \end{document}
1891    """;
1892    
1893    def CheckLModern(context):
1894        context.Message("Checking for lmodern...")
1895        print env['BUILDERS']
1896        b = env['BUILDERS']["DVI"]
1897        print "Builder:",b
1898        is_ok,res = context.TryBuild(builder=b,text=lmodern_test_text,extension=".latex")
1899        context.Result(is_ok)
1900        return is_ok
1901    
1902    #----------------
1903  # GCC Version sniffing  # GCC Version sniffing
1904    
1905  # TODO FIXME  # TODO FIXME
# Line 1248  gcc_version4 = False Line 1911  gcc_version4 = False
1911    
1912  conf = Configure(env  conf = Configure(env
1913      , custom_tests = {      , custom_tests = {
1914          'CheckMath' : CheckMath          'CheckCC' : CheckCC
1915            , 'CheckCXX' : CheckCXX
1916            , 'CheckF77' : CheckF77
1917            , 'CheckMath' : CheckMath
1918            , 'CheckMalloc' : CheckMalloc
1919            , 'CheckDLOpen' : CheckDLOpen
1920          , 'CheckSwigVersion' : CheckSwigVersion          , 'CheckSwigVersion' : CheckSwigVersion
1921          , 'CheckPythonLib' : CheckPythonLib          , 'CheckPythonLib' : CheckPythonLib
1922          , 'CheckCUnit' : CheckCUnit          , 'CheckCUnit' : CheckCUnit
1923          , 'CheckDMalloc' : CheckDMalloc          , 'CheckDMalloc' : CheckDMalloc
1924            , 'CheckLyx' : CheckLyx
1925            , 'CheckLatex2HTML' : CheckLatex2HTML
1926            , 'CheckLModern' : CheckLModern
1927            , 'CheckGraphViz' : CheckGraphViz
1928            , 'CheckUFSparse' : CheckUFSparse
1929          , 'CheckTcl' : CheckTcl          , 'CheckTcl' : CheckTcl
1930          , 'CheckTclVersion' : CheckTclVersion          , 'CheckTclVersion' : CheckTclVersion
1931          , 'CheckTk' : CheckTk          , 'CheckTk' : CheckTk
# Line 1260  conf = Configure(env Line 1933  conf = Configure(env
1933          , 'CheckGcc' : CheckGcc          , 'CheckGcc' : CheckGcc
1934          , 'CheckGccVisibility' : CheckGccVisibility          , 'CheckGccVisibility' : CheckGccVisibility
1935          , 'CheckYacc' : CheckYacc          , 'CheckYacc' : CheckYacc
1936            , 'CheckLex' : CheckLex
1937          , 'CheckTkTable' : CheckTkTable          , 'CheckTkTable' : CheckTkTable
1938          , 'CheckX11' : CheckX11          , 'CheckX11' : CheckX11
1939          , 'CheckIDA' : CheckIDA          , 'CheckIDA' : CheckIDA
1940          , 'CheckIDAVersion' : CheckIDAVersion          , 'CheckSUNDIALS' : CheckSUNDIALS
1941          , 'CheckCONOPT' : CheckCONOPT          , 'CheckCONOPT' : CheckCONOPT
1942            , 'CheckIPOPT' : CheckIPOPT
1943          , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig          , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1944          , 'CheckFPE' : CheckFPE          , 'CheckFPE' : CheckFPE
1945            , 'CheckSIGINT' : CheckSIGINT
1946            , 'CheckSigReset' : CheckSigReset
1947  #       , 'CheckIsNan' : CheckIsNan  #       , 'CheckIsNan' : CheckIsNan
1948  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig
1949      }      }
1950  #   , config_h = "config.h"  #   , config_h = "config.h"
1951  )  )
1952    
1953    def sconsversioncheck():
1954    
1955    #   uncomment the following line to skip the version check:
1956    #   return 1
1957    
1958        import SCons
1959        v = SCons.__version__.split(".")
1960        if v[0] != '0':
1961            return 0
1962        if int(v[1]) >= 97:
1963            return 1
1964        if v[1] != '96':
1965            return 0
1966        micro = int(v[2])
1967        if micro == 92 or micro == 93 or micro == 96:
1968            return 1;
1969        return 0
1970    
1971    if not sconsversioncheck():
1972        print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
1973        print "or consult the developers in the case of newer versions. Modify"
1974        print "the function 'sconsversioncheck' in the file SConstruct if you"
1975        print "want to *force* SCons to continue."
1976        Exit(1)
1977    
1978    # check C compiler
1979    
1980    if conf.CheckCC() is False:
1981        print "Failed to build simple test file with your C compiler."
1982        print "Check your compiler is installed and running correctly."
1983        Exit(1)
1984    
1985    if conf.CheckCXX() is False:
1986        print "Failed to build simple test file with your C++ compiler."
1987        print "Check your compiler is installed and running correctly."
1988        print "You can set your C++ compiler using the CXX scons option."
1989        Exit(1)
1990    
1991  # stdio -- just to check that compiler is behaving  # stdio -- just to check that compiler is behaving
1992    
1993  if not conf.CheckHeader('stdio.h'):  if conf.CheckHeader('stdio.h') is False:
1994      print "CPPPATH =",env.get('CPPPATH')      print "CPPPATH =",env.get('CPPPATH')
1995      print "Did not find 'stdio.h'! Check your compiler configuration."      print "Did not find 'stdio.h'! Check your compiler configuration."
1996        print ""
1997        print "You environment is printed here:"
1998        for k,v in os.environ.iteritems():
1999            print "%-30s%s" % ("%s :" % k, v)
2000      Exit(1)      Exit(1)
2001    
2002    if conf.CheckFunc('snprintf') is False:
2003        print "Didn't find snprintf";
2004        exit(1)
2005    
2006    if conf.CheckFunc('strdup'):
2007        conf.env['HAVE_STRDUP'] = True
2008    
2009  # Math library  # Math library
2010    
2011  if need_libm:  conf.env['HAVE_IEEE']=True
2012      if not conf.CheckMath():  
2013          print 'Did not find math library, exiting!'  if need_libm and (conf.CheckMath() is False):
2014          Exit(1)      conf.env['HAVE_IEEE']=False
2015      #pass      print 'Did not find math library, exiting!'
2016        Exit(1)
2017    
2018    # Malloc
2019    
2020    if conf.CheckMalloc() is False:
2021        conf.env['HAVE_MALLOC']=False
2022        print "Did not find functioning 'malloc', exiting!"
2023        Exit(1)
2024    
2025    # dlopen/LoadLibrary
2026    
2027    # CURRENTLY BREAKS LATER TEST (libsave?)
2028    #if conf.CheckDLOpen() is False:
2029    #   print "Did not find functioning dlopen/LoadLibrary, exiting!"
2030    #   Exit(1)
2031    
2032  # Where is 'isnan'?  # Where is 'isnan'?
2033    
2034  if not conf.CheckFunc('isnan') and not conf.CheckFunc('_isnan'):  if conf.CheckFunc('isnan') is False and conf.CheckFunc('_isnan') is False:
2035      print "Didn't find isnan"      print "Didn't find isnan"
2036  #   Exit(1)  #   Exit(1)
2037    
# Line 1304  if conf.CheckGcc(): Line 2045  if conf.CheckGcc():
2045          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
2046      conf.env.Append(CCFLAGS=['-Wall'])      conf.env.Append(CCFLAGS=['-Wall'])
2047    
2048    # Catching SIGINT
2049    
2050    if env['WITH_SIGNALS']:
2051        if not conf.CheckSIGINT():
2052            with_signals = False
2053            without_signals_reason = "SIGINT uncatchable"
2054    
2055  # Catching SIGFPE  # Catching SIGFPE
2056    
2057  if conf.CheckFPE():  if conf.CheckFPE():
2058      conf.env['HAVE_SIGFPE']=True      conf.env['HAVE_C99FPE']=True
2059  else:  else:
2060      conf.env['HAVE_SIGFPE']=False      conf.env['HAVE_C99FPE']=False
2061    
2062    # Checking for signal reset requirement
2063    
2064    if conf.CheckSigReset() is False:
2065        print "Unable to determine if signal reset is required"
2066        Exit(1)
2067    
2068  # YACC  # YACC
2069    
2070  if not conf.CheckYacc():  if conf.CheckYacc():
     print "YACC NOT FOUND OR NOT WORKING"  
 else:  
2071      conf.env['HAVE_YACC']=True      conf.env['HAVE_YACC']=True
2072    
2073  conf.env['HAVE_LEX']=True  if conf.CheckLex():
2074        conf.env['HAVE_LEX']=True
2075    
2076  # Tcl/Tk  # Tcl/Tk
2077    
# Line 1356  if env['STATIC_TCLTK']: Line 2109  if env['STATIC_TCLTK']:
2109  if not conf.CheckPythonLib():  if not conf.CheckPythonLib():
2110      without_python_reason = 'libpython2.x not found or not linkable'      without_python_reason = 'libpython2.x not found or not linkable'
2111      with_python = False      with_python = False
2112        env['WITH_PYTHON']=False
2113    
2114  # SWIG version  # SWIG version
2115    
2116  if with_python and not conf.CheckSwigVersion():  if with_python and conf.CheckSwigVersion() is False:
2117      without_python_reason = 'SWIG >= 1.3.24 is required'      without_python_reason = 'SWIG >= 1.3.24 is required'
2118      with_python = False      with_python = False
2119        env['WITH_PYTHON']=False
2120    
2121  # CUnit  # CUnit
2122    
# Line 1378  if with_dmalloc: Line 2133  if with_dmalloc:
2133          without_dmalloc_reason = 'dmalloc not found'          without_dmalloc_reason = 'dmalloc not found'
2134          with_dmalloc = False          with_dmalloc = False
2135    
2136    # GRAPHVIZ
2137    
2138    if with_graphviz:
2139        if not conf.CheckGraphViz():
2140            without_graphviz_reason = 'graphviz not found'
2141            with_graphviz = False
2142            env['WITH_GRAPHVIZ'] = False
2143    
2144    # UFSPARSE
2145    
2146    if with_ufsparse:
2147        if not conf.CheckUFSparse():
2148            without_ufsparse_reason = 'ufsparse not found'
2149            with_ufsparse = False
2150            env['WITH_UFSPARSE'] = False
2151    
2152  # IDA  # IDA
2153    
2154  if not with_ida:  if not with_ida:
2155      without_ida_reason = "Not selected (see config option WITH_SOLVERS)"      without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
2156  elif not conf.CheckIDA():  elif not conf.CheckSUNDIALS():
2157      with_ida = False      with_ida = False
2158      without_ida_reason = "IDA not found"      without_ida_reason = "SUNDIALS not found, or bad version"
2159  elif not conf.CheckIDAVersion():  elif not conf.CheckIDA():
2160      with_ida = False      with_ida = False
2161      without_ida_reason = "Unsupported (or undetected) SUNDIALS version"      without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2162    
2163  # CONOPT  # CONOPT
2164    
2165  if not with_conopt:  if not with_conopt:
2166      without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"      without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2167  elif not conf.CheckCONOPT():  elif conf.CheckCONOPT() is False:
2168      with_conopt = False      if conf.env.get('CONOPT_LINKED'):
2169      without_conpt_reason = "CONOPT not found"          conf.env['CONOPT_LINKED'] = False
2170        # we no longer require CONOPT at buildtime in order to build support for it
2171        #with_conopt = False
2172        #without_conpt_reason = "CONOPT not found"
2173    
2174    # IPOPT
2175    
2176    if not with_ipopt:
2177        without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2178    elif not conf.CheckIPOPT():
2179        with_ipopt = False
2180        without_ipopt_reason = "IPOPT not found"
2181    
2182  # BLAS  # BLAS
2183    
# Line 1403  need_blas=False Line 2185  need_blas=False
2185    
2186  if with_lsode:  if with_lsode:
2187      need_fortran = True      need_fortran = True
2188        need_fortran_reasons.append("LSODE")
2189      need_blas=True      need_blas=True
2190    
2191  if need_blas:  if need_blas:
# Line 1412  if need_blas: Line 2195  if need_blas:
2195      else:      else:
2196          with_local_blas = True          with_local_blas = True
2197          need_fortran = True          need_fortran = True
2198            need_fortran_reasons.append("BLAS")
2199  else:  else:
2200      with_local_blas= False;      with_local_blas= False;
2201      without_local_blas_reason = "BLAS not required"      without_local_blas_reason = "BLAS not required"
# Line 1420  else: Line 2204  else:
2204    
2205  if need_fortran:  if need_fortran:
2206      conf.env.Tool('fortran')      conf.env.Tool('fortran')
2207      detect_fortran = conf.env.Detect(['g77','f77','gfortran'])      detect_fortran = conf.env.Detect(['gfortran','g77'])
2208      if detect_fortran:      if detect_fortran:
2209          # For some reason, g77 doesn't get detected properly on MinGW          # For some reason, g77 doesn't get detected properly on MinGW
2210          if not env.has_key('F77') and not env.has_key('FORTRAN'):          if not env.has_key('F77') and not env.has_key('FORTRAN'):
2211                print "Fixing detection of F77 on MinGW...(?)"
2212              conf.env.Replace(F77=detect_fortran)              conf.env.Replace(F77=detect_fortran)
2213              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
2214              conf.env.Replace(F77FLAGS='')              conf.env.Replace(F77FLAGS='')
# Line 1436  if need_fortran: Line 2221  if need_fortran:
2221                  , src_suffix='.f'                  , src_suffix='.f'
2222              )              )
2223              conf.env.Append(BUILDERS={'Fortran':fortran_builder})              conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2224            if platform.system()=="Linux":
2225                conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2226      else:      else:
2227          with_lsode=False;          with_lsode=False;
2228          without_lsode_reason="FORTRAN-77 required but not found"          without_lsode_reason="FORTRAN-77 required but not found"
2229    
2230    if need_fortran and conf.CheckF77() is False:
2231        print "Failed to build simple test file with your Fortran compiler."
2232        print "Check your compiler is installed and running correctly."
2233        print "You can set your Fortran compiler using the FORTRAN scons option."
2234        print "The fortran compiler is REQUIRED to build:",", ".join(need_fortran_reasons)
2235        print "Perhaps try examining the value of your WITH_SOLVERS option (remove LSODE, etc)."
2236        Exit(1)
2237    
2238  #else:  #else:
2239  #   print "FORTRAN not required"  #   print "FORTRAN not required"
2240    
# Line 1447  if need_fortran: Line 2242  if need_fortran:
2242    
2243  if need_fortran:  if need_fortran:
2244      if platform.system()=="Windows":      if platform.system()=="Windows":
2245          conf.env.Append(LIBPATH='c:\mingw\lib')          pass
2246            #conf.env.Append(LIBPATH='c:\mingw\lib')
2247    
2248  # scrollkeeper  # scrollkeeper
2249    
2250  if with_scrollkeeper:  if with_scrollkeeper:
2251      if not conf.CheckScrollkeeperConfig():      if conf.CheckScrollkeeperConfig() is False:
2252          with_scrollkeeper=False          with_scrollkeeper=False
2253          without_scrollkeeper_reason="unable to detect scrollkeeper-config"          without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2254    
2255    # lyx
2256    
2257    if with_doc_build:
2258        if conf.CheckLyx() is False:
2259            with_doc_build = False
2260            without_doc_build_reason="unable to locate lyx"
2261    
2262        with_latext2html = conf.CheckLatex2HTML()
2263    
2264        #if conf.CheckLModern() is False:
2265        #   with_doc_build = False
2266        #   without_doc_build_reason="'lmodern' is not available"
2267    
2268  # TODO: -D_HPUX_SOURCE is needed  # TODO: -D_HPUX_SOURCE is needed
2269    
2270  # TODO: check size of void*  # TODO: check size of void*
# Line 1469  if platform.system()=="Windows" and env. Line 2278  if platform.system()=="Windows" and env.
2278          print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."          print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2279          Exit(1)          Exit(1)
2280    
2281      if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):      if with_python and conf.CheckHeader(['basetsd.h','BaseTsd.h']) is False:
2282          with_python = 0;          with_python = 0;
2283          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."
2284    
 conf.env.Append(CPPDEFINES=env['PACKAGE_LINKING'])  
   
2285  conf.Finish()  conf.Finish()
2286    
2287  #---------------------------------------  #---------------------------------------
# Line 1488  if release=="0.": Line 2295  if release=="0.":
2295    
2296  subst_dict = {  subst_dict = {
2297      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2298        ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2299      , '@GLADE_FILE@':'ascend.glade'      , '@GLADE_FILE@':'ascend.glade'
2300      , '@HELP_ROOT@':''      , '@HELP_ROOT@':''
2301      , '@ICON_EXTENSION@':icon_extension      , '@ICON_EXTENSION@':icon_extension
# Line 1496  subst_dict = { Line 2304  subst_dict = {
2304      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2305      , '@INSTALL_LIB@':env['INSTALL_LIB']      , '@INSTALL_LIB@':env['INSTALL_LIB']
2306      , '@INSTALL_MODELS@':env['INSTALL_MODELS']      , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2307        , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2308      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2309      , '@VERSION@':version      , '@VERSION@':version
2310      , '@RELEASE@':release      , '@RELEASE@':release
2311      , '@DISTTAR_NAME@':env['DISTTAR_NAME']      , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2312      , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'      , '@WEBHELPROOT@':'http://ascendwiki.cheme.cmu.edu/Category:Documentation'
2313      , '@ASC_SHLIBSUFFIX@':env['SHLIBSUFFIX']      , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2314      , '@ASC_SHLIBPREFIX@':env['SHLIBPREFIX']      , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2315        , '@EXTLIB_SUFFIX@':env['EXTLIB_SUFFIX']
2316        , '@EXTLIB_PREFIX@':env['EXTLIB_PREFIX']
2317      , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'      , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2318      , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir      , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
2319      , '@PYTHON@' : python_exe      , '@PYTHON@' : python_exe
2320        , '@PYVERSION@' : pyversion
2321      , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')      , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
2322      , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')      , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
2323      , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_LIBPATH"))      , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_DLPATH"))
2324      , '@SOURCE_ROOT@':os.path.abspath(str(env.Dir("#")))      , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2325        , '@WITH_SOLVERS@':",".join(env.get('WITH_SOLVERS'))
2326        , '@WITH_GRAPHVIZ@': str(int(env.get('WITH_GRAPHVIZ')))
2327  }  }
2328    
2329  if env.get('WITH_LOCAL_HELP'):  if env.get('WITH_DOC'):
2330      print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']      print "WITH_DOC:",env['WITH_DOC']
2331      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']      subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2332    
2333  # bool options...  # bool options...
2334  for k,v in {  for k,v in {
2335          'ABSOLUTE_PATHS' : 'ASC_ABSOLUTE_PATHS'          'ASC_WITH_IDA':with_ida
2336          ,'WITH_XTERM_COLORS' : 'ASC_XTERM_COLORS'          ,'ASC_WITH_DMALLOC':with_dmalloc
2337          ,'MALLOC_DEBUG' : 'MALLOC_DEBUG'          ,'ASC_WITH_UFSPARSE':with_ufsparse
2338  }.iteritems():          ,'ASC_WITH_CONOPT':with_conopt
2339      if env.get(k):          ,'ASC_LINKED_CONOPT':env.get('CONOPT_LINKED')
2340  #       subst_dict['@'+v+'@']='1'          ,'ASC_WITH_IPOPT':with_ipopt
2341          subst_dict["/\\* #define "+v+' @'+v+"@ \\*/"]='# define '+v+' 1 '          ,'ASC_WITH_LSODE':with_lsode
2342            ,'ASC_WITH_MMIO':with_mmio
2343  if with_ida:          ,'ASC_SIGNAL_TRAPS':with_signals
2344      subst_dict["/\\* #define ASC_WITH_IDA @ASC_WITH_IDA@ \\*/"]='#define ASC_WITH_IDA '          ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2345            ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2346  if with_dmalloc:          ,'HAVE_IEEE':env.get('HAVE_IEEE')
2347      subst_dict["/\\* #define ASC_WITH_DMALLOC @ASC_WITH_DMALLOC@ \\*/"]='#define ASC_WITH_DMALLOC '          ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2348            ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2349  if with_conopt:          ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2350      subst_dict["/\\* #define ASC_WITH_CONOPT @ASC_WITH_CONOPT@ \\*/"]='#define ASC_WITH_CONOPT '          }.iteritems():
2351            
2352  if with_lsode:      if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
     subst_dict["/\\* #define ASC_WITH_LSODE @ASC_WITH_LSODE@ \\*/"]='#define ASC_WITH_LSODE '  
2353    
2354  if with_python:  if with_python:
2355      subst_dict['@ASCXX_USE_PYTHON@']="1"      subst_dict['@ASCXX_USE_PYTHON@']="1"
2356      env['WITH_PYTHON']=1;      env['WITH_PYTHON']=1;
2357    
2358    if with_latex2html:
2359        env['WITH_LATEX2HTML']=1
2360    
2361  if env.has_key('HAVE_GCCVISIBILITY'):  if env.has_key('HAVE_GCCVISIBILITY'):
2362      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2363    
2364  env.Append(SUBST_DICT=subst_dict)  env.Append(SUBST_DICT=subst_dict)
2365    
2366  #------------------------------------------------------  #for k,v in subst_dict.iteritems():
2367  # RECIPE: Fix up long command-line bug on Win2k  #   print "%-50s%s" % ("'%s'"%k,v)
2368    
2369  # Currently this is broken, awaiting help from the SCons users list  # REMOVED: long command-line support on Win2k
   
 if 0 and env['PLATFORM'] == 'win32':  
     import win32file  
     import win32event  
     import win32process  
     import win32security  
     import string  
   
     def my_spawn(sh, escape, cmd, args, spawnenv):  
         for var in spawnenv:  
             spawnenv[var] = spawnenv[var].encode('ascii', 'replace')  
   
         sAttrs = win32security.SECURITY_ATTRIBUTES()  
         StartupInfo = win32process.STARTUPINFO()  
         newargs = string.join(map(escape, args[1:]), ' ')  
         cmdline = cmd + " " + newargs  
   
         # check for any special operating system commands  
         if cmd == 'del':  
             for arg in args[1:]:  
                 win32file.DeleteFile(arg)  
             exit_code = 0  
         else:  
             # otherwise execute the command.  
             hProcess, hThread, dwPid, dwTid = win32process.CreateProcess(None, cmdline, None, None, 1, 0, spawnenv, None, StartupInfo)  
             win32event.WaitForSingleObject(hProcess, win32event.INFINITE)  
             exit_code = win32process.GetExitCodeProcess(hProcess)  
             win32file.CloseHandle(hProcess);  
             win32file.CloseHandle(hThread);  
         return exit_code  
   
     env['SPAWN'] = my_spawn  
2370    
2371  #------------------------------------------------------  #------------------------------------------------------
2372  # RECIPE: SWIG scanner  # RECIPE: SWIG scanner
# Line 1599  SWIGScanner = SCons.Scanner.ClassicCPP( Line 2383  SWIGScanner = SCons.Scanner.ClassicCPP(
2383  env.Append(SCANNERS=[SWIGScanner])  env.Append(SCANNERS=[SWIGScanner])
2384    
2385  #------------------------------------------------------  #------------------------------------------------------
 # 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():  
             contents = re.sub(k, v, contents)  
         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)  
   
 #------------------------------------------------------  
2386  # Recipe for 'CHMOD' ACTION        # Recipe for 'CHMOD' ACTION      
2387            
2388  import SCons      import SCons    
# Line 1701  env.AppendUnique(CPPPATH=['#base/generic Line 2410  env.AppendUnique(CPPPATH=['#base/generic
2410    
2411  if env['DEBUG']:  if env['DEBUG']:
2412      env.Append(CCFLAGS=['-g'])      env.Append(CCFLAGS=['-g'])
2413        env.Append(LINKFLAGS=['-g'])
2414    
2415  if env['GCOV']:  if env['GCOV']:
2416      env.Append(      env.Append(
# Line 1715  if with_ida: Line 2425  if with_ida:
2425  if with_conopt:  if with_conopt:
2426      env.Append(WITH_CONOPT=1)      env.Append(WITH_CONOPT=1)
2427    
2428    if with_ipopt:
2429        env.Append(WITH_IPOPT=1)
2430    
2431  #-------------  #-------------
2432  # TCL/TK GUI  # TCL/TK GUI
2433    
2434  if with_tcltk:  if with_tcltk:
2435      env.SConscript(['tcltk/generic/interface/SConscript'],'env')      env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2436  else:  else:
2437      print "Skipping... Tcl/Tk GUI isn't being built:",without_tcltk_reason      print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2438    
2439  #-------------  #-------------
2440  # PYTHON INTERFACE  # PYTHON INTERFACE
# Line 1729  else: Line 2442  else:
2442  if with_python:  if with_python:
2443      env.SConscript(['pygtk/SConscript'],'env')      env.SConscript(['pygtk/SConscript'],'env')
2444  else:  else:
2445      print "Skipping... Python GUI isn't being built:",without_python_reason      print "Skipping... Python bindings aren't being built:",without_python_reason
2446    
2447  #------------  #------------
2448  # BASE/GENERIC SUBDIRECTORIES  # BASE/GENERIC SUBDIRECTORIES
2449    
2450  libascend_env = env.Copy()  libascend_env = env.Copy()
2451    
2452  dirs = ['general','utilities','compiler','solver','packages']  dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2453    
2454  srcs = []  srcs = []
2455  for d in dirs:  for d in dirs:
# Line 1746  for d in dirs: Line 2459  for d in dirs:
2459  #-------------  #-------------
2460  # IMPORTED CODE: LSODE, BLAS, etc  # IMPORTED CODE: LSODE, BLAS, etc
2461    
2462  if with_lsode:  #if with_lsode:
2463      srcs += env.SConscript(['lsod/SConscript'],'env')  #   srcs += env.SConscript(['lsod/SConscript'],'env')
2464      srcs += env.SConscript(['linpack/SConscript'],'env')  #   srcs += env.SConscript(['linpack/SConscript'],'env')
2465  else:  #else:
2466      print "Skipping... LSODE won't be built:", without_lsode_reason  #   print "Skipping... LSODE won't be built:", without_lsode_reason
2467    
2468  if with_local_blas:  if with_local_blas:
2469      srcs += env.SConscript(['blas/SConscript'],'env')      env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2470  else:  else:
2471        env['blasobjs'] = []
2472      print "Skipping... BLAS won't be built:", without_local_blas_reason      print "Skipping... BLAS won't be built:", without_local_blas_reason
2473    
2474  if not with_ida:  if not with_ida:
2475      print "Skipping... IDA won't be built:", without_ida_reason      print "Skipping... IDA won't be built:", without_ida_reason
2476    
2477    if with_mmio:
2478        srcs += env.SConscript(['mmio/SConscript'],'env')
2479    else:
2480        print "Skipping... MMIO export won't be built:", without_mmio_reason
2481  #-------------  #-------------
2482  # LIBASCEND -- all base/generic functionality  # LIBASCEND -- all base/generic functionality
2483    
2484  if with_dmalloc:  if with_dmalloc:
2485      libascend_env.Append(LIBS=['dmalloc'])      libascend_env.Append(LIBS=['dmalloc'])
2486    
2487    if with_ufsparse:
2488        libascend_env.Append(LIBS=['cxsparse'])
2489    
2490  libascend = libascend_env.SharedLibrary('ascend',srcs)  libascend = libascend_env.SharedLibrary('ascend',srcs)
2491    
2492    # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2493    env['libascend'] = libascend
2494    
2495  env.Alias('libascend',libascend)  env.Alias('libascend',libascend)
2496    
2497  #-------------  #-------------
2498  # UNIT TESTS (C CODE)  # UNIT TESTS (C CODE)
2499    
2500  if with_cunit:  if with_cunit:
2501      testdirs = ['general','solver','utilities']      testdirs = ['general','solver','utilities','linear','compiler']
2502      testsrcs = []      testsrcs = []
2503      for testdir in testdirs:      for testdir in testdirs:
2504          path = 'base/generic/'+testdir+'/test/'          path = 'base/generic/'+testdir+'/test/'
# Line 1792  else: Line 2516  else:
2516      print "Skipping... CUnit tests aren't being built:",without_cunit_reason      print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2517    
2518  #-------------  #-------------
2519  # EXTERNAL FUNCTIONS  # EXTERNAL SOLVERS
2520    
2521  env['extfns']=[]  env['extfns']=[]
2522    
2523    env.SConscript(['solvers/SConscript'],'env')
2524    
2525    #-------------
2526    # EXTERNAL FUNCTIONS
2527    
2528  modeldirs = env.SConscript(['models/SConscript'],'env')  modeldirs = env.SConscript(['models/SConscript'],'env')
2529    
2530  if not with_extfns:  if not with_extfns:
# Line 1807  env.Alias('extfns',env['extfns']) Line 2537  env.Alias('extfns',env['extfns'])
2537    
2538  ascendconfig = env.SubstInFile('ascend-config.in')  ascendconfig = env.SubstInFile('ascend-config.in')
2539    
2540    
2541    #------------------------------------------------------
2542    # CREATE asc4dev scriptlet
2543    
2544    asc4devcmd = env.SubstInFile('tcltk/asc4dev.in')
2545    env.AddPostAction(asc4devcmd, 'chmod 755 $TARGET')
2546  #------------------------------------------------------  #------------------------------------------------------
2547  # INSTALLATION  # INSTALLATION
2548    
2549  if env.get('CAN_INSTALL'):  if env.get('CAN_INSTALL'):
2550    
2551      dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE', 'INSTALL_DOC']      dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2552      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]
2553      install_dirs += modeldirs      install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2554    
2555      # TODO: add install options      # TODO: add install options
2556      env.Alias('install',install_dirs)      env.Alias('install',install_dirs)
2557    
2558      env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_LIB'],libascend)      env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2559    
2560      env.InstallProgram(env['INSTALL_ROOT']+env['INSTALL_BIN'],ascendconfig)      env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2561    
2562  #------------------------------------------------------  #------------------------------------------------------
2563  # WINDOWS INSTALLER  # WINDOWS INSTALLER
2564  # For the windows installer, please see pygtk/SConscript  
2565    if not env.get('NSIS'):
2566        with_installer = False
2567        without_installer_reason = "NSIS not found"
2568    
2569  if with_installer:  if with_installer:
2570      pass      env.Append(NSISDEFINES={
2571            'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2572            ,"VERSION":version
2573            ,'PYVERSION':pyversion
2574        })
2575        installer = env.Installer('nsis/installer.nsi')
2576        Depends(installer,["pygtk","tcltk","ascend.dll","models","ascend-config"])
2577        env.Alias('installer',installer)
2578  else:  else:
2579      print "Skipping... Windows installer isn't being built:",without_installer_reason      print "Skipping... Windows installer isn't being built:",without_installer_reason
2580    
2581    
2582  #------------------------------------------------------  #------------------------------------------------------
2583  # PROJECT FILE for MSVC  # PROJECT FILE for MSVC
2584    
# Line 1846  if platform.system()=="Linux": Line 2593  if platform.system()=="Linux":
2593  #------------------------------------------------------  #------------------------------------------------------
2594  # CREATE OMF FILE FOR USE WITH SCROLLKEEPER  # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2595    
2596  if with_scrollkeeper:  #if with_scrollkeeper:
2597      env.SubstInFile('#/pygtk/gnome/ascend.omf.in')  #   #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2598      env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")  #   #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2599    
2600  #------------------------------------------------------  #------------------------------------------------------
2601  # DISTRIBUTION TAR FILE  # DISTRIBUTION TAR FILE
2602    
2603  env['DISTTAR_FORMAT']='bz2'  env['DISTTAR_FORMAT']='bz2'
2604  env.Append(  env.Append(
2605      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','.pyc','.cvsignore','.dblite','.log','.pl','.out','.exe','.aux','.idx','.toc','.lof','.lot','.mm','.warnings','.tm2','.swp',',tmp','.gz','.bz2','.7z']
2606      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist']      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2607  )  )
2608    
2609  tar = env.DistTar("dist/"+env['DISTTAR_NAME']  tar = env.DistTar("dist/"+env['DISTTAR_NAME']
# Line 1864  tar = env.DistTar("dist/"+env['DISTTAR_N Line 2611  tar = env.DistTar("dist/"+env['DISTTAR_N
2611  )  )
2612    
2613  env.Depends(tar,'ascend.spec')  env.Depends(tar,'ascend.spec')
2614    env.Depends(tar,'#doc/book.pdf')
2615    
2616  Alias('dist',tar)  #------------------------------------------------------
2617    # DISTRIBUTION TAR FILE (new style with AccumulateBuilder)
2618    
2619    # ...
2620    
2621  #------------------------------------------------------  #------------------------------------------------------
2622  # USER'S MANUAL  # DEBIAN TARBALL for use with Build Service
2623    
2624  env.SConscript('doc/SConscript',['env'])  import glob
2625    deb_manfiles = glob.glob('debian/*.man')
2626    
2627    deb_tar = env.Tar(
2628        'dist/debian.tar.gz'
2629        ,deb_manfiles + ['debian/compat','debian/copyright','debian/dirs'
2630            ,'debian/postinst','debian/postrm']
2631        ,TARFLAGS = ['cz']
2632    )
2633    
2634    Alias('dist',[tar,deb_tar])
2635    
2636  #------------------------------------------------------  #------------------------------------------------------
2637  # LIBASCEND DOXYGEN DOCUMENTATION  # DOCUMENTATION
2638    
2639    
2640    if not with_doc_build:
2641        print "Skipping... Documentation isn't being built:",without_doc_build_reason
2642    
2643    #user's manual
2644    env.SConscript('doc/SConscript',['env'])
2645    
2646    # doxygen documentation
2647  env.SConscript('base/doc/SConscript',['env'])  env.SConscript('base/doc/SConscript',['env'])
2648    
2649  #------------------------------------------------------  #------------------------------------------------------
# Line 1886  env.SConscript('base/doc/SConscript',['e Line 2655  env.SConscript('base/doc/SConscript',['e
2655  #------------------------------------------------------  #------------------------------------------------------
2656  # DEFAULT TARGETS  # DEFAULT TARGETS
2657    
2658  default_targets =['libascend']  default_targets =['libascend','solvers']
2659  if with_tcltk:  if with_tcltk:
2660      default_targets.append('tcltk')      default_targets.append('tcltk')
2661  if with_python:  if with_python:
# Line 1895  if with_installer: Line 2664  if with_installer:
2664      default_targets.append('installer')      default_targets.append('installer')
2665  if with_extfns:  if with_extfns:
2666      default_targets.append('extfns')      default_targets.append('extfns')
2667    if with_doc_build:
2668        default_targets.append('doc')
2669    
2670  env.Default(default_targets)  env.Default(default_targets)
2671    
2672  print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])  print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2673    
2674  # vim: set syntax=python:  # vim: set syntax=python:
   

Legend:
Removed from v.960  
changed lines
  Added in v.1712

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