/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 566 by johnpye, Fri May 5 09:22:01 2006 UTC revision 953 by johnpye, Thu Dec 7 14:47:15 2006 UTC
# Line 1  Line 1 
1  import os, commands, platform, distutils.sysconfig, os.path  import os, commands, platform, distutils.sysconfig, os.path, re
2    
3  version = "0.9.5.90"  version = "0.9.5.103"
4    
5  #------------------------------------------------------  #------------------------------------------------------
6  # OPTIONS  # OPTIONS
# Line 12  opts = Options(['options.cache', 'config Line 12  opts = Options(['options.cache', 'config
12  #print "PLATFORM = ",platform.system()  #print "PLATFORM = ",platform.system()
13    
14  if platform.system()=="Windows":  if platform.system()=="Windows":
15      default_tcl_lib = "tcl83"      default_tcl_lib = "tcl84"
16      default_tk_lib = "tk83"      default_tk_lib = "tk84"
17      default_tktable_lib = "Tktable28"      default_tktable_lib = "Tktable28"
18      default_install_assets = "glade/"      default_install_assets = "glade/"
19      icon_extension = '.png'      icon_extension = '.png'
20      default_tcl = "c:\\Tcl"      default_tcl = "c:\\Tcl"
21      default_tcl_libpath = "$TCL\\bin"      if os.environ.get('MSYSTEM')=="MINGW32":
22            default_tcl_libpath="$TCL\\bin"
23        else:
24            default_tcl_libpath="$TCL\\lib"
25        default_rel_distdir = '.'
26        default_absolute_paths = False
27        
28        default_ida_prefix = "c:\\MinGW"
29        if not os.path.exists(default_ida_prefix):
30            default_ida_prefix = None
31    
32        default_conopt_prefix = "c:\\Program Files\\CONOPT"
33        default_conopt_libpath="$CONOPT_PREFIX"
34        default_conopt_cpppath="$CONOPT_PREFIX"
35        default_conopt_lib="conopt3"
36        default_conopt_envvar="CONOPT_PATH"
37    
38        default_prefix="c:\\MinGW"
39        default_libpath="$DEFAULT_PREFIX\\lib"
40        default_cpppath="$DEFAULT_PREFIX\\include"
41        
42        if not os.path.exists(default_conopt_prefix):
43            default_conopt_prefix = None
44            
45        need_libm = False
46        python_exe = "c:\\Python24\\python.exe"
47        default_with_scrollkeeper=False
48  else:  else:
49      default_tcl_lib = "tcl8.3"      default_tcl_lib = "tcl8.4"
50      default_tk_lib = "tk8.3"      default_tk_lib = "tk8.4"
51      default_tktable_lib = "Tktable2.8"      default_tktable_lib = "Tktable2.8"
52      default_install_assets = "$INSTALL_DATA/ascend/glade/"      default_install_assets = "$INSTALL_ASCDATA/glade/"
53      icon_extension = '.svg'      icon_extension = '.svg'
54      default_tcl = os.path.expanduser("~/activetcl")      default_tcl = '/usr'
55      default_tcl_libpath = "$TCL/lib"          default_tcl_libpath = "$TCL/lib"    
56        default_rel_distdir = '../share/ascend'
57        default_absolute_paths = True
58        default_ida_prefix="/usr/local"
59        default_conopt_prefix="/usr"
60        default_conopt_libpath="$CONOPT_PREFIX/lib"
61        default_conopt_cpppath="$CONOPT_PREFIX/include"
62        default_conopt_lib="consub3"
63        default_conopt_envvar="CONOPT_PATH"
64    
65        default_prefix="/usr"
66        default_libpath="$DEFAULT_PREFIX/lib"
67        default_cpppath="$DEFAULT_PREFIX/include"
68    
69        need_libm = True
70      if not os.path.isdir(default_tcl):      if not os.path.isdir(default_tcl):
71          default_tcl = '/usr'          default_tcl = '/usr'
72        python_exe = distutils.sysconfig.EXEC_PREFIX+"/bin/python"
73        default_with_scrollkeeper=False
74    
75  opts.Add(  opts.Add(
76      'CC'      'CC'
# Line 43  opts.Add( Line 84  opts.Add(
84      ,None      ,None
85  )  )
86    
87    opts.Add(BoolOption(
88        'GCOV'
89        , 'Whether to enable coverage testing in object code'
90        , False
91    ))
92    
93  # Package linking option  # Package linking option
94  opts.Add(EnumOption(  opts.Add(EnumOption(
95      'PACKAGE_LINKING'      'PACKAGE_LINKING'
# Line 60  opts.Add(BoolOption( Line 107  opts.Add(BoolOption(
107  # You can turn off building of Tcl/Tk interface  # You can turn off building of Tcl/Tk interface
108  opts.Add(BoolOption(  opts.Add(BoolOption(
109      'WITH_TCLTK'      'WITH_TCLTK'
110      ,"Set to True if you don't want to build the original Tcl/Tk GUI."      ,"Set to False if you don't want to build the original Tcl/Tk GUI."
111      , True      , True
112  ))  ))
113    
114  # You can turn off the building of the Python interface  # You can turn off the building of the Python interface
115  opts.Add(BoolOption(  opts.Add(BoolOption(
116      'WITH_PYTHON'      'WITH_PYTHON'
117      ,"Set to True if you don't want to build Python wrappers."      ,"Set to False if you don't want to build Python wrappers."
118      , True      , True
119  ))  ))
120    
# Line 76  opts.Add(ListOption( Line 123  opts.Add(ListOption(
123      'WITH_SOLVERS'      'WITH_SOLVERS'
124      ,"List of the solvers you want to build. The default is the minimum that"        ,"List of the solvers you want to build. The default is the minimum that"  
125          +" works."          +" works."
126      ,["QRSLV","CMSLV"]      ,["QRSLV","CMSLV","LSOD","IDA","CONOPT","LRSLV"]
127      ,['QRSLV','MPS','SLV','OPTSQP'      ,['QRSLV','MPS','SLV','OPTSQP'
128          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
129          ,'LSOD','OPTSQP'          ,'LSOD','OPTSQP',"IDA"
130       ]       ]
131  ))  ))
132    
# Line 104  opts.Add( Line 151  opts.Add(
151      'DEFAULT_ASCENDLIBRARY'      'DEFAULT_ASCENDLIBRARY'
152      ,"Set the default value of the ASCENDLIBRARY -- the location where"      ,"Set the default value of the ASCENDLIBRARY -- the location where"
153          +" ASCEND will look for models when running ASCEND"          +" ASCEND will look for models when running ASCEND"
154      ,"$INSTALL_DATA/models"      ,"$INSTALL_ASCDATA/models"
155  )  )
156    
157  # Where is SWIG?  # Where is SWIG?
# Line 117  opts.Add( Line 164  opts.Add(
164    
165  # Build the test suite?  # Build the test suite?
166  opts.Add(BoolOption(  opts.Add(BoolOption(
167      'WITH_CUNIT_TESTS'      'WITH_CUNIT'
168      ,"Whether to build the CUnit tests. Default is off. If set to on,"      ,"You can disable CUnit tests with this option. This will basically stop"
169          +" you must have CUnit installed somewhere that SCons can"          +" SCons from parsing the SConscript files relating to the 'test'"
170          +" find it, or else use the CUNIT_* options to specify."          +" target, which just might make things marginally faster. Probably"
171      ,False          +" you can just ignore this option though. SCons will sniff for Cunit"
172            +" but build the tests only if you specify the 'test' target."
173        ,True
174    ))
175    
176    #----- default paths -----
177    opts.Add(PackageOption(
178        'DEFAULT_PREFIX'
179        ,"Where are most of the shared libraries located on your system?"
180        ,default_prefix
181    ))
182    
183    #------ cunit --------
184    # Where was CUNIT installed?
185    opts.Add(PackageOption(
186        'CUNIT_PREFIX'
187        ,"Where are your CUnit files?"
188        ,"$DEFAULT_PREFIX"
189  ))  ))
190    
191  # Where are the CUnit includes?  # Where are the CUnit includes?
192  opts.Add(PackageOption(  opts.Add(PackageOption(
193      'CUNIT_CPPPATH'      'CUNIT_CPPPATH'
194      ,"Where are your CUnit include files?"      ,"Where are your CUnit include files?"
195      ,'off'      ,"$CUNIT_PREFIX/include"
196  ))  ))
197    
198  # Where are the CUnit libraries?  # Where are the CUnit libraries?
199  opts.Add(PackageOption(  opts.Add(PackageOption(
200      'CUNIT_LIBPATH'      'CUNIT_LIBPATH'
201      ,"Where are your CUnit libraries?"      ,"Where are your CUnit libraries?"
202      ,'off'      ,"$CUNIT_PREFIX/lib"
203    ))
204    
205    #-------- ida -------
206    
207    opts.Add(PackageOption(
208        "IDA_PREFIX"
209        ,"Prefix for your IDA install (IDA ./configure --prefix)"
210        ,default_ida_prefix
211    ))
212    
213    opts.Add(
214        "IDA_LIB"
215        ,"Libraries linked to for IDA"
216        ,['sundials_nvecserial','sundials_ida','m']
217    )
218    
219    opts.Add(
220        'IDA_CPPPATH'
221        ,"Where is your ida.h?"
222        ,"$IDA_PREFIX/include"
223    )
224    
225    opts.Add(
226        'IDA_LIBPATH'
227        ,"Where are your SUNDIALS libraries installed?"
228        ,"$IDA_PREFIX/lib"
229    )
230    
231    # ----- conopt-----
232    
233    opts.Add(PackageOption(
234        "CONOPT_PREFIX"
235        ,"Prefix for your CONOPT install (CONOPT ./configure --prefix)"
236        ,default_conopt_prefix
237  ))  ))
238    
239    opts.Add(
240        "CONOPT_LIB"
241        ,"Library linked to for CONOPT"
242        ,default_conopt_lib
243    )
244    
245    opts.Add(
246        'CONOPT_CPPPATH'
247        ,"Where is your conopt.h?"
248        ,default_conopt_cpppath
249    )
250    
251    opts.Add(
252        'CONOPT_LIBPATH'
253        ,"Where is your CONOPT libraries installed?"
254        ,default_conopt_libpath
255    )
256    
257    opts.Add(
258        'CONOPT_ENVVAR'
259        ,"What environment variable should be used at runtime to override the default search location for CONOPT DLL/SO?"
260        ,default_conopt_envvar
261    )
262    
263    #-------- f2c ------
264    
265    opts.Add(
266        "F2C_LIB"
267        ,"F2C library (eg. g2c, gfortran, f2c)"
268        ,"g2c"
269    )
270    
271    opts.Add(PackageOption(
272        "F2C_LIBPATH"
273        ,"Directory containing F2C library (i.e. g2c, gfortran, f2c, etc.), if not already accessible"
274        ,"off"
275    ))
276    
277    #------- tcl/tk --------
278    
279  opts.Add(  opts.Add(
280      'TCL'      'TCL'
# Line 237  opts.Add( Line 374  opts.Add(
374      ,'X11'      ,'X11'
375  )  )
376    
377    #----- installed file locations (for 'scons install') -----
378    
379  opts.Add(  opts.Add(
380      'INSTALL_PREFIX'      'INSTALL_PREFIX'
381      ,'Root location for installed files'      ,'Root location for installed files'
# Line 251  opts.Add( Line 390  opts.Add(
390    
391  opts.Add(  opts.Add(
392      'INSTALL_LIB'      'INSTALL_LIB'
393      ,'Location to put binaries during installation'      ,'Location to put libraries during installation'
394      ,"$INSTALL_PREFIX/lib"      ,"$INSTALL_PREFIX/lib"
395  )  )
396    
397  opts.Add(  opts.Add(
398      'INSTALL_DATA'      'INSTALL_SHARE'
399      ,'Location to put data files during installation'      ,'Common shared-file location on this system'
400      ,"$INSTALL_PREFIX/share"      ,"$INSTALL_PREFIX/share"
401  )  )
402    
403  opts.Add(  opts.Add(
404        'INSTALL_DOC'
405        ,'Location to install documentation files'
406        ,"$INSTALL_SHARE/doc"
407    )
408    
409    opts.Add(
410        'INSTALL_ASCDATA'
411        ,"Location of ASCEND shared data (TK, python, models etc)"
412        ,"$INSTALL_SHARE/ascend"
413    )
414    
415    opts.Add(
416      'INSTALL_INCLUDE'      'INSTALL_INCLUDE'
417      ,'Location to put header files during installation'      ,'Location to put header files during installation'
418      ,"$INSTALL_PREFIX/include"      ,"$INSTALL_PREFIX/include"
419  )  )
420    
421    
422    opts.Add(
423        'INSTALL_ROOT'
424        ,'For use by RPM only: location of %{buildroot} during rpmbuild'
425        ,""
426    )
427    
428    #----------------------
429    
430  opts.Add(  opts.Add(
431      'PYGTK_ASSETS'      'PYGTK_ASSETS'
432      ,'Default location for Glade assets (placed in pygtk/config.py)'      ,'Default location for Glade assets (placed in pygtk/config.py)'
# Line 279  opts.Add(BoolOption( Line 439  opts.Add(BoolOption(
439      ,False      ,False
440  ))  ))
441    
442  opts.Add(  opts.Add(BoolOption(
443      'INSTALL_ROOT'      'MALLOC_DEBUG'
444      ,'For use by RPM only: location of %{buildroot} during rpmbuild'      ,"Compile with debugging version of MALLOC. Required for full CUnit testing"
445      ,""      ,False
446  )  ))
447    
448    #------ dmalloc --------
449    opts.Add(PackageOption(
450        'DMALLOC_PREFIX'
451        ,"Where are your dmalloc files?"
452        ,default_prefix
453    ))
454    
455    opts.Add(PackageOption(
456        'DMALLOC_CPPPATH'
457        ,"Where are your dmalloc include files?"
458        ,default_cpppath
459    ))
460    
461    opts.Add(PackageOption(
462        'DMALLOC_LIBPATH'
463        ,"Where are your dmalloc libraries?"
464        ,default_libpath
465    ))
466    
467    opts.Add(BoolOption(
468        'WITH_DMALLOC'
469        ,"Link to the DMALLOC library (if available) for debugging of memory usage."
470        ,False
471    ))
472    
473    #-----------------------
474    
475  opts.Add(  opts.Add(
476      'DISTTAR_NAME'      'DISTTAR_NAME'
# Line 291  opts.Add( Line 478  opts.Add(
478      ,"ascend-"+version      ,"ascend-"+version
479  )  )
480    
481    opts.Add(
482        'RELEASE'
483        ,"Release number for use in RPM spec file. This should always start with a zero for releases made by the ASCEND group, in order that third parties can make 'patch' releases of higher version numbers."
484        ,"0"
485    )
486    
487    opts.Add(BoolOption(
488        'ABSOLUTE_PATHS'
489        ,"Whether to use absolute or relative paths in the installed Tcl/Tk interface. If you want to build an RPM, set this to false."
490        ,default_absolute_paths
491    ))
492    
493    opts.Add(
494        'WIN_INSTALLER_NAME'
495        ,"Name of the installer .exe to create under Windows (minus the '.exe')"
496        ,"ascend-"+version
497    )
498    
499    opts.Add(BoolOption(
500        'WITH_XTERM_COLORS'
501        ,"Set to 0 if you don't want xterm colour codes in the console output"
502        ,True
503    ))
504    
505    opts.Add(BoolOption(
506        'WITH_EXTFNS'
507        ,"Set to 0 if you don't want to attempt to build external modules bundled"
508            + " with ASCEND."
509        ,True
510    ))
511    
512    opts.Add(BoolOption(
513        'WITH_SCROLLKEEPER'
514        ,"Set to to 1 if you want to install an OMF file that can be read by scrollkeeper (eg Yelp on GNOME)"
515        ,default_with_scrollkeeper
516    ))
517    
518  if platform.system()!="Windows":  if platform.system()!="Windows":
519      opts.Add(BoolOption(      opts.Add(BoolOption(
520          'WITH_GCCVISIBILITY'          'WITH_GCCVISIBILITY'
# Line 298  if platform.system()!="Windows": Line 522  if platform.system()!="Windows":
522          , True          , True
523      ))      ))
524    
525  if platform.system()=="Windows":  
     opts.Add(BoolOption(  
         'WITH_INSTALLER'  
         ,'Build the Windows Installer (setup program) using NSIS'  
         ,False  
     ))  
