/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 705 by johnpye, Tue Jun 27 02:37:49 2006 UTC revision 1566 by jpye, Thu Aug 2 06:46:43 2007 UTC
# Line 1  Line 1 
1  import os, commands, platform, distutils.sysconfig, os.path  import sys, os, commands, platform, distutils.sysconfig, os.path, re
2    
3  version = "0.9.5.94"  version = "0.9.5.112"
4    
5    pyversion = "%d.%d" % (sys.version_info[0],sys.version_info[1])
6    
7  #------------------------------------------------------  #------------------------------------------------------
8  # OPTIONS  # OPTIONS
# Line 11  version = "0.9.5.94" Line 13  version = "0.9.5.94"
13  opts = Options(['options.cache', 'config.py'])  opts = Options(['options.cache', 'config.py'])
14  #print "PLATFORM = ",platform.system()  #print "PLATFORM = ",platform.system()
15    
16    default_tcl_cpppath = "$TCL/include"
17    default_tron_envvar="TRON_PATH"
18    default_conopt_envvar="CONOPT_PATH"
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 24  if platform.system()=="Windows": Line 30  if platform.system()=="Windows":
30          default_tcl_libpath="$TCL\\lib"          default_tcl_libpath="$TCL\\lib"
31      default_rel_distdir = '.'      default_rel_distdir = '.'
32      default_absolute_paths = False      default_absolute_paths = False
33      default_ida_prefix = "c:/mingw"      
34        default_ida_prefix = "c:\\MinGW"
35        if not os.path.exists(default_ida_prefix):
36            default_ida_prefix = None
37    
38        default_conopt_prefix = "c:\\Program Files\\CONOPT"
39        default_conopt_libpath="$CONOPT_PREFIX"
40        default_conopt_cpppath="$CONOPT_PREFIX"
41        default_conopt_dlpath="$CONOPT_PREFIX"
42        default_conopt_lib="conopt3"
43    
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"
49        default_libpath="$DEFAULT_PREFIX\\lib"
50        default_cpppath="$DEFAULT_PREFIX\\include"
51        
52        if not os.path.exists(default_conopt_prefix):
53            default_conopt_prefix = None
54            
55      need_libm = False      need_libm = False
56      python_exe = "c:\\Python24\\python.exe"      python_exe = "c:\\Python24\\python.exe"
57        default_with_scrollkeeper=False
58        pathsep = ";"
59        
60        default_fortran="g77"
61        default_f2c_lib="g2c"
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 34  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"
78        default_conopt_libpath="$CONOPT_PREFIX/lib"
79        default_conopt_cpppath="$CONOPT_PREFIX/include"
80        default_conopt_dlpath= default_conopt_libpath + ":/usr/local/lib"
81        default_conopt_lib="consub3"
82    
83        default_tron_prefix="/usr"
84        default_tron_dlpath="$TRON_PREFIX/lib"
85        default_tron_lib="tron1"
86    
87        default_prefix="/usr"
88        default_libpath="$DEFAULT_PREFIX/lib"
89        default_cpppath="$DEFAULT_PREFIX/include"
90    
91      need_libm = True      need_libm = True
92      if not os.path.isdir(default_tcl):      if not os.path.isdir(default_tcl):
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
96        pathsep = ":"
97        
98        default_fortran="gfortran"
99        default_f2c_lib="gfortran"
100    
101  opts.Add(  opts.Add(
102      'CC'      'CC'
# Line 61  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 93  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"]          +"; 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 122  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 144  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 -----
236    opts.Add(PackageOption(
237        'DEFAULT_PREFIX'
238        ,"Where are most of the shared libraries located on your system?"
239        ,default_prefix
240    ))
241    
242    #------ install location for python extensions ------
243    
244    # (removed for the moment)
245    
246    #------ cunit --------
247    # Where was CUNIT installed?
248    opts.Add(PackageOption(
249        'CUNIT_PREFIX'
250        ,"Where are your CUnit files?"
251        ,"$DEFAULT_PREFIX"
252    ))
253    
254  # Where are the CUnit includes?  # Where are the CUnit includes?
255  opts.Add(PackageOption(  opts.Add(PackageOption(
256      'CUNIT_CPPPATH'      'CUNIT_CPPPATH'
257      ,"Where are your CUnit include files?"      ,"Where are your CUnit include files?"
258      ,'off'      ,"$CUNIT_PREFIX/include"
259  ))  ))
260    
261  # Where are the CUnit libraries?  # Where are the CUnit libraries?
262  opts.Add(PackageOption(  opts.Add(PackageOption(
263      'CUNIT_LIBPATH'      'CUNIT_LIBPATH'
264      ,"Where are your CUnit libraries?"      ,"Where are your CUnit libraries?"
265      ,'off'      ,"$CUNIT_PREFIX/lib"
266  ))  ))
267    
268    #-------- 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_CPPPATH'      'SUNDIALS_CPPPATH'
278      ,"Where is your ida.h?"      ,"Where is your ida.h?"
279      ,"$IDA_PREFIX/include"      ,"$SUNDIALS_PREFIX/include"
280  )  )
281    
282    #
283  opts.Add(  opts.Add(
284      'IDA_LIBPATH'      'SUNDIALS_LIBPATH'
285      ,"Where are your SUNDIALS libraries installed?"      ,"Where are your SUNDIALS libraries installed?"
286      ,"$IDA_PREFIX/lib"      ,"$SUNDIALS_PREFIX/lib"
287    )
288    
289    opts.Add(
290        'SUNDIALS_LIBS'
291        ,"What libraries are required for SUNDIALS?"
292        ,['sundials_nvecserial','sundials_ida','m']
293    )
294    
295    # ----- conopt-----
296    
297    opts.Add(PackageOption(
298        "CONOPT_PREFIX"
299        ,"Prefix for your CONOPT install (CONOPT ./configure --prefix)"
300        ,default_conopt_prefix
301    ))
302    
303    opts.Add(
304        "CONOPT_LIB"
305        ,"Library linked to for CONOPT"
306        ,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(
316        'CONOPT_CPPPATH'
317        ,"Where is your conopt.h?"
318        ,default_conopt_cpppath
319    )
320    
321    opts.Add(
322        'CONOPT_LIBPATH'
323        ,"Where is your CONOPT library installed?"
324        ,default_conopt_libpath
325    )
326    
327    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'
335        ,"What environment variable should be used at runtime to override the default search location for CONOPT DLL/SO?"
336        ,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(  opts.Add(
388      "IDA_LIB"      'TRON_DLPATH'
389      ,"What libraries to link to for use of IDA (comma-separated). Note that"      ,"What is the default search path that ASCEND should use when dlopening the TRON library at runtime?"
390          +" you will need to include the math library in this list (for now)."      ,default_tron_dlpath
     ,'sundials_ida,sundials_nvecserial,m'  
391  )  )
392    
393    #-------- 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 196  opts.Add(PackageOption( Line 405  opts.Add(PackageOption(
405  ))  ))
406    
407  opts.Add(  opts.Add(
408        "FORTRAN"
409        ,"Fortran compiler (eg g77, gfortran)"
410        ,default_fortran
411    )
412    
413    #------- tcl/tk --------
414    
415    opts.Add(
416      'TCL'      'TCL'
417      ,'Base of Tcl distribution'      ,'Base of Tcl distribution'
418      ,default_tcl      ,default_tcl
# Line 205  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 293  opts.Add( Line 510  opts.Add(
510      ,'X11'      ,'X11'
511  )  )
512    
513    #----- installed file locations (for 'scons install') -----
514    
515  opts.Add(  opts.Add(
516      'INSTALL_PREFIX'      'INSTALL_PREFIX'
517      ,'Root location for installed files'      ,'Root location for installed files'
# Line 317  opts.Add( Line 536  opts.Add(
536      ,"$INSTALL_PREFIX/share"      ,"$INSTALL_PREFIX/share"
537  )  )
538    
   
