/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 672 by johnpye, Wed Jun 14 10:43:59 2006 UTC revision 673 by johnpye, Wed Jun 21 09:26:49 2006 UTC
# Line 24  if platform.system()=="Windows": Line 24  if platform.system()=="Windows":
24          default_tcl_libpath="$TCL\\lib"          default_tcl_libpath="$TCL\\lib"
25      default_rel_distdir = '.'      default_rel_distdir = '.'
26      default_absolute_paths = False      default_absolute_paths = False
27        default_ida_prefix = "c:/mingw"
28        need_libm = False
29  else:  else:
30      default_tcl_lib = "tcl8.3"      default_tcl_lib = "tcl8.4"
31      default_tk_lib = "tk8.3"      default_tk_lib = "tk8.4"
32      default_tktable_lib = "Tktable2.8"      default_tktable_lib = "Tktable2.8"
33      default_install_assets = "$INSTALL_ASCDATA/glade/"      default_install_assets = "$INSTALL_ASCDATA/glade/"
34      icon_extension = '.svg'      icon_extension = '.svg'
# Line 34  else: Line 36  else:
36      default_tcl_libpath = "$TCL/lib"          default_tcl_libpath = "$TCL/lib"    
37      default_rel_distdir = '../share/ascend'      default_rel_distdir = '../share/ascend'
38      default_absolute_paths = True      default_absolute_paths = True
39        default_ida_prefix="/usr/local"
40        need_libm = True
41      if not os.path.isdir(default_tcl):      if not os.path.isdir(default_tcl):
42          default_tcl = '/usr'          default_tcl = '/usr'
43    
# Line 73  opts.Add(BoolOption( Line 76  opts.Add(BoolOption(
76  # You can turn off building of Tcl/Tk interface  # You can turn off building of Tcl/Tk interface
77  opts.Add(BoolOption(  opts.Add(BoolOption(
78      'WITH_TCLTK'      'WITH_TCLTK'
79      ,"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."
80      , True      , True
81  ))  ))
82    
83  # You can turn off the building of the Python interface  # You can turn off the building of the Python interface
84  opts.Add(BoolOption(  opts.Add(BoolOption(
85      'WITH_PYTHON'      'WITH_PYTHON'
86      ,"Set to True if you don't want to build Python wrappers."      ,"Set to False if you don't want to build Python wrappers."
87      , True      , True
88  ))  ))
89    
# Line 89  opts.Add(ListOption( Line 92  opts.Add(ListOption(
92      'WITH_SOLVERS'      'WITH_SOLVERS'
93      ,"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"  
94          +" works."          +" works."
95      ,["QRSLV","CMSLV"]      ,["QRSLV","CMSLV","LSOD","IDA"]
96      ,['QRSLV','MPS','SLV','OPTSQP'      ,['QRSLV','MPS','SLV','OPTSQP'
97          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'          ,'NGSLV','CMSLV','LRSLV','MINOS','CONOPT'
98          ,'LSOD','OPTSQP'          ,'LSOD','OPTSQP',"IDA"
99       ]       ]
100  ))  ))
101    
# Line 153  opts.Add(PackageOption( Line 156  opts.Add(PackageOption(
156      ,'off'      ,'off'
157  ))  ))
158    
159    opts.Add(PackageOption(
160        "IDA_PREFIX"
161        ,"Prefix for your IDA install (IDA ./configure --prefix)"
162        ,default_ida_prefix
163    ))
164    
165    opts.Add(
166        'IDA_CPPPATH'
167        ,"Where is your ida.h?"
168        ,"$IDA_PREFIX/include"
169    )
170    
171    opts.Add(
172        'IDA_LIBPATH'
173        ,"Where are your SUNDIALS libraries installed?"
174        ,"$IDA_PREFIX/lib"
175    )
176    
177    opts.Add(
178        "IDA_LIB"
179        ,"What libraries to link to for use of IDA (comma-separated). Note that"
180            +" you will need to include the math library in this list (for now)."
181        ,'sundials_ida,sundials_nvecserial,m'
182    )
183    
184    opts.Add(
185        "F2C_LIB"
186        ,"F2C library (eg. g2c, gfortran, f2c)"
187        ,"g2c"
188    )
189    
190    opts.Add(PackageOption(
191        "F2C_LIBPATH"
192        ,"Directory containing F2C library (i.e. g2c, gfortran, f2c, etc.), if not already accessible"
193        ,"off"
194    ))
195    
196  opts.Add(  opts.Add(
197      'TCL'      'TCL'
# Line 400  else: Line 439  else:
439      with_installer=0      with_installer=0
440      without_installer_reason = "only possible under Windows"      without_installer_reason = "only possible under Windows"
441    
442    if 'LSOD' in env['WITH_SOLVERS']:
443        with_lsode=True
444    else:
445        with_lsode=False
446        without_lsode_reason = "not requested (WITH_SOLVERS)"
447        
448    if 'IDA' in env['WITH_SOLVERS']:
449        with_ida=True
450    else:
451        with_ida=False
452        without_ida_reason = "not requested (WITH_SOLVERS)"
453    
454    
455  #print "SOLVERS:",env['WITH_SOLVERS']  #print "SOLVERS:",env['WITH_SOLVERS']
456  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']  #print "WITH_BINTOKEN:",env['WITH_BINTOKEN']
457  #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']  #print "DEFAULT_ASCENDLIBRARY:",env['DEFAULT_ASCENDLIBRARY']
# Line 415  print "TCL_LIBPATH =",env['TCL_LIBPATH'] Line 467  print "TCL_LIBPATH =",env['TCL_LIBPATH']
467  print "TCL_LIB =",env['TCL_LIB']  print "TCL_LIB =",env['TCL_LIB']
468  print "CC =",env['CC']  print "CC =",env['CC']
469  print "CXX =",env['CXX']  print "CXX =",env['CXX']
470    print "FORTRAN=",env.get('FORTRAN')
471    
472  print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']  print "ABSOLUTE PATHS =",env['ABSOLUTE_PATHS']
473  #------------------------------------------------------  #------------------------------------------------------
# Line 634  def CheckCUnit(context): Line 687  def CheckCUnit(context):
687      return CheckExtLib(context,'cunit',cunit_test_text)      return CheckExtLib(context,'cunit',cunit_test_text)
688    
689  #----------------  #----------------
690    # MATH test
691    
692    math_test_text = """
693    #include <math.h>
694    int main(void){
695        double x;
696        x = sinh(0.1);
697        return 0;
698    }
699    """
700    
701    def CheckMath(context):
702        return CheckExtLib(context,'m',math_test_text)
703    #----------------
704    # IDA test
705    
706    ida_test_text = """
707    #include <ida.h>
708    #include <nvector_serial.h>
709    #include <ida_spgmr.h>
710    int main(){
711        void *ida_mem;
712        ida_mem = IDACreate();
713    }
714    """
715    
716    def CheckIDA(context):
717        context.Message( 'Checking for IDA (SUNDIALS)... ' )
718        
719        # add SUNDIALS subdirectories as well (what a pain)
720        if context.env.get('IDA_CPPPATH'):
721            extra = [context.env['IDA_CPPPATH']+"/ida",context.env['IDA_CPPPATH']+"/sundials"]
722            context.env.Append(CPPPATH=extra)
723        
724        if ',' in context.env.get('IDA_LIB'):
725            context.env['IDA_LIB']=context.env['IDA_LIB'].split(',')
726            #print "IDA_LIB NOW =",context.env['IDA_LIB']
727        else:
728            print "NO COMMA IN IDA_LIB:",context.env['IDA_LIB']
729    
730        keep = KeepContext(context,"IDA")
731        
732        is_ok = context.TryLink(ida_test_text,".c")
733        context.Result(is_ok)
734        
735        keep.restore(context)
736        
737        if is_ok:
738            context.env.Append(IDA_CPPPATH_EXTRA=extra)
739        
740        return is_ok
741    
742    #----------------
743  # Tcl test  # Tcl test
744    
745  # 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 683  int main(void){ Line 789  int main(void){
789  }  }
790  """  """
791  def CheckTk(context):  def CheckTk(context):
792      return CheckExtLib(context,'tk',tcl_check_text,static=env['STATIC_TCLTK'])      return CheckExtLib(context,'tk',tk_check_text,static=env['STATIC_TCLTK'])
793    
794    
795  def CheckTkVersion(context):  def CheckTkVersion(context):
# Line 751  gcc_version4 = False Line 857  gcc_version4 = False
857    
858  conf = Configure(env  conf = Configure(env
859      , custom_tests = {      , custom_tests = {
860          'CheckSwigVersion' : CheckSwigVersion          'CheckMath' : CheckMath
861            , 'CheckSwigVersion' : CheckSwigVersion
862          , 'CheckCUnit' : CheckCUnit          , 'CheckCUnit' : CheckCUnit
863          , 'CheckTcl' : CheckTcl          , 'CheckTcl' : CheckTcl
864          , 'CheckTclVersion' : CheckTclVersion          , 'CheckTclVersion' : CheckTclVersion
# Line 762  conf = Configure(env Line 869  conf = Configure(env
869          , 'CheckYacc' : CheckYacc          , 'CheckYacc' : CheckYacc
870          , 'CheckTkTable' : CheckTkTable          , 'CheckTkTable' : CheckTkTable
871          , 'CheckX11' : CheckX11          , 'CheckX11' : CheckX11
872            , 'CheckIDA' : CheckIDA
873  #       , 'CheckIsNan' : CheckIsNan  #       , 'CheckIsNan' : CheckIsNan
874  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig
875      }      }
# Line 771  conf = Configure(env Line 879  conf = Configure(env
879    
880  # Math library  # Math library
881    
882  #if not conf.CheckFunc('sinh') and not conf.CheckLibWithHeader(['m','c','libc'], 'math.h', 'C'):  if need_libm:
883  #   print 'Did not find math library, exiting!'      if not conf.CheckMath():
884  #   Exit(1)          print 'Did not find math library, exiting!'
885            Exit(1)
886        #pass
887    
888  # Where is 'isnan'?  # Where is 'isnan'?
889    
# Line 850  if with_cunit: Line 960  if with_cunit:
960          without_cunit_reason = 'CUnit not found'          without_cunit_reason = 'CUnit not found'
961          with_cunit = False          with_cunit = False
962    
963    # IDA
964    
965    if not with_ida:
966        without_ida_reason = "Not selected (see config option WITH_SOLVERS)"
967    elif not conf.CheckIDA():
968        with_ida = False
969        without_ida_reason = "IDA not found"
970    
971  # BLAS  # BLAS
972    
973  need_blas=False  need_blas=False
974  if with_tcltk:  
975    if with_lsode:
976        need_fortran = True
977      need_blas=True      need_blas=True
978    
979  if need_blas:  if need_blas:
980      if conf.CheckLib('blas'):      if conf.CheckLib('blas'):
981          with_local_blas = False          with_local_blas = False
# Line 862  if need_blas: Line 983  if need_blas:
983      else:      else:
984          with_local_blas = True          with_local_blas = True
985          need_fortran = True          need_fortran = True
986    else:
987        with_local_blas= False;
988        without_local_blas_reason = "BLAS not required"
989    
990  # FORTRAN  # FORTRAN
991    
# Line 870  if need_fortran: Line 994  if need_fortran:
994      detect_fortran = conf.env.Detect(['g77','f77','gfortran'])      detect_fortran = conf.env.Detect(['g77','f77','gfortran'])
995      if detect_fortran:      if detect_fortran:
996          # For some reason, g77 doesn't get detected properly on MinGW          # For some reason, g77 doesn't get detected properly on MinGW
997          if not env.has_key('F77'):          if not env.has_key('F77') and not env.has_key('FORTRAN'):
998              conf.env.Replace(F77=detect_fortran)              conf.env.Replace(F77=detect_fortran)
999              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')              conf.env.Replace(F77COM='$F77 $F77FLAGS -c -o $TARGET $SOURCE')
1000              conf.env.Replace(F77FLAGS='')              conf.env.Replace(F77FLAGS='')
# Line 884  if need_fortran: Line 1008  if need_fortran:
1008              )              )
1009              conf.env.Append(BUILDERS={'Fortran':fortran_builder})              conf.env.Append(BUILDERS={'Fortran':fortran_builder})
1010      else:      else:
1011          with_tcltk=False;          with_lsode=False;
1012          without_tcltk_reason="FORTRAN-77 required but not found"          without_lsode_reason="FORTRAN-77 required but not found"
1013    
1014  #else:  #else:
1015  #   print "FORTRAN not required"  #   print "FORTRAN not required"
1016    
1017    # F2C
1018    
1019    if need_fortran:
1020        if platform.system()=="Windows":
1021            conf.env.Append(LIBPATH='c:\mingw\lib')
1022    
1023    
1024  # TODO: -D_HPUX_SOURCE is needed  # TODO: -D_HPUX_SOURCE is needed
1025    
1026  # TODO: check size of void*  # TODO: check size of void*
# Line 945  if env.get('WITH_LOCAL_HELP'): Line 1076  if env.get('WITH_LOCAL_HELP'):
1076      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']      subst_dict['@HELP_ROOT@']=env['WITH_LOCAL_HELP']
1077    
1078  # bool options...  # bool options...
1079  for k,v in { \  for k,v in {
1080          'ABSOLUTE_PATHS' : 'ASC_ABSOLUTE_PATHS', \          'ABSOLUTE_PATHS' : 'ASC_ABSOLUTE_PATHS'
1081          'WITH_XTERM_COLORS' : 'ASC_XTERM_COLORS', \          ,'WITH_XTERM_COLORS' : 'ASC_XTERM_COLORS'
1082          'MALLOC_DEBUG' : 'MALLOC_DEBUG' \          ,'MALLOC_DEBUG' : 'MALLOC_DEBUG'
1083  }.iteritems():  }.iteritems():
1084      if env.get(k):      if env.get(k):
1085          subst_dict['ifdef '+v]="if 1"  #       subst_dict['@'+v+'@']='1'
1086            subst_dict["/\\* #define "+v+' @'+v+"@ \\*/"]='# define '+v+' 1 '
1087    
1088    if with_ida:
1089        subst_dict["/\\* #define ASC_WITH_IDA @ASC_WITH_IDA@ \\*/"]='#define ASC_WITH_IDA '
1090    
1091    if with_lsode:
1092        subst_dict["/\\* #define ASC_WITH_LSODE @ASC_WITH_LSODE@ \\*/"]='#define ASC_WITH_LSODE '
1093    
1094  if with_python:  if with_python:
1095      subst_dict['@ASCXX_USE_PYTHON@']="1"      subst_dict['@ASCXX_USE_PYTHON@']="1"
1096        env['WITH_PYTHON']=1;
1097    
1098  if env.has_key('HAVE_GCCVISIBILITY'):  if env.has_key('HAVE_GCCVISIBILITY'):
1099      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
# Line 1089  if env['GCOV']: Line 1228  if env['GCOV']:
1228          , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']          , LINKFLAGS=['-fprofile-arcs','-ftest-coverage']
1229      )      )
1230    
1231    if with_ida:
1232        env.Append(WITH_IDA=1)
1233    
1234  #-------------  #-------------
1235  # TCL/TK GUI  # TCL/TK GUI
1236    
1237  if with_tcltk:  if with_tcltk:
     if with_local_blas:  
         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')  