526    
527  # TODO: OTHER OPTIONS?  # TODO: OTHER OPTIONS?
528  # TODO: flags for optimisation  # TODO: flags for optimisation
# Line 312  if platform.system()=="Windows": Line 531  if platform.system()=="Windows":
531    
532  # Import the outside environment  # Import the outside environment
533    
534  if os.environ.has_key('OSTYPE') and os.environ['OSTYPE']=='msys':  def c_escape(str):
535      env = Environment(          return re.sub("\\\\","/",str)
536          ENV=os.environ  
537          , tools=['mingw','lex','yacc','fortran','swig','disttar']  envadditional={}
         , toolpath=['scons']  
     )  
     env['IS_MINGW']=True  
 else:  
     env = Environment(  
         ENV=os.environ  
         ,tools=['default','lex','yacc','fortran','swig','disttar']  
         , toolpath=['scons']  
     )  
538    
539  if platform.system()=='Windows' and env.has_key('MSVS'):  if platform.system()=="Windows":
540      print "INCLUDE =",env['ENV']['INCLUDE']      if os.environ.get('OSTYPE')=='msys':
541      print "LIB =",env['ENV']['LIB']          envenv = os.environ;
542      print "PATH =",env['ENV']['PATH']          tools = ['mingw','lex','yacc','fortran','swig','disttar','nsis']
543      env.Append(CPPPATH=env['ENV']['INCLUDE'])          #TODO removed 'doxygen' for SCons 0.96.93
544      env.Append(LIBPATH=env['ENV']['LIB'])          envadditional['IS_MINGW']=True
545        else:
546            envenv = {
547                'PATH':os.environ['PATH']
548                ,'INCLUDE':os.environ['INCLUDE']
549                ,'LIB':os.environ['LIB']
550                ,'MSVS_IGNORE_IDE_PATHS':1
551            }
552            tools=['default','lex','yacc','fortran','swig','disttar','nsis']    
553            #TODO removed 'doxygen' for SCons 0.96.93
554            envadditional['CPPDEFINES']=['_CRT_SECURE_NO_DEPRECATE']
555    else:
556        if os.environ.get('TARGET')=='mingw':
557            envenv = os.environ
558            tools=['crossmingw','lex','yacc','disttar','nsis','doxygen']
559            envadditional['CPPPATH']=['/usr/local/lib/gcc/i386-mingw32/3.4.5/include','/usr/include']
560        else:
561            envenv = os.environ
562            tools=['default','lex','yacc','fortran','swig','disttar','nsis']
563            #TODO removed 'doxygen' for SCons 0.96.93
564        
565        
566    env = Environment(
567        ENV=envenv
568        , toolpath=['scons']
569        , tools=tools
570        , **envadditional
571    )
572    
573  opts.Update(env)  opts.Update(env)
574  opts.Save('options.cache',env)  opts.Save('options.cache',env)
# Line 344  without_tcltk_reason = "disabled by opti Line 581  without_tcltk_reason = "disabled by opti
581  with_python = env.get('WITH_PYTHON')  with_python = env.get('WITH_PYTHON')
582  without_python_reason = "disabled by options/config.py"  without_python_reason = "disabled by options/config.py"
583    
584  with_cunit_tests = env.get('WITH_CUNIT_TESTS')  with_cunit = env.get('WITH_CUNIT')
585  without_cunit_reason = "not requested"  without_cunit_reason = "not requested"
586    
587    with_extfns = env.get('WITH_EXTFNS')
588    without_extfn_reason = "disabled by options/config.py"
589    
590    with_scrollkeeper = env.get('WITH_SCROLLKEEPER')
591    without_scrollkeeper_reason = "disabled by options/config.py"
592    
593    with_dmalloc = env.get('WITH_DMALLOC')
594    without_dmalloc_reason = "disabled by options/config.py"
595    
596    if platform.system()=="Windows":
597        with_installer=1
598    else:
599        with_installer=0
600        without_installer_reason = "only possible under Windows"
601    
602    if 'LSOD' in env['WITH_SOLVERS']:
603        with_lsode=True
604    else:
605        with_lsode=False
606        without_lsode_reason = "not requested (WITH_SOLVERS)"
607        
608    if 'IDA' in env['WITH_SOLVERS']:
609        with_ida=True
610    else:
611        with_ida=False
612        without_ida_reason = "not requested (WITH_SOLVERS)"
613    
614    
615    if 'CONOPT' in env['WITH_SOLVERS']:
616        with_conopt=True
617    else:
618        with_conopt=False
619        without_conopt_reason = "not requested (WITH_SOLVERS)"
620    
621    
622  #print "SOLVERS:",env['WITH_SOLVERS']  #print "SOLVERS:",env['WITH_SOLVERS']
623  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
624  #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']  #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
# Line 357  if platform.system()=='Windows': Line 629  if platform.system()=='Windows':
629    
630  env['CAN_INSTALL']=can_install  env['CAN_INSTALL']=can_install
631    
632    env['INSTALL_MODELS']=env['INSTALL_ASCDATA']+"/models/"
633    
634  print "TCL_CPPPATH =",env['TCL_CPPPATH']  print "TCL_CPPPATH =",env['TCL_CPPPATH']
635  print "TCL_LIBPATH =",env['TCL_LIBPATH']  print "TCL_LIBPATH =",env['TCL_LIBPATH']
636  print "TCL_LIB =",env['TCL_LIB']  print "TCL_LIB =",env['TCL_LIB']
637  print "CC =",env['CC']  print "CC =",env['CC']
638  print "CXX =",env['CXX']  print "CXX =",env['CXX']
639    print "FORTRAN=",env.get('FORTRAN')
640    
641    print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
642  #------------------------------------------------------  #------------------------------------------------------
643  # SPECIAL CONFIGURATION TESTS  # SPECIAL CONFIGURATION TESTS
644    
# Line 412  def CheckSwigVersion(context): Line 688  def CheckSwigVersion(context):
688          return 0;          return 0;
689    
690  #----------------  #----------------
691    # Scrollkeeper (Linux documentation system)
692    
693    def get_scrollkeeper_omfdir(env):
694        cmd = 'scrollkeeper-config --omfdir'
695        (cin,coutcerr) = os.popen4(cmd)
696        output = coutcerr.read()
697        return output.strip()
698    
699    def CheckScrollkeeperConfig(context):
700        try:
701            context.Message("Checking for scrollkeeper...")
702            dir=get_scrollkeeper_omfdir(context.env)
703        except:
704            context.Result("Failed to run 'scrollkeeper-config'")
705            return 0
706        context.env['OMFDIR']=dir
707        context.Result("OK, %s" % dir)
708        return 1
709    
710    #----------------
711  # General purpose library-and-header test  # General purpose library-and-header test
712    
713  class KeepContext:  class KeepContext:
714      def __init__(self,context,varprefix,static=False):      def __init__(self,context,varprefix,static=False):
715          self.keep = {}          self.keep = {}
716          for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:          for k in ['LIBS','LIBPATH','CPPPATH','LINKFLAGS']:
717              if context.env.has_key(k):              #print "Keeping env %s = %s" % (k,context.env.get(k))
718                  self.keep[k] = context.env[k]              self.keep[k]=context.env.get(k)
             else:  
                 self.keep[k] = None  