539  opts.Add(  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)"
# Line 325  opts.Add( Line 543  opts.Add(
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"
567  )  )
568    
569    
570    opts.Add(
571        'INSTALL_ROOT'
572        ,'For use by RPM only: location of %{buildroot} during rpmbuild'
573        ,""
574    )
575    
576    #----------------------
577    
578  opts.Add(  opts.Add(
579      'PYGTK_ASSETS'      'PYGTK_ASSETS'
580      ,'Default location for Glade assets (placed in pygtk/config.py)'      ,'Default location for Glade assets (placed in pygtk/config.py)'
# Line 348  opts.Add(BoolOption( Line 593  opts.Add(BoolOption(
593      ,False      ,False
594  ))  ))
595    
596  opts.Add(  #------ dmalloc --------
597      'INSTALL_ROOT'  opts.Add(PackageOption(
598      ,'For use by RPM only: location of %{buildroot} during rpmbuild'      'DMALLOC_PREFIX'
599      ,""      ,"Where are your dmalloc files?"
600  )      ,default_prefix
601    ))
602    
603    opts.Add(PackageOption(
604        'DMALLOC_CPPPATH'
605        ,"Where are your dmalloc include files?"
606        ,default_cpppath
607    ))
608    
609    opts.Add(PackageOption(
610        'DMALLOC_LIBPATH'
611        ,"Where are your dmalloc libraries?"
612        ,default_libpath
613    ))
614    
615    opts.Add(BoolOption(
616        'WITH_DMALLOC'
617        ,"Link to the DMALLOC library (if available) for debugging of memory usage."
618        ,False
619    ))
620    
621    #------ f --------
622    opts.Add(PackageOption(
623        'MFGRAPH_PREFIX'
624        ,"Where are your MFGRAPH files?"
625        ,default_prefix
626    ))
627    
628    opts.Add(PackageOption(
629        'MFGRAPH_CPPPATH'
630        ,"Where are your MFGRAPH include files?"
631        ,default_cpppath
632    ))
633    
634    opts.Add(PackageOption(
635        'MFGRAPH_LIBPATH'
636        ,"Where are your MFGRAPH libraries?"
637        ,default_libpath
638    ))
639    
640    opts.Add(BoolOption(
641        'WITH_MFGRAPH'
642        ,"Link to the MFGRAPH library (if available, for generating incidence graphs)"
643        ,True
644    ))
645    
646    
647    #------ ufsparse --------
648    opts.Add(PackageOption(
649        'UFSPARSE_PREFIX'
650        ,"Where are your UFSPARSE files?"
651        ,default_prefix
652    ))
653    
654    opts.Add(PackageOption(
655        'UFSPARSE_CPPPATH'
656        ,"Where are your UFSPARSE include files?"
657        ,default_cpppath
658    ))
659    
660    opts.Add(PackageOption(
661        'UFSPARSE_LIBPATH'
662        ,"Where are your UFSPARSE libraries?"
663        ,default_libpath
664    ))
665    
666    opts.Add(BoolOption(
667        'WITH_UFSPARSE'
668        ,"Link to the UFSPARSE library (if available, for additional sparse matrix routines)"
669        ,True
670    ))
671    
672    #-----------------------
673    
674    opts.Add(BoolOption(
675        'UPDATE_NO_YACC_LEX'
676        ,"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)"
677        ,False
678    ))
679    
680  opts.Add(  opts.Add(
681      'DISTTAR_NAME'      'DISTTAR_NAME'
# Line 375  opts.Add(BoolOption( Line 698  opts.Add(BoolOption(
698  opts.Add(  opts.Add(
699      'WIN_INSTALLER_NAME'      'WIN_INSTALLER_NAME'
700      ,"Name of the installer .exe to create under Windows (minus the '.exe')"      ,"Name of the installer .exe to create under Windows (minus the '.exe')"
701      ,"ascend-"+version      ,"ascend-"+version+"-py"+pyversion+".exe"
702  )  )
703    
704  opts.Add(BoolOption(  opts.Add(BoolOption(
# Line 384  opts.Add(BoolOption( Line 707  opts.Add(BoolOption(
707      ,True      ,True
708  ))  ))
709    
710    opts.Add(BoolOption(
711        'WITH_EXTFNS'
712        ,"Set to 0 if you don't want to attempt to build the external modules bundled with ASCEND"
713        ,True
714    ))
715    
716    opts.Add(BoolOption(
717        'WITH_SCROLLKEEPER'
718        ,"Set to to 1 if you want to install an OMF file that can be read by scrollkeeper (eg Yelp on GNOME)"
719        ,default_with_scrollkeeper
720    ))
721    
722    
723  if platform.system()!="Windows":  if platform.system()!="Windows":
724      opts.Add(BoolOption(      opts.Add(BoolOption(
725          'WITH_GCCVISIBILITY'          'WITH_GCCVISIBILITY'
# Line 391  if platform.system()!="Windows": Line 727  if platform.system()!="Windows":
727          , True          , True
728      ))      ))
729    
730    
731    
732  # TODO: OTHER OPTIONS?  # TODO: OTHER OPTIONS?
733  # TODO: flags for optimisation  # TODO: flags for optimisation
734  # TODO: turning on/off bintoken functionality  # TODO: turning on/off bintoken functionality
# Line 398  if platform.system()!="Windows": Line 736  if platform.system()!="Windows":
736    
737  # Import the outside environment  # Import the outside environment
738    
739  if os.environ.get('OSTYPE')=='msys':  def c_escape(str):
740      env = Environment(          return re.sub("\\\\","/",str)
741          ENV=os.environ  
742          , tools=['mingw','lex','yacc','fortran','swig','disttar','nsis']  envadditional={}
743          , toolpath=['scons']  
744      )  tools = ['lex','yacc','fortran','swig','nsis','substinfile','disttar']
745      env['IS_MINGW']=True  if platform.system()=="Windows":
746        if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
747            envenv = os.environ;
748            tools += ['mingw']
749            #TODO removed 'doxygen' for SCons 0.96.93
750            envadditional['IS_MINGW']=True
751        else:
752            print "Assuming VC++ build environment (Note: MinGW is preferred)"
753            envenv = {
754                'PATH':os.environ['PATH']
755                ,'INCLUDE':os.environ['INCLUDE']
756                ,'LIB':os.environ['LIB']
757                ,'MSVS_IGNORE_IDE_PATHS':1
758            }
759            tools += ['default']
760            #TODO removed 'doxygen' for SCons 0.96.93
761            envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
762  else:  else:
763      env = Environment(      if os.environ.get('TARGET')=='mingw':
764          ENV=os.environ          envenv = os.environ
765          ,tools=['default','lex','yacc','fortran','swig','disttar','nsis']          tools += ['crossmingw']
766          , toolpath=['scons']          envadditional['CPPPATH']=['/usr/lib/gcc/i586-mingw32msvc/3.4.5/include','/usr/include']
767      )          envadditional['LIBS']=['gcc']
768        else:
769            envenv = os.environ
770            tools += ['default']
771            #TODO removed 'doxygen' for SCons 0.96.93
772        
773        
774    env = Environment(
775        ENV=envenv
776        , toolpath=['scons']
777        , tools=tools
778        , **envadditional
779    )
780    
781  if platform.system()=='Windows' and env.has_key('MSVS'):  #print "PATH =",os.environ['PATH']
782      print "INCLUDE =",env['ENV']['INCLUDE']  #print "PROGSUFFIX =",env['PROGSUFFIX']
783      print "LIB =",env['ENV']['LIB']  #print "CPPPATH =",env['CPPPATH']
     print "PATH =",env['ENV']['PATH']  
     env.Append(CPPPATH=env['ENV']['INCLUDE'])  
     env.Append(LIBPATH=env['ENV']['LIB'])  
     env.Append(CPPDEFINES=['_CRT_SECURE_NO_DEPRECATE'])  
     env.Append(CCFLAGS=['/Za'])  
784    
785  opts.Update(env)  opts.Update(env)
786    
787    if 'LSOD' in env['WITH_SOLVERS']:
788        if 'LSODE' not in env['WITH_SOLVERS']:
789            env['WITH_SOLVERS'].append('LSODE')
790        env['WITH_SOLVERS'].remove('LSOD')
791    
792  opts.Save('options.cache',env)  opts.Save('options.cache',env)
793    
794  Help(opts.GenerateHelpText(env))  Help(opts.GenerateHelpText(env))
# Line 435  without_python_reason = "disabled by opt Line 802  without_python_reason = "disabled by opt
802  with_cunit = env.get('WITH_CUNIT')  with_cunit = env.get('WITH_CUNIT')
803  without_cunit_reason = "not requested"  without_cunit_reason = "not requested"
804    
805    with_extfns = env.get('WITH_EXTFNS')
806    without_extfn_reason = "disabled by options/config.py"
807    
808    with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
809    without_scrollkeeper_reason = "disabled by options/config.py"
810    
811    with_dmalloc = env.get('WITH_DMALLOC')
812    without_dmalloc_reason = "disabled by options/config.py"
813    
814    with_mfgraph = env.get('WITH_MFGRAPH')
815    without_mfgraph_reason = "disabled by options/config.py"
816    
817    with_ufsparse = env.get('WITH_UFSPARSE')
818    without_ufsparse_reason = "disabled by options/config.py"
819    
820    with_mmio = env.get('WITH_MMIO')
821    without_mmio_reason = "disabled by options/config.py"
822    
823    with_signals = env.get('WITH_SIGNALS')
824    without_signals_reason = "disabled by options/config.py"
825    
826    with_doc = env.get('WITH_DOC')
827    
828    with_doc_build = env.get('WITH_DOC_BUILD');
829    without_doc_build_reason = "disabled by options/config.py"
830    if not with_doc:
831        with_doc_build = False
832        without_doc_build_reason = "disabled by with_doc"
833    
834    with_latex2html = False
835    
836  if platform.system()=="Windows":  if platform.system()=="Windows":
837      with_installer=1      with_installer=1
838  else:  else:
839      with_installer=0      with_installer=0
840      without_installer_reason = "only possible under Windows"      without_installer_reason = "only possible under Windows"
841            
842  if 'LSOD' in env['WITH_SOLVERS']:  if 'LSODE' in env['WITH_SOLVERS']:
843      with_lsode=True      with_lsode=True
844  else:  else:
845      with_lsode=False      with_lsode=False
# Line 454  else: Line 852  else:
852      without_ida_reason = "not requested (WITH_SOLVERS)"      without_ida_reason = "not requested (WITH_SOLVERS)"
853    
854    
855    if 'CONOPT' in env['WITH_SOLVERS']:
856        with_conopt=True
857    else:
858        with_conopt=False
859        without_conopt_reason = "not requested (WITH_SOLVERS)"
860    
861    if 'IPOPT' in env['WITH_SOLVERS']:
862        with_ipopt=True
863    else:
864        with_ipopt=False
865        without_ipopt_reason = "not requested (WITH_SOLVERS)"
866    
867    
868  #print "SOLVERS:",env['WITH_SOLVERS']  #print "SOLVERS:",env['WITH_SOLVERS']
869  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
870  #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']  #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
# Line 464  if platform.system()=='Windows': Line 875  if platform.system()=='Windows':
875    
876  env['CAN_INSTALL']=can_install  env['CAN_INSTALL']=can_install
877    
878    print "TCL=",env['TCL']
879  print "TCL_CPPPATH =",env['TCL_CPPPATH']  print "TCL_CPPPATH =",env['TCL_CPPPATH']
880  print "TCL_LIBPATH =",env['TCL_LIBPATH']  print "TCL_LIBPATH =",env['TCL_LIBPATH']
881  print "TCL_LIB =",env['TCL_LIB']  print "TCL_LIB =",env['TCL_LIB']
# Line 472  print "CXX =",env['CXX'] Line 884  print "CXX =",env['CXX']
884  print "FORTRAN=",env.get('FORTRAN')  print "FORTRAN=",env.get('FORTRAN')
885    
886  print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']  print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
887    print "INSTALL_ASCDATA =",env['INSTALL_ASCDATA']
888    print "INSTALL_PREFIX =",env['INSTALL_PREFIX']
889    print "INSTALL_MODELS =",env['INSTALL_MODELS']
890    print "INSTALL_SOLVERS =",env['INSTALL_SOLVERS']
891    print "DEFAULT_ASCENDLIBRARY =",env['DEFAULT_ASCENDLIBRARY']
892    print "DEFAULT_ASCENDSOLVERS =",env['DEFAULT_ASCENDSOLVERS']
893    
894    
895  #------------------------------------------------------  #------------------------------------------------------
896  # SPECIAL CONFIGURATION TESTS  # SPECIAL CONFIGURATION TESTS
897    
898  need_fortran = False  need_fortran = False
899    
900  #----------------  #----------------
901    # CC
902    
903    cc_test_text = """
904    int main(void){
905        return 0;
906    }
907    """;
908    
909    def CheckCC(context):
910        context.Message("Checking C compiler ('%s')... " % context.env.get('CC'))
911        is_ok = context.TryCompile(cc_test_text,".c")
912        context.Result(is_ok)
913        return is_ok
914    
915    #----------------
916    # CXX
917    
918    cxx_test_text = """
919    template<class X>
920    class pair{
921    public:
922        X a;
923        X b;
924    };
925    
926    int main(void){
927        pair<double> P;
928        P.a = 0;
929        return 0;
930    }
931    """;
932    
933    def CheckCXX(context):
934        context.Message("Checking C++ compiler ('%s')... " % context.env.get('CXX'))
935        is_ok = context.TryCompile(cc_test_text,".cpp")
936        context.Result(is_ok)
937        return is_ok
938    
939        
940    
941    #----------------
942  # SWIG  # SWIG
943    
944  import os,re  import os,re
# Line 521  def CheckSwigVersion(context): Line 982  def CheckSwigVersion(context):
982          return 0;          return 0;
983    
984  #----------------  #----------------
985    # Scrollkeeper (Linux documentation system)
986    
987    def get_scrollkeeper_omfdir(env):
988        cmd = 'scrollkeeper-config --omfdir'
989        (cin,coutcerr) = os.popen4(cmd)
990        output = coutcerr.read()
991        return output.strip()
992    
993    def CheckScrollkeeperConfig(context):
994        try:
995            context.Message("Checking for scrollkeeper...")
996            dir=get_scrollkeeper_omfdir(context.env)
997        except:
998            context.Result("Failed to run 'scrollkeeper-config'")
999            return 0
1000        context.env['OMFDIR']=dir
1001        context.Result("OK, %s" % dir)
1002        return 1
1003    
1004    #----------------
1005  # General purpose library-and-header test  # General purpose library-and-header test
1006    
1007  class KeepContext:  class KeepContext:
# Line 531  class KeepContext: Line 1012  class KeepContext:
1012              self.keep[k]=context.env.get(k)              self.keep[k]=context.env.get(k)
1013                    
1014          if context.env.has_key(varprefix+'_CPPPATH'):          if context.env.has_key(varprefix+'_CPPPATH'):
1015              context.env.Append(CPPPATH=[env[varprefix+'_CPPPATH']])              context.env.AppendUnique(CPPPATH=[env[varprefix+'_CPPPATH']])
1016              #print "Adding '"+str(cpppath_add)+"' to cpp path"              #print "Adding '"+str(env[varprefix+'_CPPPATH'])+"' to cpp path"
1017    
1018          if static:          if static:
1019              staticlib=env[varprefix+'_LIB']              staticlib=env[varprefix+'_LIB']
# Line 543  class KeepContext: Line 1024  class KeepContext:
1024          else:          else:
1025              if context.env.has_key(varprefix+'_LIBPATH'):              if context.env.has_key(varprefix+'_LIBPATH'):
1026                  context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])                  context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])
1027                  #print "Adding '"+str(libpath_add)+"' to lib path"                  #print "Adding '"+str(env[varprefix+'_LIBPATH'])+"' to lib path"
1028    
1029              if context.env.has_key(varprefix+'_LIB'):              if context.env.has_key(varprefix+'_LIB'):
1030                  context.env.Append(LIBS=[env[varprefix+'_LIB']])                  context.env.Append(LIBS=[env[varprefix+'_LIB']])
1031                  #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"                      #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"    
1032                elif context.env.has_key(varprefix+'_LIBS'):
1033                    context.env.AppendUnique(LIBS=env[varprefix+'_LIBS'])
1034    
1035      def restore(self,context):      def restore(self,context):
1036          #print "RESTORING CONTEXT"          #print "RESTORING CONTEXT"
# Line 647  def CheckGccVisibility(context): Line 1130  def CheckGccVisibility(context):
1130  yacc_test_text = """  yacc_test_text = """
1131  %{  %{
1132  #include <stdio.h>  #include <stdio.h>
1133    
1134    /* MSVC++ needs this before it can swallow Bison output */
1135    #ifdef _MSC_VER
1136    # define __STDC__
1137    #endif
1138  %}  %}
1139  %token MSG  %token MSG
1140  %start ROOT  %start ROOT
# Line 664  def CheckYacc(context): Line 1152  def CheckYacc(context):
1152      return is_ok      return is_ok
1153    
1154  #----------------  #----------------
1155    # LEX
1156    
1157    lex_test_text = """
1158    %{
1159    #include <stdio.h>
1160    %}
1161    DIGIT   [0-9]
1162    ID      [a-z][a-z0-9]*
1163    %%
1164    {DIGIT}+    {
1165            printf("A digit: %s\\n",yytext);
1166        }
1167    
1168    [ \\t\\n]+    /* ignore */
1169    
1170    .           {
1171            printf("Unrecognized guff");
1172        }
1173    %%
1174    main(){
1175        yylex();
1176    }
1177    """
1178    
1179    def CheckLex(context):
1180        context.Message("Checking for Lex ('%s')... " % context.env.get('LEX'))
1181        is_ok = context.TryCompile(lex_test_text,".l")
1182        context.Result(is_ok)
1183        return is_ok
1184    
1185    #----------------
1186  # CUnit test  # CUnit test
1187    
1188  cunit_test_text = """  cunit_test_text = """
# Line 688  def CheckCUnit(context): Line 1207  def CheckCUnit(context):
1207      return CheckExtLib(context,'cunit',cunit_test_text)      return CheckExtLib(context,'cunit',cunit_test_text)
1208    
1209  #----------------  #----------------
1210    # dmalloc test
1211    
1212    dmalloc_test_text = """
1213    #include <stdlib.h>
1214    #include <dmalloc.h>
1215    
1216    int main(void){
1217        char *c;
1218        c = malloc(100*sizeof(char));
1219        free(c);
1220        return 0;
1221    }
1222    """
1223    
1224    def CheckDMalloc(context):
1225        return CheckExtLib(context,'dmalloc',dmalloc_test_text)
1226    
1227    #----------------
1228    # mfgraph test
1229    
1230    mfgraph_test_text = """
1231    #include <mfgraph/mfg_draw_graph.h>
1232    int main(void){
1233        using namespace mfg;
1234        DrawGraph g;
1235        return 0;
1236    }
1237    """
1238    
1239    def CheckMFGraph(context):
1240        return CheckExtLib(context,'mfgraph',mfgraph_test_text,ext=".cpp")
1241    
1242    #----------------
1243    # ufsparse test
1244    
1245    ufsparse_test_text = """
1246    #include <ufsparse/cs.h>
1247    int main(void){
1248        cs *A,*B,*C;
1249        C = cs_multiply(A,B);
1250        return 0;
1251    }
1252    """
1253    
1254    def CheckUFSparse(context):
1255        return CheckExtLib(context
1256            ,libname='cxsparse'
1257            ,varprefix='ufsparse'
1258            ,text=ufsparse_test_text
1259            ,ext=".c"
1260        )
1261    
1262    #----------------
1263  # MATH test  # MATH test
1264    
1265  math_test_text = """  math_test_text = """
# Line 706  int main(void){ Line 1278  int main(void){
1278      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);
1279      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);
1280      y0(x); y1(x); yn(i,x);      y0(x); y1(x); yn(i,x);
1281    /* this part causes problems with crossmingw... */
1282  #ifdef _THREAD_SAFE  #ifdef _THREAD_SAFE
1283      gamma_r(x,&i);      gamma_r(x,&i);
1284      lgamma_r(x,&i);      lgamma_r(x,&i);
# Line 719  gamma(x); Line 1292  gamma(x);
1292  """  """
1293    
1294  def CheckMath(context):  def CheckMath(context):
1295      context.Message('Checking for IEE math library... ')      context.Message('Checking for IEEE math library... ')
1296      libsave=context.env.get('LIBS');      libsave=context.env.get('LIBS');
1297      context.env.AppendUnique(LIBS=['m'])      context.env.AppendUnique(LIBS=['m'])
1298      is_ok=context.TryLink(math_test_text,".c")      is_ok=context.TryLink(math_test_text,".c")
# Line 729  def CheckMath(context): Line 1302  def CheckMath(context):
1302      return is_ok      return is_ok
1303    
1304  #----------------  #----------------
1305    # libpython test
1306    
1307    libpython_test_text = """
1308    #include <Python.h>
1309    int main(void){
1310        PyObject *p;
1311        p = Py_None;
1312        return 0;
1313    }
1314    """
1315    
1316    def CheckPythonLib(context):
1317        context.Message('Checking for libpython... ')
1318    
1319        if platform.system()=="Windows":
1320            python_lib='python%d%d'
1321        else:
1322            python_lib='python%d.%d'
1323        python_libs = [python_lib % (sys.version_info[0],sys.version_info[1])]
1324    
1325        python_cpppath = [distutils.sysconfig.get_python_inc()]
1326        cfig = distutils.sysconfig.get_config_vars()    
1327        
1328        lastLIBS = context.env.get('LIBS')
1329        lastLIBPATH = context.env.get('LIBPATH')
1330        lastCPPPATH = context.env.get('CPPPATH')
1331        lastLINKFLAGS = context.env.get('LINKFLAGS')
1332    
1333        python_libpath = []
1334        python_linkflags = []
1335        if platform.system()=="Windows":
1336            python_libpath += [os.path.join(sys.prefix,"libs")]
1337        else:
1338            # checked on Linux and SunOS
1339            if cfig['LDLIBRARY']==cfig['LIBRARY']:
1340                sys.stdout.write("(static)")
1341                python_libpath += [cfig['LIBPL']]
1342                python_linkflags += cfig['LIBS'].split(' ')
1343    
1344        context.env.AppendUnique(LIBS=python_libs)
1345        context.env.AppendUnique(LIBPATH=python_libpath)
1346        context.env.AppendUnique(CPPPATH=python_cpppath)
1347        context.env.AppendUnique(LINKFLAGS=python_linkflags)
1348        result = context.TryLink(libpython_test_text,".c");
1349    
1350        context.Result(result)  
1351    
1352        if(result):
1353            context.env['PYTHON_LIBPATH']=python_libpath
1354            context.env['PYTHON_LIB']=python_libs
1355            context.env['PYTHON_CPPPATH']=python_cpppath
1356            context.env['PYTHON_LINKFLAGS']=python_linkflags
1357    
1358        context.env['LIBS'] = lastLIBS
1359        context.env['LIBPATH'] = lastLIBPATH
1360        context.env['CPPPATH'] = lastCPPPATH
1361        context.env['LINKFLAGS'] = lastLINKFLAGS
1362    
1363        return result
1364    
1365    #----------------
1366  # IDA test  # IDA test
1367    
1368    sundials_version_major_required = 2
1369    sundials_version_minor_min = 2
1370    sundials_version_minor_max = 3
1371    
1372    sundials_version_text = """
1373    #include <sundials/sundials_config.h>
1374    #include <stdio.h>
1375    int main(){
1376        printf("%s",SUNDIALS_PACKAGE_VERSION);
1377        return 0;
1378    }
1379    """
1380    
1381  ida_test_text = """  ida_test_text = """
1382  #include <ida.h>  #if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
1383  #include <nvector_serial.h>  # include <sundials/sundials_config.h>
1384  #include <ida_spgmr.h>  # include <sundials/sundials_nvector.h>
1385    # include <nvector_serial.h>
1386    # include <ida.h>
1387    # include <ida/ida_spgmr.h>
1388    #else
1389    # include <sundials/sundials_config.h>
1390    # include <nvector/nvector_serial.h>
1391    # include <ida/ida.h>
1392    #endif
1393  int main(){  int main(){
1394      void *ida_mem;      void *ida_mem;
1395      ida_mem = IDACreate();      ida_mem = IDACreate();
1396        return 0;
1397  }  }
1398  """  """
1399    
1400    # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
1401    # so detect the version and act accordingly.
1402    def CheckSUNDIALS(context):
1403        keep = KeepContext(context,'SUNDIALS')
1404        context.Message("Checking for SUNDIALS... ")
1405        (is_ok,output) = context.TryRun(sundials_version_text,'.c')
1406        keep.restore(context)
1407        if not is_ok:
1408            context.Result(0)
1409            return 0
1410    
1411        major,minor,patch = tuple([int(i) for i in output.split(".")])
1412        context.env['SUNDIALS_VERSION_MAJOR'] = major
1413        context.env['SUNDIALS_VERSION_MINOR'] = minor
1414        if major != sundials_version_major_required \
1415                or minor < sundials_version_minor_min \
1416                or minor > sundials_version_minor_max:
1417            context.Result(output+" (bad version)")
1418            # bad version
1419            return 0
1420            
1421        # good version
1422        context.Result("%d.%d.%d, good" % (major,minor,patch))
1423    
1424        return 1
1425        
1426    
1427  def CheckIDA(context):  def CheckIDA(context):
1428      context.Message( 'Checking for IDA (SUNDIALS)... ' )      context.Message( 'Checking for IDA... ' )
1429    
1430        keep = KeepContext(context,"SUNDIALS")
1431    
1432        major = context.env['SUNDIALS_VERSION_MAJOR']
1433        minor = context.env['SUNDIALS_VERSION_MINOR']
1434    
1435        cppdef = context.env.get('CPPDEFINES')
1436    
1437        context.env.Append(CPPDEFINES=[
1438            ('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR")
1439            ,('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")
1440        ])
1441    
1442        context.env['SUNDIALS_CPPPATH_EXTRA']=[]
1443        if major==2 and minor==2:
1444            context.env.Append(SUNDIALS_CPPPATH_EXTRA = ["$SUNDIALS_CPPPATH/sundials"])
1445    
1446        context.env.Append(CPPDEFINES=[('SUNDIALS_VERSION_MAJOR',"$SUNDIALS_VERSION_MAJOR"),('SUNDIALS_VERSION_MINOR',"$SUNDIALS_VERSION_MINOR")])
1447        context.env.AppendUnique(LIBS=context.env['SUNDIALS_LIBS'])
1448        context.env.AppendUnique(CPPPATH=context.env['SUNDIALS_CPPPATH_EXTRA'])
1449    
1450        is_ok = context.TryLink(ida_test_text,".c")
1451        context.Result(is_ok)
1452            
1453      # add SUNDIALS subdirectories as well (what a pain)      if cppdef:
1454      if context.env.get('IDA_CPPPATH'):          context.env['CPPDEFINES']=cppdef
         extra = [context.env['IDA_CPPPATH']+"/ida",context.env['IDA_CPPPATH']+"/sundials"]  
         context.env.Append(CPPPATH=extra)  
       
     if ',' in context.env.get('IDA_LIB'):  
         context.env['IDA_LIB']=context.env['IDA_LIB'].split(',')  
         #print "IDA_LIB NOW =",context.env['IDA_LIB']  
1455      else:      else:
1456          print "NO COMMA IN IDA_LIB:",context.env['IDA_LIB']          del context.env['CPPDEFINES']
1457    
1458      keep = KeepContext(context,"IDA")      keep.restore(context)
1459            
1460        return is_ok
1461    
1462    
1463    #----------------
1464    # CONOPT test
1465    
1466    conopt_test_text = """
1467    #if !defined(_WIN32)
1468    # define FNAME_LCASE_DECOR
1469    #endif
1470    
1471    #include <conopt.h>
1472    #include <stdlib.h>
1473    int main(){
1474        int s, *v, e;
1475        s = COIDEF_Size();
1476        v = (int *)malloc(s*sizeof(int));
1477        e = COIDEF_Ini(v);
1478        return e;
1479    }
1480    """
1481    
1482    def CheckCONOPT(context):
1483        context.Message( 'Checking for CONOPT... ' )
1484    
1485        keep = KeepContext(context,"CONOPT")
1486            
1487      is_ok = context.TryLink(ida_test_text,".c")      is_ok = context.TryLink(conopt_test_text,".c")
1488      context.Result(is_ok)      context.Result(is_ok)
1489            
1490      keep.restore(context)      keep.restore(context)
1491            
1492        return is_ok
1493    
1494    #----------------
1495    # IPOPT test
1496    
1497    ipopt_test_text = """
1498    #if !defined(_WIN32)
1499    # define FNAME_LCASE_DECOR
1500    #endif
1501    
1502    #include <ipopt/IpStdCInterface.h>
1503    int main(){
1504        Number n;
1505        IpoptProblem nlp = 0;
1506        FreeIpoptProblem(nlp); // probably a crash if you run this
1507        return 0;
1508    }
1509    """
1510    
1511    def CheckIPOPT(context):
1512        context.Message( 'Checking for IPOPT... ' )
1513    
1514        keep = KeepContext(context,"IPOPT")
1515        is_ok = context.TryLink(ipopt_test_text,".c")
1516        context.Result(is_ok)
1517            
1518      if is_ok:      keep.restore(context)
1519          context.env.Append(IDA_CPPPATH_EXTRA=extra)          
       
1520      return is_ok      return is_ok
1521    
1522  #----------------  #----------------
# Line 874  def CheckX11(context): Line 1626  def CheckX11(context):
1626      return CheckExtLib(context,'X11',x11_check_text)      return CheckExtLib(context,'X11',x11_check_text)
1627    
1628  #----------------  #----------------
1629    # Check that we can raise and catch sigint
1630    
1631    sigint_test_text = r"""
1632    #include <signal.h>
1633    #include <setjmp.h>
1634    #include <stdlib.h>
1635    static jmp_buf g_jmpenv;
1636    void sighandler(int sig){
1637        longjmp(g_jmpenv,sig);
1638    }
1639    void testsigint(){
1640        raise(SIGINT);
1641    }
1642    int main(void){
1643        signal(SIGINT,&sighandler);
1644        switch(setjmp(g_jmpenv)){
1645            case 0:
1646                testsigint();
1647                exit(1);
1648            case SIGINT:
1649                exit(0);
1650            default:
1651                exit(2);
1652        }
1653    }
1654    """
1655    
1656    def CheckSIGINT(context):
1657        context.Message("Checking SIGINT is catchable... ")
1658        (is_ok,output)=context.TryRun(sigint_test_text,".c")
1659        context.Result(is_ok)
1660        return is_ok
1661    
1662    #----------------
1663    # Check that we're able to catch floating point errors
1664    
1665    sigfpe_test_text = r"""
1666    #include <signal.h>
1667    #include <setjmp.h>
1668    #include <stdlib.h>
1669    #include <fenv.h>
1670    static jmp_buf g_jmpenv;
1671    void fpehandler(int sig){
1672        longjmp(g_jmpenv,sig);
1673    }
1674    int main(void){
1675        fenv_t myfenv;
1676        fegetenv(&myfenv);
1677        fesetenv(&myfenv);
1678        feenableexcept(FE_ALL_EXCEPT);
1679        signal(SIGFPE,&fpehandler);
1680        double x;
1681        switch(setjmp(g_jmpenv)){
1682            case 0:
1683                x = 1.0 / 0.0;
1684                /* failed to catch */
1685                exit(1);            
1686            case SIGFPE:
1687                exit(0);
1688        }
1689    }
1690    """
1691    
1692    def CheckFPE(context):
1693        context.Message("Checking C99 FPE behaviour... ")
1694        (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1695        context.Result(is_ok)
1696        return is_ok
1697    
1698    #----------------
1699    # signal reset needed?
1700    
1701    sigreset_test_text = r"""
1702    #include <signal.h>
1703    #include <setjmp.h>
1704    #include <stdlib.h>
1705    #include <stdio.h>
1706    typedef void SigHandlerFn(int);
1707    static jmp_buf g_jmpenv;
1708    void sighandler(int sig){
1709        longjmp(g_jmpenv,sig);
1710    }
1711    void testsigint(){
1712        /* fprintf(stderr,"Raising SIGINT\n"); */
1713        raise(SIGINT);
1714    }
1715    int main(void){
1716        SigHandlerFn *last,*saved;
1717        saved = signal(SIGINT,&sighandler);
1718        if(saved!=SIG_DFL){
1719            fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1720            exit(3);
1721        }
1722        switch(setjmp(g_jmpenv)){
1723            case 0:
1724                testsigint();
1725                fprintf(stderr,"Back from SIGINT\n");
1726                exit(1);
1727            case SIGINT:
1728                break;
1729            default:
1730                exit(2);
1731        };
1732        last = signal(SIGINT,SIG_DFL);
1733        if(last!=&sighandler){
1734            printf("1");
1735            exit(0);
1736        }
1737        printf("0");
1738        exit(0);
1739    }
1740    """
1741    
1742    def CheckSigReset(context):
1743        context.Message("Checking signal handler reset... ")
1744        (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1745        if not is_ok:
1746            context.Result("ERROR")
1747            return False
1748        if int(output)==1:
1749            context.Result("required");
1750            context.env['ASC_RESETNEEDED'] = True
1751        else:
1752            context.Result("not required");
1753            context.env['ASC_RESETNEEDED'] = False
1754        return is_ok
1755    
1756    #----------------
1757    # LyX on this system?
1758    
1759    def CheckLyx(context):
1760        context.Message("Checking for LyX... ")
1761        r = context.env.WhereIs("lyx")
1762        if r:
1763            context.Result(r)
1764        else:
1765            context.Result(0)
1766        return r
1767    
1768    #----------------
1769    # Latex2HTML on this system?
1770    
1771    def CheckLatex2HTML(context):
1772        context.Message("Checking for latex2html...")
1773        if context.env.WhereIs("latex2html"):
1774            r = True
1775        else:
1776            r = False
1777        context.Result(r)
1778        return r
1779    
1780    #----------------
1781  # GCC Version sniffing  # GCC Version sniffing
1782    
1783  # TODO FIXME  # TODO FIXME
# Line 885  gcc_version4 = False Line 1789  gcc_version4 = False
1789    
1790  conf = Configure(env  conf = Configure(env
1791      , custom_tests = {      , custom_tests = {
1792          'CheckMath' : CheckMath          'CheckCC' : CheckCC
1793            , 'CheckCXX' : CheckCXX
1794            , 'CheckMath' : CheckMath
1795          , 'CheckSwigVersion' : CheckSwigVersion          , 'CheckSwigVersion' : CheckSwigVersion
1796            , 'CheckPythonLib' : CheckPythonLib
1797          , 'CheckCUnit' : CheckCUnit          , 'CheckCUnit' : CheckCUnit
1798            , 'CheckDMalloc' : CheckDMalloc
1799            , 'CheckLyx' : CheckLyx
1800            , 'CheckLatex2HTML' : CheckLatex2HTML
1801            , 'CheckMFGraph' : CheckMFGraph
1802            , 'CheckUFSparse' : CheckUFSparse
1803          , 'CheckTcl' : CheckTcl          , 'CheckTcl' : CheckTcl
1804          , 'CheckTclVersion' : CheckTclVersion          , 'CheckTclVersion' : CheckTclVersion
1805          , 'CheckTk' : CheckTk          , 'CheckTk' : CheckTk
# Line 895  conf = Configure(env Line 1807  conf = Configure(env
1807          , 'CheckGcc' : CheckGcc          , 'CheckGcc' : CheckGcc
1808          , 'CheckGccVisibility' : CheckGccVisibility          , 'CheckGccVisibility' : CheckGccVisibility
1809          , 'CheckYacc' : CheckYacc          , 'CheckYacc' : CheckYacc
1810            , 'CheckLex' : CheckLex
1811          , 'CheckTkTable' : CheckTkTable          , 'CheckTkTable' : CheckTkTable
1812          , 'CheckX11' : CheckX11          , 'CheckX11' : CheckX11
1813          , 'CheckIDA' : CheckIDA          , 'CheckIDA' : CheckIDA
1814            , 'CheckSUNDIALS' : CheckSUNDIALS
1815            , 'CheckCONOPT' : CheckCONOPT
1816            , 'CheckIPOPT' : CheckIPOPT
1817            , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1818            , 'CheckFPE' : CheckFPE
1819            , 'CheckSIGINT' : CheckSIGINT
1820            , 'CheckSigReset' : CheckSigReset
1821  #       , 'CheckIsNan' : CheckIsNan  #       , 'CheckIsNan' : CheckIsNan
1822  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig
1823      }      }
1824  #   , config_h = "config.h"  #   , config_h = "config.h"
1825  )  )
1826    
1827    def sconsversioncheck():
1828    
1829    #   uncomment the following line to skip the version check:
1830    #   return 1
1831    
1832        import SCons
1833        v = SCons.__version__.split(".")
1834        if v[0] != '0':
1835            return 0
1836        if int(v[1]) >= 97:
1837            return 1
1838        if v[1] != '96':
1839            return 0
1840        micro = int(v[2])
1841        if micro == 92 or micro == 93 or micro == 96:
1842            return 1;
1843        return 0
1844    
1845    if not sconsversioncheck():
1846        print "Scons version is not OK. Please try version 0.96.92 or 0.96.93,"
1847        print "or consult the developers in the case of newer versions. Modify"
1848        print "the function 'sconsversioncheck' in the file SConstruct if you"
1849        print "want to *force* SCons to continue."
1850        Exit(1)
1851    
1852    # check C compiler
1853    
1854    if not conf.CheckCC():
1855        print "Failed to build simple test file with your C compiler."
1856        print "Check your compiler is installed and running correctly."
1857        Exit(1)
1858    
1859    if not conf.CheckCXX():
1860        print "Failed to build simple test file with your C++ compiler."
1861        print "Check your compiler is installed and running correctly."
1862        Exit(1)
1863    
1864    # stdio -- just to check that compiler is behaving
1865    
1866    if not conf.CheckHeader('stdio.h'):
1867        print "CPPPATH =",env.get('CPPPATH')
1868        print "Did not find 'stdio.h'! Check your compiler configuration."
1869        print ""
1870        print "You environment is printed here:"
1871        for k,v in os.environ.iteritems():
1872            print "%-30s%s" % ("%s :" % k, v)
1873        Exit(1)
1874    
1875    if not conf.CheckFunc('snprintf'):
1876        print "Didn't find snprintf";
1877        exit(1)
1878    
1879  # Math library  # Math library
1880    
1881  if need_libm:  conf.env['HAVE_IEEE']=True
1882      if not conf.CheckMath():  
1883          print 'Did not find math library, exiting!'  if need_libm and not conf.CheckMath():
1884          Exit(1)      conf.env['HAVE_IEEE']=False
1885      #pass      print 'Did not find math library, exiting!'
1886        Exit(1)
1887    
1888  # Where is 'isnan'?  # Where is 'isnan'?
1889    
1890  if not conf.CheckFunc('isnan'):  if not conf.CheckFunc('isnan') and not conf.CheckFunc('_isnan'):
1891      print "Didn't find isnan"      print "Didn't find isnan"
1892  #   Exit(1)  #   Exit(1)
1893    
# Line 927  if conf.CheckGcc(): Line 1899  if conf.CheckGcc():
1899          conf.env['HAVE_GCCVISIBILITY']=True;          conf.env['HAVE_GCCVISIBILITY']=True;
1900          conf.env.Append(CCFLAGS=['-fvisibility=hidden'])          conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
1901          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
1902        conf.env.Append(CCFLAGS=['-Wall'])
1903    
1904  # YACC  # Catching SIGINT
1905    
1906  if not conf.CheckYacc():  if env['WITH_SIGNALS']:
1907      print "YACC NOT FOUND OR NOT WORKING"      if not conf.CheckSIGINT():
1908            with_signals = False
1909            without_signals_reason = "SIGINT uncatchable"
1910    
1911    # Catching SIGFPE
1912    
1913    if conf.CheckFPE():
1914        conf.env['HAVE_C99FPE']=True
1915  else:  else:
1916        conf.env['HAVE_C99FPE']=False
1917    
1918    # Checking for signal reset requirement
1919    
1920    if not conf.CheckSigReset():
1921        print "Unable to determine if signal reset is required"
1922        Exit(1)
1923    
1924    # YACC
1925    
1926    if conf.CheckYacc():
1927      conf.env['HAVE_YACC']=True      conf.env['HAVE_YACC']=True
1928    
1929  conf.env['HAVE_LEX']=True  if conf.CheckLex():
1930        conf.env['HAVE_LEX']=True
1931    
1932  # Tcl/Tk  # Tcl/Tk
1933    
# Line 970  if env['STATIC_TCLTK']: Line 1962  if env['STATIC_TCLTK']:
1962  # Python... obviously we're already running python, so we just need to  # Python... obviously we're already running python, so we just need to
1963  # check that we can link to the python library OK:  # check that we can link to the python library OK:
1964    
1965  if platform.system()=="Windows":  if not conf.CheckPythonLib():
1966      python_lib='python24'      without_python_reason = 'libpython2.x not found or not linkable'
1967  else:      with_python = False
1968      python_lib='python2.4'      env['WITH_PYTHON']=False
1969    
1970  # SWIG version  # SWIG version
1971    
1972  if not conf.CheckSwigVersion():  if with_python and not conf.CheckSwigVersion():
1973      without_python_reason = 'SWIG >= 1.3.24 is required'      without_python_reason = 'SWIG >= 1.3.24 is required'
1974      with_python = False      with_python = False
1975        env['WITH_PYTHON']=False
1976    
1977  # CUnit  # CUnit
1978    
# Line 989  if with_cunit: Line 1982  if with_cunit:
1982          with_cunit = False          with_cunit = False
1983          #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')          #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
1984    
1985    # DMALLOC
1986    
1987    if with_dmalloc:
1988        if not conf.CheckDMalloc():
1989            without_dmalloc_reason = 'dmalloc not found'
1990            with_dmalloc = False
1991    
1992    # MFGRAPH
1993    
1994    if with_mfgraph:
1995        if not conf.CheckMFGraph():
1996            without_mfgraph_reason = 'mfgraph not found'
1997            with_mfgraph = False
1998            env['WITH_MFGRAPH'] = False
1999    
2000    # UFSPARSE
2001    
2002    if with_ufsparse:
2003        if not conf.CheckUFSparse():
2004            without_ufsparse_reason = 'mfgraph not found'
2005            with_ufsparse = False
2006            env['WITH_UFSPARSE'] = False
2007    
2008  # IDA  # IDA
2009    
2010  if not with_ida:  if not with_ida:
2011      without_ida_reason = "Not selected (see config option WITH_SOLVERS)"      without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
2012    elif not conf.CheckSUNDIALS():
2013        with_ida = False
2014        without_ida_reason = "SUNDIALS not found, or bad version"
2015  elif not conf.CheckIDA():  elif not conf.CheckIDA():
2016      with_ida = False      with_ida = False
2017      without_ida_reason = "IDA not found"      without_ida_reason = "Unable to compile/link against SUNDIALS/IDA"
2018    
2019    # CONOPT
2020    
2021    if not with_conopt:
2022        without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
2023    elif not conf.CheckCONOPT():
2024        if conf.env.get('CONOPT_LINKED'):
2025            conf.env['CONOPT_LINKED'] = False
2026        # we no longer require CONOPT at buildtime in order to build support for it
2027        #with_conopt = False
2028        #without_conpt_reason = "CONOPT not found"
2029    
2030    # IPOPT
2031    
2032    if not with_ipopt:
2033        without_ipopt_reason = "Not selected (see config option WITH_SOLVERS)"
2034    elif not conf.CheckIPOPT():
2035        with_ipopt = False
2036        without_ipopt_reason = "IPOPT not found"
2037    
2038  # BLAS  # BLAS
2039    
# Line 1020  else: Line 2058  else:
2058    
2059  if need_fortran:  if need_fortran:
2060      conf.env.Tool('fortran')      conf.env.Tool('fortran')
2061      detect_fortran = conf.env.Detect(['g77','f77','gfortran'])      detect_fortran = conf.env.Detect(['gfortran','g77'])
2062      if detect_fortran:      if detect_fortran:
2063          # For some reason, g77 doesn't get detected properly on MinGW          # For some reason, g77 doesn't get detected properly on MinGW
2064          if not env.has_key('F77') and not env.has_key('FORTRAN'):          if not env.has_key('F77') and not env.has_key('FORTRAN'):
2065                print "Fixing detection of F77 on MinGW...(?)"
2066              conf.env.Replace(F77=detect_fortran)              conf.env.Replace(F77=detect_fortran)
2067              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
2068              conf.env.Replace(F77FLAGS='')              conf.env.Replace(F77FLAGS='')
# Line 1036  if need_fortran: Line 2075  if need_fortran:
2075                  , src_suffix='.f'                  , src_suffix='.f'
2076              )              )
2077              conf.env.Append(BUILDERS={'Fortran':fortran_builder})              conf.env.Append(BUILDERS={'Fortran':fortran_builder})
2078            if platform.system()=="Linux":
2079                conf.env.Append(SHFORTRANFLAGS=['-fPIC'])
2080      else:      else:
2081          with_lsode=False;          with_lsode=False;
2082          without_lsode_reason="FORTRAN-77 required but not found"          without_lsode_reason="FORTRAN-77 required but not found"
# Line 1047  if need_fortran: Line 2088  if need_fortran:
2088    
2089  if need_fortran:  if need_fortran:
2090      if platform.system()=="Windows":      if platform.system()=="Windows":
2091          conf.env.Append(LIBPATH='c:\mingw\lib')          pass
2092            #conf.env.Append(LIBPATH='c:\mingw\lib')
2093    
2094    # scrollkeeper
2095    
2096    if with_scrollkeeper:
2097        if not conf.CheckScrollkeeperConfig():
2098            with_scrollkeeper=False
2099            without_scrollkeeper_reason="unable to detect scrollkeeper-config"
2100    
2101    # lyx
2102    
2103    if with_doc_build:
2104        if not conf.CheckLyx():
2105            with_doc_build = False
2106            without_doc_build_reason="unable to locate lyx"
2107    
2108        with_latext2html = conf.CheckLatex2HTML()
2109    
2110  # TODO: -D_HPUX_SOURCE is needed  # TODO: -D_HPUX_SOURCE is needed
2111    
# Line 1057  if need_fortran: Line 2114  if need_fortran:
2114  # TODO: detect if dynamic libraries are possible or not  # TODO: detect if dynamic libraries are possible or not
2115    
2116  if platform.system()=="Windows" and env.has_key('MSVS'):  if platform.system()=="Windows" and env.has_key('MSVS'):
2117      if not conf.CheckHeader('windows.h') and env['PACKAGE_LINKING']=='DYNAMIC_PACKAGES':      _found_windows_h = conf.CheckHeader('Windows.h')
2118          print "Reverting to STATIC_PACKAGES since windows.h is not available. Probably you "\  
2119              +"need to install the Microsoft Windows Server 2003 Platform SDK, or similar."      if not _found_windows_h:
2120          env['PACKAGE_LINKING']='STATIC_PACKAGES'          print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
2121                    Exit(1)
2122    
2123      if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):      if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):
2124          with_python = 0;          with_python = 0;
2125          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."
2126    
 conf.env.Append(CPPDEFINES=env['PACKAGE_LINKING'])  
   