1238      env.SConscript(['tcltk/generic/interface/SConscript'],'env')      env.SConscript(['tcltk/generic/interface/SConscript'],'env')
1239  else:  else:
1240      print "Skipping... Tcl/Tk GUI isn't being built:",without_tcltk_reason      print "Skipping... Tcl/Tk GUI isn't being built:",without_tcltk_reason
# Line 1116  else: Line 1250  else:
1250  #------------  #------------
1251  # BASE/GENERIC SUBDIRECTORIES  # BASE/GENERIC SUBDIRECTORIES
1252    
1253    libascend_env = env.Copy()
1254    
1255  dirs = ['general','utilities','compiler','solver','packages']  dirs = ['general','utilities','compiler','solver','packages']
1256    
1257  srcs = []  srcs = []
1258  for d in dirs:  for d in dirs:
1259      heresrcs = env.SConscript('base/generic/'+d+'/SConscript','env')      heresrcs = libascend_env.SConscript('base/generic/'+d+'/SConscript','libascend_env')
1260      srcs += heresrcs      srcs += heresrcs
1261    
1262  #-------------  #-------------
1263    # IMPORTED CODE: LSODE, BLAS, etc
1264    
1265    if with_lsode:
1266        srcs += env.SConscript(['lsod/SConscript'],'env')
1267        srcs += env.SConscript(['linpack/SConscript'],'env')
1268    else:
1269        print "Skipping... LSODE won't be built:", without_lsode_reason
1270    
1271    if with_local_blas:
1272        srcs += env.SConscript(['blas/SConscript'],'env')
1273    else:
1274        print "Skipping... BLAS won't be built:", without_local_blas_reason
1275    
1276    if not with_ida:
1277        print "Skipping... IDA won't be built:", without_ida_reason
1278    
1279    #-------------
1280  # LIBASCEND -- all base/generic functionality  # LIBASCEND -- all base/generic functionality
1281    
1282  libascend = env.SharedLibrary('ascend',srcs)  libascend = libascend_env.SharedLibrary('ascend',srcs)
1283    
1284    env.Alias('libascend',libascend)
1285    
1286  #-------------  #-------------
1287  # UNIT TESTS  # UNIT TESTS
# Line 1174  else: Line 1329  else:
1329      print "Skipping... Windows installer isn't being built:",without_installer_reason      print "Skipping... Windows installer isn't being built:",without_installer_reason
1330    
1331  #------------------------------------------------------  #------------------------------------------------------
1332    # PROJECT FILE for MSVC
1333    
1334    env.SConscript(['base/msvc/SConscript'],['env','libascend']);
1335    
1336    #------------------------------------------------------
1337  # CREATE the SPEC file for generation of RPM packages  # CREATE the SPEC file for generation of RPM packages
1338    
1339  if platform.system()=="Linux":  if platform.system()=="Linux":
# Line 1201  tar = env.DistTar("dist/"+env['DISTTAR_N Line 1361  tar = env.DistTar("dist/"+env['DISTTAR_N
1361  #------------------------------------------------------  #------------------------------------------------------
1362  # DEFAULT TARGETS  # DEFAULT TARGETS
1363    
1364  default_targets =[]  default_targets =['libascend']
1365  if with_tcltk:  if with_tcltk:
1366      default_targets.append('tcltk')      default_targets.append('tcltk')
1367  if with_python:  if with_python:

Legend:
Removed from v.672  
changed lines
  Added in v.673

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