719                    
720          if context.env.has_key(varprefix+'_CPPPATH'):          if context.env.has_key(varprefix+'_CPPPATH'):
721              context.env.Append(CPPPATH=[env[varprefix+'_CPPPATH']])              context.env.AppendUnique(CPPPATH=[env[varprefix+'_CPPPATH']])
722              #print "Adding '"+str(cpppath_add)+"' to cpp path"              #print "Adding '"+str(env[varprefix+'_CPPPATH'])+"' to cpp path"
723    
724          if static:          if static:
725              staticlib=env[varprefix+'_LIB']              staticlib=env[varprefix+'_LIB']
# Line 436  class KeepContext: Line 730  class KeepContext:
730          else:          else:
731              if context.env.has_key(varprefix+'_LIBPATH'):              if context.env.has_key(varprefix+'_LIBPATH'):
732                  context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])                  context.env.Append(LIBPATH=[env[varprefix+'_LIBPATH']])
733                  #print "Adding '"+str(libpath_add)+"' to lib path"                  #print "Adding '"+str(env[varprefix+'_LIBPATH'])+"' to lib path"
734    
735              if context.env.has_key(varprefix+'_LIB'):              if context.env.has_key(varprefix+'_LIB'):
736                  context.env.Append(LIBS=[env[varprefix+'_LIB']])                  context.env.Append(LIBS=[env[varprefix+'_LIB']])
737                  #print "Adding '"+str(libs_add)+"' to libs"                  #print "Adding '"+str(env[varprefix+'_LIB'])+"' to libs"    
738    
739      def restore(self,context):      def restore(self,context):
740          #print "RESTORING CONTEXT"          #print "RESTORING CONTEXT"
# Line 452  class KeepContext: Line 746  class KeepContext:
746                      #print "Clearing "+str(k)                      #print "Clearing "+str(k)
747                      del context.env[k];                      del context.env[k];
748              else:              else:
749                  #print "Restoring "+str(k)+" to '"+self.keep[k]+"'"                              #print "Restoring %s to '%s'" %(k,self.keep.get(k))
750                  context.env[k]=self.keep[k];                  context.env[k]=self.keep[k];
751    
752  def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False):  def CheckExtLib(context,libname,text,ext='.c',varprefix=None,static=False):
# Line 469  def CheckExtLib(context,libname,text,ext Line 763  def CheckExtLib(context,libname,text,ext
763      if varprefix==None:      if varprefix==None:
764          varprefix = libname.upper()          varprefix = libname.upper()
765            
766        #print "LIBS is currently:",context.env.get('LIBS')
767      keep = KeepContext(context,varprefix,static)      keep = KeepContext(context,varprefix,static)
768    
769      if not context.env.has_key(varprefix+'_LIB'):      if not context.env.has_key(varprefix+'_LIB'):
770          # if varprefix_LIB were in env, KeepContext would          # if varprefix_LIB were in env, KeepContext would
771          # have appended it already          # have appended it already
772          context.env.Append(LIBS=libname)          context.env.Append(LIBS=[libname])
773    
774      is_ok = context.TryLink(text,ext)      is_ok = context.TryLink(text,ext)
775            
# Line 483  def CheckExtLib(context,libname,text,ext Line 778  def CheckExtLib(context,libname,text,ext
778      keep.restore(context)      keep.restore(context)
779    
780  #   print "Restored CPPPATH="+str(context.env['CPPPATH'])  #   print "Restored CPPPATH="+str(context.env['CPPPATH'])
781  #   print "Restored LIBS="+libname  #   print "Restored LIBS="+str(context.env['LIBS'])
782  #   print "Restored LIBPATH="+str(context.env['LIBPATH'])  #   print "Restored LIBPATH="+str(context.env['LIBPATH'])
783    
784      context.Result(is_ok)      context.Result(is_ok)
# Line 537  def CheckGccVisibility(context): Line 832  def CheckGccVisibility(context):
832  # YACC  # YACC
833    
834  yacc_test_text = """  yacc_test_text = """
835  %start ROOT  %{
836     %token MSG  #include <stdio.h>
    %%  
837    
838     ROOT:  /* MSVC++ needs this before it can swallow Bison output */
839       MSG { print("HELLO"); }  #ifdef _MSC_VER
840     ;  # define __STDC__
841    #endif
842    %}
843    %token MSG
844    %start ROOT
845    %%
846    ROOT:
847        MSG { printf("HELLO"); }
848        ;
849    %%
850  """  """
851    
852  def CheckYacc(context):  def CheckYacc(context):
853      context.Message("Checking for Yacc... ")      context.Message("Checking for Yacc ('%s')... " % context.env.get('YACC'))
854      is_ok = context.TryCompile(yacc_test_text,".y")      is_ok = context.TryCompile(yacc_test_text,".y")
855      context.Result(is_ok)      context.Result(is_ok)
856      return is_ok      return is_ok
# Line 577  def CheckCUnit(context): Line 880  def CheckCUnit(context):
880      return CheckExtLib(context,'cunit',cunit_test_text)      return CheckExtLib(context,'cunit',cunit_test_text)
881    
882  #----------------  #----------------
883    # dmalloc test
884    
885    dmalloc_test_text = """
886    #include <stdlib.h>
887    #include <dmalloc.h>
888    
889    int main(void){
890        char *c;
891        c = malloc(100*sizeof(char));
892        free(c);
893        return 0;
894    }
895    """
896    
897    def CheckDMalloc(context):
898        return CheckExtLib(context,'dmalloc',dmalloc_test_text)
899    
900    #----------------
901    # MATH test
902    
903    math_test_text = """
904    #ifndef _ALL_SOURCE
905    # define _ALL_SOURCE
906    #endif
907    #ifndef _XOPEN_SOURCE
908    # define _XOPEN_SOURCE
909    #endif
910    #ifndef _XOPEN_SOURCE_EXTENDED
911    # define _XOPEN_SOURCE_EXTENDED 1
912    #endif
913    #include <math.h>
914    int main(void){
915        double x = 1.0; double y = 1.0; int i = 1;
916        acosh(x); asinh(x); atanh(x); cbrt(x); expm1(x); erf(x); erfc(x); isnan(x);
917        j0(x); j1(x); jn(i,x); ilogb(x); logb(x); log1p(x); rint(x);
918        y0(x); y1(x); yn(i,x);
919    #ifdef _THREAD_SAFE
920        gamma_r(x,&i);
921        lgamma_r(x,&i);
922    #else
923    gamma(x);
924        lgamma(x);
925    #endif
926        hypot(x,y); nextafter(x,y); remainder(x,y); scalb(x,y);
927        return 0;
928    }
929    """
930    
931    def CheckMath(context):
932        context.Message('Checking for IEEE math library... ')
933        libsave=context.env.get('LIBS');
934        context.env.AppendUnique(LIBS=['m'])
935        is_ok=context.TryLink(math_test_text,".c")
936        context.Result(is_ok)
937        if not is_ok:
938            context.env['LIBS']=libsave
939        return is_ok
940    
941    #----------------
942    # IDA test
943    
944    sundials_version_major_required = 2
945    sundials_version_minor_min = 2
946    sundials_version_minor_max = 3
947    
948    sundials_version_text = """
949    #include <sundials/sundials_config.h>
950    #include <stdio.h>
951    int main(){
952        printf("%s",SUNDIALS_PACKAGE_VERSION);
953        return 0;
954    }
955    """
956    
957    ida_test_text = """
958    # include <ida/ida.h>
959    # include <nvector/nvector_serial.h>
960    # include <ida/ida_spgmr.h>
961    int main(){
962        void *ida_mem;
963        ida_mem = IDACreate();
964        return 0;
965    }
966    """
967    
968    def CheckIDA(context):
969        context.Message( 'Checking for IDA (SUNDIALS)... ' )
970    
971        keep = KeepContext(context,"IDA")
972        
973        is_ok = context.TryLink(ida_test_text,".c")
974        context.Result(is_ok)
975        
976        keep.restore(context)
977            
978        return is_ok
979    
980    # slightly changed calling convention (IDACalcID) in newer versions of SUNDIALS,
981    # so detect the version and act accordingly.
982    def CheckIDAVersion(context):
983        keep = KeepContext(context,'IDA')
984        context.Message("Checking SUNDIALS version... ")
985        (is_ok,output) = context.TryRun(sundials_version_text,'.c')
986        keep.restore(context)
987        if not is_ok:
988            context.Result("failed to run check")
989            return 0
990    
991        major,minor,patch = tuple([int(i) for i in output.split(".")])
992        context.env['SUNDIALS_VERSION_MAJOR'] = major
993        context.env['SUNDIALS_VERSION_MINOR'] = minor
994        if major != sundials_version_major_required \
995                or minor < sundials_version_minor_min \
996                or minor > sundials_version_minor_max:
997            context.Result(output+" (bad version)")
998            # bad version
999            return 0
1000            
1001        # good version
1002        context.Result(output+", good")
1003        return 1
1004        
1005    #----------------
1006    # CONOPT test
1007    
1008    conopt_test_text = """
1009    #if !defined(_WIN32)
1010    # define FNAME_LCASE_DECOR
1011    #endif
1012    
1013    #include <conopt.h>
1014    #include <stdlib.h>
1015    int main(){
1016        int s, *v, e;
1017        s = COIDEF_Size();
1018        v = (int *)malloc(s*sizeof(int));
1019        e = COIDEF_Ini(v);
1020        return e;
1021    }
1022    """
1023    
1024    def CheckCONOPT(context):
1025        context.Message( 'Checking for CONOPT... ' )
1026    
1027        keep = KeepContext(context,"CONOPT")
1028        
1029        is_ok = context.TryLink(conopt_test_text,".c")
1030        context.Result(is_ok)
1031        
1032        keep.restore(context)
1033            
1034        return is_ok
1035    
1036    #----------------
1037  # Tcl test  # Tcl test
1038    
1039  # 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 626  int main(void){ Line 1083  int main(void){
1083  }  }
1084  """  """
1085  def CheckTk(context):  def CheckTk(context):
1086      return CheckExtLib(context,'tk',tcl_check_text,static=env['STATIC_TCLTK'])      return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
1087    
1088    
1089  def CheckTkVersion(context):  def CheckTkVersion(context):
# Line 683  def CheckX11(context): Line 1140  def CheckX11(context):
1140      return CheckExtLib(context,'X11',x11_check_text)      return CheckExtLib(context,'X11',x11_check_text)
1141    
1142  #----------------  #----------------
1143    # Check that we're able to catch floating point errors
1144    
1145    sigfpe_test_text = r"""
1146    #include <signal.h>
1147    #include <setjmp.h>
1148    #include <stdlib.h>
1149    #include <fenv.h>
1150    static jmp_buf g_jmpenv;
1151    void fpehandler(int sig){
1152        longjmp(g_jmpenv,sig);
1153    }
1154    int main(void){
1155        fenv_t myfenv;
1156        fegetenv(&myfenv);
1157        fesetenv(&myfenv);
1158        feenableexcept(FE_ALL_EXCEPT);
1159        signal(SIGFPE,&fpehandler);
1160        double x;
1161        switch(setjmp(g_jmpenv)){
1162            case 0:
1163                x = 1.0 / 0.0;
1164                /* failed to catch */
1165                exit(1);            
1166            case SIGFPE:
1167                exit(0);
1168        }
1169    }
1170    """
1171    
1172    def CheckFPE(context):
1173        context.Message("Checking for C99 FPE behaviour... ")
1174        (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1175        context.Result(is_ok)
1176        return is_ok
1177    
1178    #----------------
1179  # GCC Version sniffing  # GCC Version sniffing
1180    
1181  # TODO FIXME  # TODO FIXME
# Line 694  gcc_version4 = False Line 1187  gcc_version4 = False
1187    
1188  conf = Configure(env  conf = Configure(env
1189      , custom_tests = {      , custom_tests = {
1190          'CheckSwigVersion' : CheckSwigVersion          'CheckMath' : CheckMath
1191            , 'CheckSwigVersion' : CheckSwigVersion
1192          , 'CheckCUnit' : CheckCUnit          , 'CheckCUnit' : CheckCUnit
1193            , 'CheckDMalloc' : CheckDMalloc
1194          , 'CheckTcl' : CheckTcl          , 'CheckTcl' : CheckTcl
1195          , 'CheckTclVersion' : CheckTclVersion          , 'CheckTclVersion' : CheckTclVersion
1196          , 'CheckTk' : CheckTk          , 'CheckTk' : CheckTk
# Line 705  conf = Configure(env Line 1200  conf = Configure(env
1200          , 'CheckYacc' : CheckYacc          , 'CheckYacc' : CheckYacc
1201          , 'CheckTkTable' : CheckTkTable          , 'CheckTkTable' : CheckTkTable
1202          , 'CheckX11' : CheckX11          , 'CheckX11' : CheckX11
1203            , 'CheckIDA' : CheckIDA
1204            , 'CheckIDAVersion' : CheckIDAVersion
1205            , 'CheckCONOPT' : CheckCONOPT
1206            , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1207            , 'CheckFPE' : CheckFPE
1208  #       , 'CheckIsNan' : CheckIsNan  #       , 'CheckIsNan' : CheckIsNan
1209  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig
1210      }      }
1211  #   , config_h = "config.h"  #   , config_h = "config.h"
1212  )  )
1213    
1214    # stdio -- just to check that compiler is behaving
1215    
1216    if not conf.CheckHeader('stdio.h'):
1217        print "CPPPATH =",env.get('CPPPATH')
1218        print "Did not find 'stdio.h'! Check your compiler configuration."
1219        Exit(1)
1220    
1221  # Math library  # Math library
1222    
1223  #if not conf.CheckFunc('sinh') and not conf.CheckLibWithHeader(['m','c','libc'], 'math.h', 'C'):  if need_libm:
1224  #   print 'Did not find math library, exiting!'      if not conf.CheckMath():
1225  #   Exit(1)          print 'Did not find math library, exiting!'
1226            Exit(1)
1227        #pass
1228    
1229  # Where is 'isnan'?  # Where is 'isnan'?
1230    
1231  if not conf.CheckFunc('isnan'):  if not conf.CheckFunc('isnan') and not conf.CheckFunc('_isnan'):
1232      print "Didn't find isnan"      print "Didn't find isnan"
1233  #   Exit(1)  #   Exit(1)
1234    
# Line 732  if conf.CheckGcc(): Line 1240  if conf.CheckGcc():
1240          conf.env['HAVE_GCCVISIBILITY']=True;          conf.env['HAVE_GCCVISIBILITY']=True;
1241          conf.env.Append(CCFLAGS=['-fvisibility=hidden'])          conf.env.Append(CCFLAGS=['-fvisibility=hidden'])
1242          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
1243        conf.env.Append(CCFLAGS=['-Wall'])
1244    
1245    # Catching SIGFPE
1246    
1247    if conf.CheckFPE():
1248        conf.env['HAVE_SIGFPE']=True
1249    else:
1250        conf.env['HAVE_SIGFPE']=False
1251    
1252  # YACC  # YACC
1253    
# Line 744  conf.env['HAVE_LEX']=True Line 1260  conf.env['HAVE_LEX']=True
1260    
1261  # Tcl/Tk  # Tcl/Tk
1262    
1263  if conf.CheckTcl():  if with_tcltk:
1264      if with_tcltk and conf.CheckTclVersion():      if conf.CheckTcl():
1265          if conf.CheckTk():          if conf.CheckTclVersion():
1266              if with_tcltk and conf.CheckTkVersion():              if conf.CheckTk():
1267                  if env['STATIC_TCLTK']:                  if with_tcltk and conf.CheckTkVersion():
1268                      if conf.CheckTkTable():                      if env['STATIC_TCLTK']:
1269                          pass                          if conf.CheckTkTable():
1270                      else:                              pass
1271                          without_tcltk_reason = "TkTable not found"                          else:
1272                          with_tcltk = False                              without_tcltk_reason = "TkTable not found"
1273                                with_tcltk = False
1274                    else:
1275                        without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"
1276                        with_tcltk = False
1277              else:              else:
1278                  without_tcltk_reason = "Require Tk version <= 8.4. See 'scons -h'"                  without_tcltk_reason = "Tk not found."
1279                  with_tcltk = False                  with_tcltk = False
1280          else:          else:
1281              without_tcltk_reason = "Tk not found."              without_tcltk_reason = "Require Tcl <= 8.4 Tcl."
1282              with_tcltk = False              with_tcltk = False
1283    
1284      else:      else:
1285          without_tcltk_reason = "Require Tcl <= 8.4 Tcl."          without_tcltk_reason = "Tcl not found."
1286          with_tcltk = False          with_tcltk = False
1287    
 else:  
     without_tcltk_reason = "Tcl not found."  
     with_tcltk = False  
   
1288  if env['STATIC_TCLTK']:  if env['STATIC_TCLTK']:
1289      conf.CheckX11()      conf.CheckX11()
1290    
# Line 787  if not conf.CheckSwigVersion(): Line 1304  if not conf.CheckSwigVersion():
1304    
1305  # CUnit  # CUnit
1306    
1307  if with_cunit_tests:  if with_cunit:
1308      if not conf.CheckCUnit():      if not conf.CheckCUnit():
1309          without_cunit_reason = 'CUnit not found'          without_cunit_reason = 'CUnit not found'
1310            with_cunit = False
1311            #print "CUNIT NOT FOUND, LIBS=",conf.env.get('LIBS')
1312    
1313    # DMALLOC
1314    
1315    if with_dmalloc:
1316        if not conf.CheckDMalloc():
1317            without_dmalloc_reason = 'dmalloc not found'
1318            with_dmalloc = False
1319    
1320    # IDA
1321    
1322    if not with_ida:
1323        without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
1324    elif not conf.CheckIDA():
1325        with_ida = False
1326        without_ida_reason = "IDA not found"
1327    elif not conf.CheckIDAVersion():
1328        with_ida = False
1329        without_ida_reason = "Unsupported (or undetected) SUNDIALS version"
1330    
1331    # CONOPT
1332    
1333    if not with_conopt:
1334        without_conopt_reason = "Not selected (see config option WITH_SOLVERS)"
1335    elif not conf.CheckCONOPT():
1336        with_conopt = False
1337        without_conpt_reason = "CONOPT not found"
1338    
1339  # BLAS  # BLAS
1340    
1341  need_blas=False  need_blas=False
1342  if with_tcltk:  
1343    if with_lsode:
1344        need_fortran = True
1345      need_blas=True      need_blas=True
1346    
1347  if need_blas:  if need_blas:
1348      if conf.CheckLib('blas'):      if conf.CheckLib('blas'):
1349          with_local_blas = False          with_local_blas = False
# Line 803  if need_blas: Line 1351  if need_blas:
1351      else:      else:
1352          with_local_blas = True          with_local_blas = True
1353          need_fortran = True          need_fortran = True
1354    else:
1355        with_local_blas= False;
1356        without_local_blas_reason = "BLAS not required"
1357    
1358  # FORTRAN  # FORTRAN
1359    
1360  if need_fortran:  if need_fortran:
1361      conf.env.Tool('f77')      conf.env.Tool('fortran')
1362      detect_fortran = conf.env.Detect(['g77','f77'])      detect_fortran = conf.env.Detect(['g77','f77','gfortran'])
1363      if detect_fortran:      if detect_fortran:
1364          # For some reason, g77 doesn't get detected properly on MinGW          # For some reason, g77 doesn't get detected properly on MinGW
1365          if not env.has_key('F77'):          if not env.has_key('F77') and not env.has_key('FORTRAN'):
1366              conf.env.Replace(F77=detect_fortran)              conf.env.Replace(F77=detect_fortran)
1367              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
1368              conf.env.Replace(F77FLAGS='')              conf.env.Replace(F77FLAGS='')
# Line 825  if need_fortran: Line 1376  if need_fortran:
1376              )              )
1377              conf.env.Append(BUILDERS={'Fortran':fortran_builder})              conf.env.Append(BUILDERS={'Fortran':fortran_builder})
1378      else:      else:
1379          print "FORTRAN-77 required but not found"          with_lsode=False;
1380          Exit(1)          without_lsode_reason="FORTRAN-77 required but not found"
1381    
1382  #else:  #else:
1383  #   print "FORTRAN not required"  #   print "FORTRAN not required"
1384    
1385    # F2C
1386    
1387    if need_fortran:
1388        if platform.system()=="Windows":
1389            conf.env.Append(LIBPATH='c:\mingw\lib')
1390    
1391    # scrollkeeper
1392    
1393    if with_scrollkeeper:
1394        if not conf.CheckScrollkeeperConfig():
1395            with_scrollkeeper=False
1396            without_scrollkeeper_reason="unable to detect scrollkeeper-config"
1397    
1398  # TODO: -D_HPUX_SOURCE is needed  # TODO: -D_HPUX_SOURCE is needed
1399    
1400  # TODO: check size of void*  # TODO: check size of void*
# Line 837  if need_fortran: Line 1402  if need_fortran:
1402  # TODO: detect if dynamic libraries are possible or not  # TODO: detect if dynamic libraries are possible or not
1403    
1404  if platform.system()=="Windows" and env.has_key('MSVS'):  if platform.system()=="Windows" and env.has_key('MSVS'):
1405      if not conf.CheckHeader('windows.h') and env['PACKAGE_LINKING']=='DYNAMIC_PACKAGES':      _found_windows_h = conf.CheckHeader('Windows.h')
1406          print "Reverting to STATIC_PACKAGES since windows.h is not available. Probably you "\  
1407              +"need to install the Microsoft Windows Server 2003 Platform SDK, or similar."      if not _found_windows_h:
1408          env['PACKAGE_LINKING']='STATIC_PACKAGES'          print "Could not locate 'Windows.h' in CPPPATH. Check your configuration."
1409                    Exit(1)
1410    
1411      if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):      if with_python and not conf.CheckHeader(['basetsd.h','BaseTsd.h']):
1412          with_python = 0;          with_python = 0;
1413          without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."          without_python_reason = "Header file 'basetsd.h' not found. Install the MS Platform SDK."
# Line 857  env.Append(PYTHON_CPPPATH=[distutils.sys Line 1423  env.Append(PYTHON_CPPPATH=[distutils.sys
1423  #---------------------------------------  #---------------------------------------
1424  # SUBSTITUTION DICTIONARY for .in files  # SUBSTITUTION DICTIONARY for .in files
1425    
1426    release = env.get('RELEASE')
1427    if release=="0.":
1428        release="0"
1429    
1430    #print "SUBSTITUTED CONOPT_LIBPATH:",c_escape(env.subst("$CONOPT_LIBPATH"))
1431    
1432  subst_dict = {  subst_dict = {
1433      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']      '@DEFAULT_ASCENDLIBRARY@':env['DEFAULT_ASCENDLIBRARY']
1434      , '@GLADE_FILE@':'ascend.glade'      , '@GLADE_FILE@':'ascend.glade'
1435      , '@HELP_ROOT@':''      , '@HELP_ROOT@':''
1436      , '@ICON_EXTENSION@':icon_extension      , '@ICON_EXTENSION@':icon_extension
1437      , '@INSTALL_DATA@':env['INSTALL_DATA']      , '@INSTALL_ASCDATA@':env['INSTALL_ASCDATA']
1438      , '@INSTALL_BIN@':env['INSTALL_BIN']      , '@INSTALL_BIN@':env['INSTALL_BIN']
1439      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']      , '@INSTALL_INCLUDE@':env['INSTALL_INCLUDE']
1440        , '@INSTALL_LIB@':env['INSTALL_LIB']
1441        , '@INSTALL_MODELS@':env['INSTALL_MODELS']
1442      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']      , '@PYGTK_ASSETS@':env['PYGTK_ASSETS']
1443      , '@VERSION@':version      , '@VERSION@':version
1444        , '@RELEASE@':release
1445      , '@DISTTAR_NAME@':env['DISTTAR_NAME']      , '@DISTTAR_NAME@':env['DISTTAR_NAME']
1446      , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'      , '@WEBHELPROOT@':'http://pye.dyndns.org/ascend/manual/'
1447      , '@ASC_SHLIBSUFFIX@':env['SHLIBSUFFIX']      , '@ASC_SHLIBSUFFIX@':env['SHLIBSUFFIX']
1448      , '@ASC_SHLIBPREFIX@':env['SHLIBPREFIX']      , '@ASC_SHLIBPREFIX@':env['SHLIBPREFIX']
1449        , '@ASC_ENV_TK_DEFAULT@' : '$$ASCENDDIST/tcltk'
1450        , '@ASC_DISTDIR_REL_BIN@' : default_rel_distdir
1451        , '@PYTHON@' : python_exe
1452        , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
1453        , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
1454        , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_LIBPATH"))
1455        , '@SOURCE_ROOT@':os.path.abspath(str(env.Dir("#")))
1456  }  }
1457    
1458  if env['WITH_LOCAL_HELP']:  if env.get('WITH_LOCAL_HELP'):
1459      print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']      print "WITH_LOCAL_HELP:",env['WITH_LOCAL_HELP']
1460      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']
1461    
1462    # bool options...
1463    for k,v in {
1464            'ABSOLUTE_PATHS' : 'ASC_ABSOLUTE_PATHS'
1465            ,'WITH_XTERM_COLORS' : 'ASC_XTERM_COLORS'
1466            ,'MALLOC_DEBUG' : 'MALLOC_DEBUG'
1467    }.iteritems():
1468        if env.get(k):
1469    #       subst_dict['@'+v+'@']='1'
1470            subst_dict["/\\* #define "+v+' @'+v+"@ \\*/"]='# define '+v+' 1 '
1471    
1472    if with_ida:
1473        subst_dict["/\\* #define ASC_WITH_IDA @ASC_WITH_IDA@ \\*/"]='#define ASC_WITH_IDA '
1474    
1475    if with_dmalloc:
1476        subst_dict["/\\* #define ASC_WITH_DMALLOC @ASC_WITH_DMALLOC@ \\*/"]='#define ASC_WITH_DMALLOC '
1477    
1478    if with_conopt:
1479        subst_dict["/\\* #define ASC_WITH_CONOPT @ASC_WITH_CONOPT@ \\*/"]='#define ASC_WITH_CONOPT '
1480    
1481    if with_lsode:
1482        subst_dict["/\\* #define ASC_WITH_LSODE @ASC_WITH_LSODE@ \\*/"]='#define ASC_WITH_LSODE '
1483    
1484  if with_python:  if with_python:
1485      subst_dict['@ASCXX_USE_PYTHON@']="1"      subst_dict['@ASCXX_USE_PYTHON@']="1"
1486        env['WITH_PYTHON']=1;
1487    
1488  if env.has_key('HAVE_GCCVISIBILITY'):  if env.has_key('HAVE_GCCVISIBILITY'):
1489      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
# Line 886  if env.has_key('HAVE_GCCVISIBILITY'): Line 1491  if env.has_key('HAVE_GCCVISIBILITY'):
1491  env.Append(SUBST_DICT=subst_dict)  env.Append(SUBST_DICT=subst_dict)
1492    
1493  #------------------------------------------------------  #------------------------------------------------------
1494    # RECIPE: Fix up long command-line bug on Win2k
1495    
1496    # Currently this is broken, awaiting help from the SCons users list
1497    
1498    if 0 and env['PLATFORM'] == 'win32':
1499        import win32file
1500        import win32event
1501        import win32process
1502        import win32security
1503        import string
1504    
1505        def my_spawn(sh, escape, cmd, args, spawnenv):
1506            for var in spawnenv:
1507                spawnenv[var] = spawnenv[var].encode('ascii', 'replace')
1508    
1509            sAttrs = win32security.SECURITY_ATTRIBUTES()
1510            StartupInfo = win32process.STARTUPINFO()
1511            newargs = string.join(map(escape, args[1:]), ' ')
1512            cmdline = cmd + " " + newargs
1513    
1514            # check for any special operating system commands
1515            if cmd == 'del':
1516                for arg in args[1:]:
1517                    win32file.DeleteFile(arg)
1518                exit_code = 0
1519            else:
1520                # otherwise execute the command.
1521                hProcess, hThread, dwPid, dwTid = win32process.CreateProcess(None, cmdline, None, None, 1, 0, spawnenv, None, StartupInfo)
1522                win32event.WaitForSingleObject(hProcess, win32event.INFINITE)
1523                exit_code = win32process.GetExitCodeProcess(hProcess)
1524                win32file.CloseHandle(hProcess);
1525                win32file.CloseHandle(hThread);
1526            return exit_code
1527    
1528        env['SPAWN'] = my_spawn
1529    
1530    #------------------------------------------------------
1531  # RECIPE: SWIG scanner  # RECIPE: SWIG scanner
1532    
1533  import SCons.Script  import SCons.Script
# Line 991  SConsEnvironment.InstallPerm = InstallPe Line 1633  SConsEnvironment.InstallPerm = InstallPe
1633            
1634  # define wrappers      # define wrappers    
1635  SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)    SConsEnvironment.InstallProgram = lambda env, dest, files: InstallPerm(env, dest, files, 0755)  
1636  SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)      SConsEnvironment.InstallHeader = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
1637    SConsEnvironment.InstallShared = lambda env, dest, files: InstallPerm(env, dest, files, 0644)
 #------------------------------------------------------  
 # NSIS Support for SCons  
   
 # Adapted version by John Pye, April 2006.  
 # from http://www.scons.org/cgi-sys/cgiwrap/scons/moin.cgi/NsisSconsTool  
 # Written by Mike Elkins, January 2004.  
   
 #This tool provides SCons support for the Nullsoft Scriptable Install System  
 #a windows installer builder available at http://nsis.sourceforge.net/home  
   
 #In addition, if you set NSISDEFINES to a dictionary, those variables will be passed  
 #to NSIS.  
   
 import SCons.Builder  
 import SCons.Util  
 import SCons.Scanner  
 import SCons.Sig  
 import os.path  
 import glob  
   
 def nsis_parse( sources, keyword, multiple ):  
   """  
   A function that knows how to read a .nsi file and figure  
   out what files are referenced, or find the 'OutFile' line.  
   
   
   sources is a list of nsi files.  
   keyword is the command ('File' or 'OutFile') to look for  
   multiple is true if you want all the args as a list, false if you  
   just want the first one.  
   """  
   stuff = []  
   for s in sources:  
     c = s.get_contents()  
     for l in c.split('\n'):  
       semi = l.find(';')  
       if (semi != -1):  
         l = l[:semi]  
       hash = l.find('#')  
       if (hash != -1):  
         l = l[:hash]  
       # Look for the keyword  
       l = l.strip()  
       spl = l.split(None,1)  
       if len(spl) > 1:  
         if spl[0].capitalize() == keyword.capitalize():  
           arg = spl[1]  
           if arg.startswith('"') and arg.endswith('"'):  
             arg = arg[1:-1]  
           if multiple:  
             stuff += [ arg ]  
           else:  
             return arg  
   return stuff  
   
   
 def nsis_path( filename, nsisdefines, rootdir ):  
   """  
   Do environment replacement, and prepend with the SCons root dir if  
   necessary  
   """  
   # We can't do variables defined by NSIS itself (like $INSTDIR),  
   # only user supplied ones (like ${FOO})  
   varPos = filename.find('${')  
   while varPos != -1:  
     endpos = filename.find('}',varPos)  
     assert endpos != -1  
     if not nsisdefines.has_key(filename[varPos+2:endpos]):  
       raise KeyError ("Could not find %s in NSISDEFINES" % filename[varPos+2:endpos])  
     val = nsisdefines[filename[varPos+2:endpos]]  
     if type(val) == list:  
       if varPos != 0 or endpos+1 != len(filename):  
         raise Exception("Can't use lists on variables that aren't complete filenames")  
       return val  
     filename = filename[0:varPos] + val + filename[endpos+1:]  
     varPos = filename.find('${')  
   return filename  
   
   
 def nsis_scanner( node, env, path ):  
   """  
   The scanner that looks through the source .nsi files and finds all lines  
   that are the 'File' command, fixes the directories etc, and returns them.  
   """  
   nodes = node.rfile()  
   if not node.exists():  
     return []  
   nodes = []  
   source_dir = node.get_dir()  
   for include in nsis_parse([node],'file',1):  
     exp = nsis_path(include,env['NSISDEFINES'],source_dir)  
     if type(exp) != list:  
       exp = [exp]  
     for p in exp:  
       for filename in glob.glob( os.path.abspath(  
         os.path.join(str(source_dir),p))):  
           # Why absolute path?  Cause it breaks mysteriously without it :(  
           nodes.append(filename)  
   return nodes  
   
   
 def nsis_emitter( source, target, env ):  
   """  
   The emitter changes the target name to match what the command actually will  
   output, which is the argument to the OutFile command.  
   """  
   nsp = nsis_parse(source,'outfile',0)  
   if not nsp:  
     return (target,source)  
   x  = (  
     nsis_path(nsp,env['NSISDEFINES'],''),  
     source)  
   return x  
   
 def quoteIfSpaced(text):  
   if ' ' in text:  
     return '"'+text+'"'  
   else:  
     return text  
   
 def toString(item,env):  
   if type(item) == list:  
     ret = ''  
     for i in item:  
       if ret:  
         ret += ' '  
       val = toString(i,env)  
       if ' ' in val:  
         val = "'"+val+"'"  
       ret += val  
     return ret  
   else:  
     # For convienence, handle #s here  
     if str(item).startswith('#'):  
       item = env.File(item).get_abspath()  
     return str(item)  
   
 def runNSIS(source,target,env,for_signature):  
   ret = env['NSIS']+" "  
   if env.has_key('NSISFLAGS'):  
     for flag in env['NSISFLAGS']:  
       ret += flag  
       ret += ' '  
   if env.has_key('NSISDEFINES'):  
     for d in env['NSISDEFINES']:  
       ret += '/D'+d  
       if env['NSISDEFINES'][d]:  
         ret +='='+quoteIfSpaced(toString(env['NSISDEFINES'][d],env))  
       ret += ' '  
   for s in source:  
     ret += quoteIfSpaced(str(s))  
   return ret  
   
 def find_nsis(env):  
   """  
   Try and figure out if NSIS is installed on this machine, and if so,  
   where.  
   """  
   if SCons.Util.can_read_reg:  
     # If we can read the registry, get the NSIS command from it  
     try:  
       k = SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,  
                                   'SOFTWARE\\NSIS')  
       val, tok = SCons.Util.RegQueryValueEx(k,None)  
       ret = val + os.path.sep + 'makensis.exe'  
       if os.path.exists(ret):  
         return '"' + ret + '"'  
       else:  
         return None  
     except:  
       pass # Couldn't find the key, just act like we can't read the registry  
   # Hope it's on the path  
   return env.WhereIs('makensis.exe')  
   
 def nsis_exists(env):  
   """  
   Is NSIS findable on this machine?  
   """  
   if find_nsis(env) != None:  
     return 1  
   return 0  
   
 env['BUILDERS']['Nsis'] = SCons.Builder.Builder(generator=runNSIS,  
                                  src_suffix='.nsi',  
                                  emitter=nsis_emitter)  
   
 env.Append(SCANNERS = SCons.Scanner.Scanner( function = nsis_scanner,  
              skeys = ['.nsi']))  
   
 if not env.has_key('NSISDEFINES'):  
     env['NSISDEFINES'] = {}  
 env['NSIS'] = find_nsis(env)  