2127  conf.Finish()  conf.Finish()
2128    
 env.Append(PYTHON_LIBPATH=[distutils.sysconfig.PREFIX+"/libs"])  
 env.Append(PYTHON_LIB=[python_lib])  
 env.Append(PYTHON_CPPPATH=[distutils.sysconfig.get_python_inc()])  
   
2129  #---------------------------------------  #---------------------------------------
2130  # SUBSTITUTION DICTIONARY for .in files  # SUBSTITUTION DICTIONARY for .in files
2131    
# Line 1081  release = env.get('RELEASE') Line 2133  release = env.get('RELEASE')
2133  if release=="0.":  if release=="0.":
2134      release="0"      release="0"
2135    
2136    #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
2137    
2138  subst_dict = {  subst_dict = {
2139      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
2140        ,'@DEFAULT_ASCENDSOLVERS@':env['DEFAULT_ASCENDSOLVERS']
2141      , '@GLADE_FILE@':'ascend.glade'      , '@GLADE_FILE@':'ascend.glade'
2142      , '@HELP_ROOT@':''      , '@HELP_ROOT@':''
2143      , '@ICON_EXTENSION@':icon_extension      , '@ICON_EXTENSION@':icon_extension
# Line 1090  subst_dict = { Line 2145  subst_dict = {
2145      , '@INSTALL_BIN@':env['INSTALL_BIN']      , '@INSTALL_BIN@':env['INSTALL_BIN']
2146      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
2147      , '@INSTALL_LIB@':env['INSTALL_LIB']      , '@INSTALL_LIB@':env['INSTALL_LIB']
2148        , '@INSTALL_MODELS@':env['INSTALL_MODELS']
2149        , '@INSTALL_SOLVERS@':env['INSTALL_SOLVERS']
2150      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
2151      , '@VERSION@':version      , '@VERSION@':version
2152      , '@RELEASE@':release      , '@RELEASE@':release
2153      , '@DISTTAR_NAME@':env['DISTTAR_NAME']      , '@DISTTAR_NAME@':env['DISTTAR_NAME']
2154      , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'      , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'
2155      , '@ASC_SHLIBSUFFIX@':env['SHLIBSUFFIX']      , '@SHLIBSUFFIX@':env['SHLIBSUFFIX']
2156      , '@ASC_SHLIBPREFIX@':env['SHLIBPREFIX']      , '@SHLIBPREFIX@':env['SHLIBPREFIX']
2157      , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'      , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
2158      , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir      , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
2159      , '@PYTHON@' : python_exe      , '@PYTHON@' : python_exe
2160        , '@PYVERSION@' : pyversion
2161        , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
2162        , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
2163        , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_DLPATH"))
2164        , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
2165        , '@WITH_SOLVERS@':",".join(env.get('WITH_SOLVERS'))
2166  }  }
2167    
2168  if env.get('WITH_LOCAL_HELP'):  if env.get('WITH_DOC'):
2169      print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']      print "WITH_DOC:",env['WITH_DOC']
2170      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']      subst_dict['@HELP_ROOT@']=env['HELP_ROOT']
2171    
2172  # bool options...  # bool options...
2173  for k,v in {  for k,v in {
2174          'ABSOLUTE_PATHS' : 'ASC_ABSOLUTE_PATHS'          'ASC_WITH_IDA':with_ida
2175          ,'WITH_XTERM_COLORS' : 'ASC_XTERM_COLORS'          ,'ASC_WITH_DMALLOC':with_dmalloc
2176          ,'MALLOC_DEBUG' : 'MALLOC_DEBUG'          ,'ASC_WITH_MFGRAPH':with_mfgraph
2177  }.iteritems():          ,'ASC_WITH_UFSPARSE':with_ufsparse
2178      if env.get(k):          ,'ASC_WITH_CONOPT':with_conopt
2179  #       subst_dict['@'+v+'@']='1'          ,'ASC_LINKED_CONOPT':env.get('CONOPT_LINKED')
2180          subst_dict["/\\* #define "+v+' @'+v+"@ \\*/"]='# define '+v+' 1 '          ,'ASC_WITH_IPOPT':with_ipopt
2181            ,'ASC_WITH_LSODE':with_lsode
2182  if with_ida:          ,'ASC_WITH_MMIO':with_mmio
2183      subst_dict["/\\* #define ASC_WITH_IDA @ASC_WITH_IDA@ \\*/"]='#define ASC_WITH_IDA '          ,'ASC_SIGNAL_TRAPS':with_signals
2184            ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
2185  if with_lsode:          ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
2186      subst_dict["/\\* #define ASC_WITH_LSODE @ASC_WITH_LSODE@ \\*/"]='#define ASC_WITH_LSODE '          ,'HAVE_IEEE':env.get('HAVE_IEEE')
2187            ,'ASC_ABSOLUTE_PATHS':env.get('ABSOLUTE_PATHS')
2188            ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
2189            ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
2190            }.iteritems():
2191            
2192        if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
2193    
2194  if with_python:  if with_python:
2195      subst_dict['@ASCXX_USE_PYTHON@']="1"      subst_dict['@ASCXX_USE_PYTHON@']="1"
2196      env['WITH_PYTHON']=1;      env['WITH_PYTHON']=1;
2197    
2198    if with_latex2html:
2199        env['WITH_LATEX2HTML']=1
2200    
2201  if env.has_key('HAVE_GCCVISIBILITY'):  if env.has_key('HAVE_GCCVISIBILITY'):
2202      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
2203    
2204  env.Append(SUBST_DICT=subst_dict)  env.Append(SUBST_DICT=subst_dict)
2205    
2206    #for k,v in subst_dict.iteritems():
2207    #   print "%-50s%s" % ("'%s'"%k,v)
2208    
2209    # REMOVED: long command-line support on Win2k
2210    
2211  #------------------------------------------------------  #------------------------------------------------------
2212  # RECIPE: SWIG scanner  # RECIPE: SWIG scanner
2213    
# Line 1146  SWIGScanner = SCons.Scanner.ClassicCPP( Line 2223  SWIGScanner = SCons.Scanner.ClassicCPP(
2223  env.Append(SCANNERS=[SWIGScanner])  env.Append(SCANNERS=[SWIGScanner])
2224    
2225  #------------------------------------------------------  #------------------------------------------------------
 # 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)  
   
 #------------------------------------------------------  
2226  # Recipe for 'CHMOD' ACTION        # Recipe for 'CHMOD' ACTION      
2227            
2228  import SCons      import SCons    
# Line 1244  SConsEnvironment.InstallShared = lambda Line 2246  SConsEnvironment.InstallShared = lambda
2246  # BUILD...  # BUILD...
2247    
2248  # so that #include <modulename/headername.h> works across all modules...  # so that #include <modulename/headername.h> works across all modules...
2249  env.Append(CPPPATH=['#base/generic'])  env.AppendUnique(CPPPATH=['#base/generic'])
   
 if gcc_version4:  
     env.Append(CCFLAGS=['-fvisibility=hidden'])  
2250    
2251  if env['DEBUG']:  if env['DEBUG']:
2252      env.Append(CCFLAGS=['-g'])      env.Append(CCFLAGS=['-g'])
2253        env.Append(LINKFLAGS=['-g'])
2254    
2255  if env['GCOV']:  if env['GCOV']:
2256      env.Append(      env.Append(
# Line 1262  if env['GCOV']: Line 2262  if env['GCOV']:
2262  if with_ida:  if with_ida:
2263      env.Append(WITH_IDA=1)      env.Append(WITH_IDA=1)
2264    
2265    if with_conopt:
2266        env.Append(WITH_CONOPT=1)
2267    
2268    if with_ipopt:
2269        env.Append(WITH_IPOPT=1)
2270    
2271  #-------------  #-------------
2272  # TCL/TK GUI  # TCL/TK GUI
2273    
2274  if with_tcltk:  if with_tcltk:
2275      env.SConscript(['tcltk/generic/interface/SConscript'],'env')      env.SConscript(['tcltk/generic/interface/SConscript'],'env')
2276  else:  else:
2277      print "Skipping... Tcl/Tk GUI isn't being built:",without_tcltk_reason      print "Skipping... Tcl/Tk bindings aren't being built:",without_tcltk_reason
2278    
2279  #-------------  #-------------
2280  # PYTHON INTERFACE  # PYTHON INTERFACE
# Line 1276  else: Line 2282  else:
2282  if with_python:  if with_python:
2283      env.SConscript(['pygtk/SConscript'],'env')      env.SConscript(['pygtk/SConscript'],'env')
2284  else:  else:
2285      print "Skipping... Python GUI isn't being built:",without_python_reason      print "Skipping... Python bindings aren't being built:",without_python_reason
2286    
2287  #------------  #------------
2288  # BASE/GENERIC SUBDIRECTORIES  # BASE/GENERIC SUBDIRECTORIES
2289    
2290  libascend_env = env.Copy()  libascend_env = env.Copy()
2291    
2292  dirs = ['general','utilities','compiler','solver','packages']  dirs = ['general','utilities','compiler','system','solver','integrator','packages','linear']
2293    
2294  srcs = []  srcs = []
2295  for d in dirs:  for d in dirs:
# Line 1293  for d in dirs: Line 2299  for d in dirs:
2299  #-------------  #-------------
2300  # IMPORTED CODE: LSODE, BLAS, etc  # IMPORTED CODE: LSODE, BLAS, etc
2301    
2302  if with_lsode:  #if with_lsode:
2303      srcs += env.SConscript(['lsod/SConscript'],'env')  #   srcs += env.SConscript(['lsod/SConscript'],'env')
2304      srcs += env.SConscript(['linpack/SConscript'],'env')  #   srcs += env.SConscript(['linpack/SConscript'],'env')
2305  else:  #else:
2306      print "Skipping... LSODE won't be built:", without_lsode_reason  #   print "Skipping... LSODE won't be built:", without_lsode_reason
2307    
2308  if with_local_blas:  if with_local_blas:
2309      srcs += env.SConscript(['blas/SConscript'],'env')      env['blasobjs'] = env.SConscript(['blas/SConscript'],'env')
2310  else:  else:
2311        env['blasobjs'] = []
2312      print "Skipping... BLAS won't be built:", without_local_blas_reason      print "Skipping... BLAS won't be built:", without_local_blas_reason
2313    
2314  if not with_ida:  if not with_ida:
2315      print "Skipping... IDA won't be built:", without_ida_reason      print "Skipping... IDA won't be built:", without_ida_reason
2316    
2317    if with_mmio:
2318        srcs += env.SConscript(['mmio/SConscript'],'env')
2319    else:
2320        print "Skipping... MMIO export won't be built:", without_mmio_reason
2321  #-------------  #-------------
2322  # LIBASCEND -- all base/generic functionality  # LIBASCEND -- all base/generic functionality
2323    
2324    if with_dmalloc:
2325        libascend_env.Append(LIBS=['dmalloc'])
2326    
2327    if with_ufsparse:
2328        libascend_env.Append(LIBS=['cxsparse'])
2329    
2330  libascend = libascend_env.SharedLibrary('ascend',srcs)  libascend = libascend_env.SharedLibrary('ascend',srcs)
2331    
2332    # for use in declaring dependent shared libraries in SConscript files (eg solvers/*/SConscript)
2333    env['libascend'] = libascend
2334    
2335  env.Alias('libascend',libascend)  env.Alias('libascend',libascend)
2336    
2337  #-------------  #-------------
2338  # UNIT TESTS  # UNIT TESTS (C CODE)
2339    
2340  if with_cunit:  if with_cunit:
2341      testdirs = ['general','solver','utilities']      testdirs = ['general','solver','utilities','linear']
2342      testsrcs = []      testsrcs = []
2343      for testdir in testdirs:      for testdir in testdirs:
2344          path = 'base/generic/'+testdir+'/test/'          path = 'base/generic/'+testdir+'/test/'
# Line 1335  if with_cunit: Line 2355  if with_cunit:
2355  else:  else:
2356      print "Skipping... CUnit tests aren't being built:",without_cunit_reason      print "Skipping... CUnit tests aren't being built:",without_cunit_reason
2357    
2358    #-------------
2359    # EXTERNAL SOLVERS
2360    
2361    env['extfns']=[]
2362    
2363    env.SConscript(['solvers/SConscript'],'env')
2364    
2365    #-------------
2366    # EXTERNAL FUNCTIONS
2367    
2368    modeldirs = env.SConscript(['models/SConscript'],'env')
2369    
2370    if not with_extfns:
2371        print "Skipping... External modules aren't being built:",without_extfns_reason
2372    
2373    env.Alias('extfns',env['extfns'])
2374    
2375  #------------------------------------------------------  #------------------------------------------------------
2376  # CREATE ASCEND-CONFIG scriptlet  # CREATE ASCEND-CONFIG scriptlet
2377    
# Line 1344  ascendconfig = env.SubstInFile('ascend-c Line 2381  ascendconfig = env.SubstInFile('ascend-c
2381  # INSTALLATION  # INSTALLATION
2382    
2383  if env.get('CAN_INSTALL'):  if env.get('CAN_INSTALL'):
     # the models directory only needs to be processed for installation, no other processing required.  
     env.SConscript(['models/SConscript'],'env')  
2384    
2385      dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB']      dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE','INSTALL_DOC']
2386      install_dirs = [env['INSTALL_ROOT']+env[d] for d in dirs]      install_dirs = [Dir(env.subst("$INSTALL_ROOT$"+d)) for d in dirs]
2387        install_dirs += modeldirs + [Dir(env.subst("$INSTALL_ROOT$INSTALL_SOLVERS"))]
2388    
2389      # TODO: add install options      # TODO: add install options
2390      env.Alias('install',install_dirs)      env.Alias('install',install_dirs)
2391    
2392      env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_LIB'],libascend)      env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_LIB")),libascend)
2393    
2394      env.InstallProgram(env['INSTALL_ROOT']+env['INSTALL_BIN'],ascendconfig)      env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendconfig)
2395    
2396  #------------------------------------------------------  #------------------------------------------------------
2397  # WINDOWS INSTALLER  # WINDOWS INSTALLER
2398  # For the windows installer, please see pygtk/SConscript  # For the windows installer, please see pygtk/SConscript
2399    
2400    if not env.get('NSIS'):
2401        with_installer = False
2402        without_installer_reason = "NSIS not found"
2403    
2404  if with_installer:  if with_installer:
2405      pass      env.Append(NSISDEFINES={
2406            'OUTFILE':"#dist/"+env['WIN_INSTALLER_NAME']
2407            ,"VERSION":version
2408            ,'PYVERSION':pyversion
2409        })
2410        installer = env.Installer('installer.nsi')
2411        Depends(installer,["pygtk","tcltk","ascend.dll","models","ascend-config"])
2412        env.Alias('installer',installer)
2413  else:  else:
2414      print "Skipping... Windows installer isn't being built:",without_installer_reason      print "Skipping... Windows installer isn't being built:",without_installer_reason
2415    
2416    
2417  #------------------------------------------------------  #------------------------------------------------------
2418  # PROJECT FILE for MSVC  # PROJECT FILE for MSVC
2419    
# Line 1378  if platform.system()=="Linux": Line 2426  if platform.system()=="Linux":
2426      env.SubstInFile('ascend.spec.in')      env.SubstInFile('ascend.spec.in')
2427    
2428  #------------------------------------------------------  #------------------------------------------------------
2429    # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
2430    
2431    #if with_scrollkeeper:
2432    #   #env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
2433    #   #env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
2434    
2435    #------------------------------------------------------
2436  # DISTRIBUTION TAR FILE  # DISTRIBUTION TAR FILE
2437    
2438  env['DISTTAR_FORMAT']='bz2'  env['DISTTAR_FORMAT']='bz2'
2439  env.Append(  env.Append(
2440      DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.cc','.cache','.pyc','.cvsignore','.dblite','.log','.pl']      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']
2441      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist']      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist','debian']
2442  )  )
2443    
2444  tar = env.DistTar("dist/"+env['DISTTAR_NAME']  tar = env.DistTar("dist/"+env['DISTTAR_NAME']
# Line 1391  tar = env.DistTar("dist/"+env['DISTTAR_N Line 2446  tar = env.DistTar("dist/"+env['DISTTAR_N
2446  )  )
2447    
2448  env.Depends(tar,'ascend.spec')  env.Depends(tar,'ascend.spec')
2449    env.Depends(tar,'#doc/book.pdf')
2450    
2451    Alias('dist',tar)
2452    
2453    #------------------------------------------------------
2454    # DOCUMENTATION
2455    
2456    
2457    if not with_doc_build:
2458        print "Skipping... Documentation isn't being built:",without_doc_build_reason
2459    
2460    #user's manual
2461    env.SConscript('doc/SConscript',['env'])
2462    
2463    # doxygen documentation
2464    env.SConscript('base/doc/SConscript',['env'])
2465    
2466  #------------------------------------------------------  #------------------------------------------------------
2467  # RPM BUILD  # RPM BUILD
2468    
2469  #if platform.system()=="Linux":  # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
2470  #   pass  # (check * for the version number used to create the tarball)
2471    
2472  #------------------------------------------------------  #------------------------------------------------------
2473  # DEFAULT TARGETS  # DEFAULT TARGETS
2474    
2475  default_targets =['libascend']  default_targets =['libascend','solvers']
2476  if with_tcltk:  if with_tcltk:
2477      default_targets.append('tcltk')      default_targets.append('tcltk')
2478  if with_python:  if with_python:
2479      default_targets.append('pygtk')      default_targets.append('pygtk')
2480  if with_installer:  if with_installer:
2481      default_targets.append('installer')      default_targets.append('installer')
2482    if with_extfns:
2483        default_targets.append('extfns')
2484    if with_doc_build:
2485        default_targets.append('doc')
2486    
2487  env.Default(default_targets)  env.Default(default_targets)
2488    
2489  print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])  print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
2490    
2491  # vim: set syntax=python:  # vim: set syntax=python:
   

Legend:
Removed from v.705  
changed lines
  Added in v.1566

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