1638    
1639  #------------------------------------------------------  #------------------------------------------------------
1640  # BUILD...  # BUILD...
1641    
1642  # so that #include <modulename/headername.h> works across all modules...  # so that #include <modulename/headername.h> works across all modules...
1643  env.Append(CPPPATH=['#base/generic'])  env.AppendUnique(CPPPATH=['#base/generic'])
   
 if gcc_version4:  
     env.Append(CCFLAGS=['-fvisibility=hidden'])  
1644    
1645  if env['DEBUG']:  if env['DEBUG']:
1646      env.Append(CCFLAGS=['-g'])      env.Append(CCFLAGS=['-g'])
1647    
1648    if env['GCOV']:
1649        env.Append(
1650            CPPFLAGS=['-g','-fprofile-arcs','-ftest-coverage']
1651            , LIBS=['gcov']
1652            , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
1653        )
1654    
1655    if with_ida:
1656        env.Append(WITH_IDA=1)
1657    
1658    if with_conopt:
1659        env.Append(WITH_CONOPT=1)
1660    
1661  #-------------  #-------------
1662  # TCL/TK GUI  # TCL/TK GUI
1663    
1664  if with_tcltk:  if with_tcltk:
1665      if with_local_blas:      env.SConscript(['tcltk/generic/interface/SConscript'],'env')
         env.SConscript(['blas/SConscript'],'env')  
     else:  
         print "Skipping... BLAS won't be build:", without_local_blas_reason  
   
     env.SConscript(['lsod/SConscript'],'env')        
   
     env.SConscript(['linpack/SConscript'],'env')  
     env.SConscript(['tcltk98/generic/interface/SConscript'],'env')  
1666  else:  else:
1667      print "Skipping... Tcl/Tk GUI isn't being built:",without_tcltk_reason      print "Skipping... Tcl/Tk GUI isn't being built:",without_tcltk_reason
1668    
# Line 1225  else: Line 1677  else:
1677  #------------  #------------
1678  # BASE/GENERIC SUBDIRECTORIES  # BASE/GENERIC SUBDIRECTORIES
1679    
1680    libascend_env = env.Copy()
1681    
1682  dirs = ['general','utilities','compiler','solver','packages']  dirs = ['general','utilities','compiler','solver','packages']
1683    
1684  srcs = []  srcs = []
1685  for d in dirs:  for d in dirs:
1686      heresrcs = env.SConscript('base/generic/'+d+'/SConscript','env')      heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
1687      srcs += heresrcs      srcs += heresrcs
1688    
1689  #-------------  #-------------
1690    # IMPORTED CODE: LSODE, BLAS, etc
1691    
1692    if with_lsode:
1693        srcs += env.SConscript(['lsod/SConscript'],'env')
1694        srcs += env.SConscript(['linpack/SConscript'],'env')
1695    else:
1696        print "Skipping... LSODE won't be built:", without_lsode_reason
1697    
1698    if with_local_blas:
1699        srcs += env.SConscript(['blas/SConscript'],'env')
1700    else:
1701        print "Skipping... BLAS won't be built:", without_local_blas_reason
1702    
1703    if not with_ida:
1704        print "Skipping... IDA won't be built:", without_ida_reason
1705    
1706    #-------------
1707  # LIBASCEND -- all base/generic functionality  # LIBASCEND -- all base/generic functionality
1708    
1709  libascend = env.SharedLibrary('ascend',srcs)  if with_dmalloc:
1710        libascend_env.Append(LIBS=['dmalloc'])
1711    
1712    libascend = libascend_env.SharedLibrary('ascend',srcs)
1713    
1714    env.Alias('libascend',libascend)
1715    
1716  #-------------  #-------------
1717  # UNIT TESTS  # UNIT TESTS (C CODE)
1718    
1719  if with_cunit_tests:  if with_cunit:
1720      testdirs = ['general','solver','utilities']      testdirs = ['general','solver','utilities']
1721        testsrcs = []
1722      for testdir in testdirs:      for testdir in testdirs:
1723          path = 'base/generic/'+testdir+'/test/'          path = 'base/generic/'+testdir+'/test/'
1724          env.SConscript([path+'SConscript'],'env')          env.SConscript([path+'SConscript'],'env')
1725            testsrcs += [i.path for i in env['TESTSRCS_'+testdir.upper()]]
1726    
1727        #print "TESTSRCS =",testsrcs
1728            
1729      env.SConscript(['test/SConscript'],'env')      env.SConscript(['test/SConscript'],'env')
1730      env.SConscript(['base/generic/test/SConscript'],'env')      env.SConscript(['base/generic/test/SConscript'],'env')
1731        
1732        env.Alias('test',[env.Dir('test'),env.Dir('base/generic/test')])
1733            
1734  else:  else:
1735      print "Skipping... CUnit tests aren't being built:",without_cunit_reason      print "Skipping... CUnit tests aren't being built:",without_cunit_reason
1736    
1737    #-------------
1738    # EXTERNAL FUNCTIONS
1739    
1740    env['extfns']=[]
1741    modeldirs = env.SConscript(['models/SConscript'],'env')
1742    
1743    if not with_extfns:
1744        print "Skipping... External modules aren't being built:",without_extfns_reason
1745    
1746    env.Alias('extfns',env['extfns'])
1747    
1748    #------------------------------------------------------
1749    # CREATE ASCEND-CONFIG scriptlet
1750    
1751    ascendconfig = env.SubstInFile('ascend-config.in')
1752    
1753  #------------------------------------------------------  #------------------------------------------------------
1754  # INSTALLATION  # INSTALLATION
1755    
1756  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')  
1757    
1758      dirs = ['INSTALL_BIN','INSTALL_DATA','INSTALL_LIB']      dirs = ['INSTALL_BIN','INSTALL_ASCDATA','INSTALL_LIB', 'INSTALL_INCLUDE', 'INSTALL_DOC']
1759      install_dirs = [env['INSTALL_ROOT']+env[d] for d in dirs]      install_dirs = [env.Entry(env['INSTALL_ROOT']+env[d]) for d in dirs]
1760        install_dirs += modeldirs
1761    
1762      # TODO: add install options      # TODO: add install options
1763      env.Alias('install',install_dirs)      env.Alias('install',install_dirs)
1764    
1765      env.Install(env['INSTALL_ROOT']+env['INSTALL_LIB'],libascend)      env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_LIB'],libascend)
1766    
1767        env.InstallProgram(env['INSTALL_ROOT']+env['INSTALL_BIN'],ascendconfig)
1768    
1769    #------------------------------------------------------
1770    # WINDOWS INSTALLER
1771    # For the windows installer, please see pygtk/SConscript
1772    
1773    if with_installer:
1774        pass
1775    else:
1776        print "Skipping... Windows installer isn't being built:",without_installer_reason
1777    
1778    #------------------------------------------------------
1779    # PROJECT FILE for MSVC
1780    
1781    env.SConscript(['base/msvc/SConscript'],['env','libascend']);
1782    
1783  #------------------------------------------------------  #------------------------------------------------------
1784  # CREATE the SPEC file for generation of RPM packages  # CREATE the SPEC file for generation of RPM packages
# Line 1275  if platform.system()=="Linux": Line 1787  if platform.system()=="Linux":
1787      env.SubstInFile('ascend.spec.in')      env.SubstInFile('ascend.spec.in')
1788    
1789  #------------------------------------------------------  #------------------------------------------------------
1790    # CREATE OMF FILE FOR USE WITH SCROLLKEEPER
1791    
1792    if with_scrollkeeper:
1793        env.SubstInFile('#/pygtk/gnome/ascend.omf.in')
1794        env.InstallShared(env['INSTALL_ROOT']+env['OMFDIR'],"#/pygtk/gnome/ascend.omf")
1795    
1796    #------------------------------------------------------
1797  # DISTRIBUTION TAR FILE  # DISTRIBUTION TAR FILE
1798    
1799  env['DISTTAR_FORMAT']='bz2'  env['DISTTAR_FORMAT']='bz2'
1800  env.Append(  env.Append(
1801      DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.cc','.cache','.pyc','.cvsignore','.dblite','.log','.pl']      DISTTAR_EXCLUDEEXTS=['.o','.os','.so','.a','.dll','.cc','.cache','.pyc','.cvsignore','.dblite','.log','.pl','.out']
1802      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist']      , DISTTAR_EXCLUDEDIRS=['CVS','.svn','.sconf_temp', 'dist']
1803  )  )
1804    
# Line 1287  tar = env.DistTar("dist/"+env['DISTTAR_N Line 1806  tar = env.DistTar("dist/"+env['DISTTAR_N
1806      , [env.Dir('#')]      , [env.Dir('#')]
1807  )  )
1808    
1809    env.Depends(tar,'ascend.spec')
1810    
1811    Alias('dist',tar)
1812    
1813    #------------------------------------------------------
1814    # USER'S MANUAL
1815    
1816    env.SConscript('doc/SConscript',['env'])
1817    
1818    #------------------------------------------------------
1819    # LIBASCEND DOXYGEN DOCUMENTATION
1820    
1821    env.SConscript('base/doc/SConscript',['env'])
1822    
1823  #------------------------------------------------------  #------------------------------------------------------
1824  # RPM BUILD  # RPM BUILD
1825    
1826  #if platform.system()=="Linux":  # for RPM builds, 'scons dist' then 'rpmbuild -ta dist/ascend-*.tar.bz2'
1827  #   pass  # (check * for the version number used to create the tarball)
1828    
1829  #------------------------------------------------------  #------------------------------------------------------
1830  # DEFAULT TARGETS  # DEFAULT TARGETS
1831    
1832  env.Default(['pygtk','tcltk98'])  default_targets =['libascend']
1833    if with_tcltk:
1834        default_targets.append('tcltk')
1835    if with_python:
1836        default_targets.append('pygtk')
1837    if with_installer:
1838        default_targets.append('installer')
1839    if with_extfns:
1840        default_targets.append('extfns')
1841    
1842    env.Default(default_targets)
1843    
1844    print "Building targets:"," ".join([str(i) for i in BUILD_TARGETS])
1845    
1846    # vim: set syntax=python:
1847    

Legend:
Removed from v.566  
changed lines
  Added in v.953

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