/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 993 by johnpye, Fri Dec 22 11:03:51 2006 UTC revision 1181 by johnpye, Sat Jan 20 03:50:21 2007 UTC
# Line 1  Line 1 
1  import sys, os, commands, platform, distutils.sysconfig, os.path, re  import sys, os, commands, platform, distutils.sysconfig, os.path, re
2    
3  version = "0.9.5.104"  version = "0.9.5.106"
4    
5  #------------------------------------------------------  #------------------------------------------------------
6  # OPTIONS  # OPTIONS
# Line 104  opts.Add(BoolOption( Line 104  opts.Add(BoolOption(
104      ,True      ,True
105  ))  ))
106    
107    opts.Add(BoolOption(
108        'WITH_SIGNALS'
109        ,"Whether to permit use of signals for flow control in the C-level code"
110        ,False
111    ))
112    
113  # You can turn off building of Tcl/Tk interface  # You can turn off building of Tcl/Tk interface
114  opts.Add(BoolOption(  opts.Add(BoolOption(
115      'WITH_TCLTK'      'WITH_TCLTK'
# Line 180  opts.Add(BoolOption( Line 186  opts.Add(BoolOption(
186      ,True      ,True
187  ))  ))
188    
189    
190    opts.Add(BoolOption(
191        'IDA_NEW_ANALYSE'
192        ,"Build with new IDA 'analyse' function? (see base/generic/solver/ida.c)"
193        ,False
194    ))
195    
196  #----- default paths -----  #----- default paths -----
197  opts.Add(PackageOption(  opts.Add(PackageOption(
198      'DEFAULT_PREFIX'      'DEFAULT_PREFIX'
# Line 481  opts.Add(BoolOption( Line 494  opts.Add(BoolOption(
494      ,False      ,False
495  ))  ))
496    
497    #------ mfgraph --------
498    opts.Add(PackageOption(
499        'MFGRAPH_PREFIX'
500        ,"Where are your MFGRAPH files?"
501        ,default_prefix
502    ))
503    
504    opts.Add(PackageOption(
505        'MFGRAPH_CPPPATH'
506        ,"Where are your MFGRAPH include files?"
507        ,default_cpppath
508    ))
509    
510    opts.Add(PackageOption(
511        'MFGRAPH_LIBPATH'
512        ,"Where are your MFGRAPH libraries?"
513        ,default_libpath
514    ))
515    
516    opts.Add(BoolOption(
517        'WITH_MFGRAPH'
518        ,"Link to the MFGRAPH library (if available) for debugging of memory usage."
519        ,True
520    ))
521    
522  #-----------------------  #-----------------------
523    
524  opts.Add(  opts.Add(
# Line 548  def c_escape(str): Line 586  def c_escape(str):
586  envadditional={}  envadditional={}
587    
588  if platform.system()=="Windows":  if platform.system()=="Windows":
589      if os.environ.get('OSTYPE')=='msys':      if os.environ.get('OSTYPE')=='msys' or os.environ.get('MSYSTEM'):
590          envenv = os.environ;          envenv = os.environ;
591          tools = ['mingw','lex','yacc','fortran','swig','disttar','nsis']          tools = ['mingw','lex','yacc','fortran','swig','disttar','nsis']
592          #TODO removed 'doxygen' for SCons 0.96.93          #TODO removed 'doxygen' for SCons 0.96.93
593          envadditional['IS_MINGW']=True          envadditional['IS_MINGW']=True
594      else:      else:
595            print "Assuming VC++ build environment (Note: MinGW is preferred)"
596          envenv = {          envenv = {
597              'PATH':os.environ['PATH']              'PATH':os.environ['PATH']
598              ,'INCLUDE':os.environ['INCLUDE']              ,'INCLUDE':os.environ['INCLUDE']
# Line 604  without_scrollkeeper_reason = "disabled Line 643  without_scrollkeeper_reason = "disabled
643  with_dmalloc = env.get('WITH_DMALLOC')  with_dmalloc = env.get('WITH_DMALLOC')
644  without_dmalloc_reason = "disabled by options/config.py"  without_dmalloc_reason = "disabled by options/config.py"
645    
646    with_mfgraph = env.get('WITH_MFGRAPH')
647    without_mfgraph_reason = "disabled by options/config.py"
648    
649  with_mmio = env.get('WITH_MMIO')  with_mmio = env.get('WITH_MMIO')
650  without_mmio_reason = "disabled by options/config.py"  without_mmio_reason = "disabled by options/config.py"
651    
652    with_signals = env.get('WITH_SIGNALS')
653    without_signals_reason = "disabled by options/config.py"
654    
655  if platform.system()=="Windows":  if platform.system()=="Windows":
656      with_installer=1      with_installer=1
657  else:  else:
# Line 642  if platform.system()=='Windows': Line 687  if platform.system()=='Windows':
687      can_install = False      can_install = False
688    
689  env['CAN_INSTALL']=can_install  env['CAN_INSTALL']=can_install
   
690  env['INSTALL_MODELS']=env['INSTALL_ASCDATA']+"/models/"  env['INSTALL_MODELS']=env['INSTALL_ASCDATA']+"/models/"
691    
692  print "TCL_CPPPATH =",env['TCL_CPPPATH']  print "TCL_CPPPATH =",env['TCL_CPPPATH']
# Line 870  def CheckYacc(context): Line 914  def CheckYacc(context):
914      return is_ok      return is_ok
915    
916  #----------------  #----------------
917    # LEX
918    
919    lex_test_text = """
920    %{
921    #include <stdio.h>
922    %}
923    DIGIT   [0-9]
924    ID      [a-z][a-z0-9]*
925    %%
926    {DIGIT}+    {
927            printf("A digit: %s\\n",yytext);
928        }
929    
930    [ \\t\\n]+    /* ignore */
931    
932    .           {
933            printf("Unrecognized guff");
934        }
935    %%
936    main(){
937        yylex();
938    }
939    """
940    
941    def CheckLex(context):
942        context.Message("Checking for Lex ('%s')... " % context.env.get('LEX'))
943        is_ok = context.TryCompile(lex_test_text,".l")
944        context.Result(is_ok)
945        return is_ok
946    
947    #----------------
948  # CUnit test  # CUnit test
949    
950  cunit_test_text = """  cunit_test_text = """
# Line 912  def CheckDMalloc(context): Line 987  def CheckDMalloc(context):
987      return CheckExtLib(context,'dmalloc',dmalloc_test_text)      return CheckExtLib(context,'dmalloc',dmalloc_test_text)
988    
989  #----------------  #----------------
990    # mfgraph test
991    
992    mfgraph_test_text = """
993    #include <mfgraph/mfg_draw_graph.h>
994    int main(void){
995        using namespace mfg;
996        DrawGraph g;
997        return 0;
998    }
999    """
1000    
1001    def CheckMFGraph(context):
1002        return CheckExtLib(context,'mfgraph',mfgraph_test_text,ext=".cpp")
1003    
1004    #----------------
1005  # MATH test  # MATH test
1006    
1007  math_test_text = """  math_test_text = """
# Line 1074  def CheckIDAVersion(context): Line 1164  def CheckIDAVersion(context):
1164          return 0          return 0
1165                    
1166      # good version      # good version
1167      context.Result(output+", good")      context.Result("%d.%d.%d, good" % (major,minor,patch))
1168      return 1      return 1
1169            
1170  #----------------  #----------------
# Line 1298  void sighandler(int sig){ Line 1388  void sighandler(int sig){
1388      longjmp(g_jmpenv,sig);      longjmp(g_jmpenv,sig);
1389  }  }
1390  void testsigint(){  void testsigint(){
1391      fprintf(stderr,"Raising SIGINT\n");      /* fprintf(stderr,"Raising SIGINT\n"); */
1392      raise(SIGINT);      raise(SIGINT);
1393  }  }
1394  int main(void){  int main(void){
1395      SigHandlerFn *last,*saved;      SigHandlerFn *last,*saved;
1396      saved = signal(SIGINT,&sighandler);      saved = signal(SIGINT,&sighandler);
1397      if(saved!=SIG_DFL){      if(saved!=SIG_DFL){
1398          fprintf(stderr,"Default handler was not correctly set\n");          fprintf(stderr,"Default handler (%p) was not correctly set\n",SIG_DFL);
1399          exit(3);          exit(3);
1400      }      }
1401      switch(setjmp(g_jmpenv)){      switch(setjmp(g_jmpenv)){
# Line 1318  int main(void){ Line 1408  int main(void){
1408          default:          default:
1409              exit(2);              exit(2);
1410      };      };
1411      last = signal(SIGINT,(saved!=NULL)?saved:SIG_DFL);      last = signal(SIGINT,SIG_DFL);
1412      if(last!=&sighandler){      if(last!=&sighandler){
1413          printf("1");          printf("1");
1414          exit(0);          exit(0);
# Line 1334  def CheckSigReset(context): Line 1424  def CheckSigReset(context):
1424      if not is_ok:      if not is_ok:
1425          context.Result("ERROR")          context.Result("ERROR")
1426          return 0          return 0
1427      if(int(output)):      if int(output)==1:
1428          context.Result("required");          context.Result("required");
1429          context.env['ASC_RESETNEEDED'] = True          context.env['ASC_RESETNEEDED'] = True
1430      else:      else:
# Line 1359  conf = Configure(env Line 1449  conf = Configure(env
1449          , 'CheckPythonLib' : CheckPythonLib          , 'CheckPythonLib' : CheckPythonLib
1450          , 'CheckCUnit' : CheckCUnit          , 'CheckCUnit' : CheckCUnit
1451          , 'CheckDMalloc' : CheckDMalloc          , 'CheckDMalloc' : CheckDMalloc
1452            , 'CheckMFGraph' : CheckMFGraph
1453          , 'CheckTcl' : CheckTcl          , 'CheckTcl' : CheckTcl
1454          , 'CheckTclVersion' : CheckTclVersion          , 'CheckTclVersion' : CheckTclVersion
1455          , 'CheckTk' : CheckTk          , 'CheckTk' : CheckTk
# Line 1366  conf = Configure(env Line 1457  conf = Configure(env
1457          , 'CheckGcc' : CheckGcc          , 'CheckGcc' : CheckGcc
1458          , 'CheckGccVisibility' : CheckGccVisibility          , 'CheckGccVisibility' : CheckGccVisibility
1459          , 'CheckYacc' : CheckYacc          , 'CheckYacc' : CheckYacc
1460            , 'CheckLex' : CheckLex
1461          , 'CheckTkTable' : CheckTkTable          , 'CheckTkTable' : CheckTkTable
1462          , 'CheckX11' : CheckX11          , 'CheckX11' : CheckX11
1463          , 'CheckIDA' : CheckIDA          , 'CheckIDA' : CheckIDA
# Line 1386  conf = Configure(env Line 1478  conf = Configure(env
1478  if not conf.CheckHeader('stdio.h'):  if not conf.CheckHeader('stdio.h'):
1479      print "CPPPATH =",env.get('CPPPATH')      print "CPPPATH =",env.get('CPPPATH')
1480      print "Did not find 'stdio.h'! Check your compiler configuration."      print "Did not find 'stdio.h'! Check your compiler configuration."
1481        print ""
1482        print "You environment is printed here:"
1483        for k,v in os.environ.iteritems():
1484            print "%-30s%s" % ("%s :" % k, v)
1485      Exit(1)      Exit(1)
1486    
1487  # Math library  # Math library
# Line 1414  if conf.CheckGcc(): Line 1510  if conf.CheckGcc():
1510    
1511  # Catching SIGINT  # Catching SIGINT
1512    
1513  if not conf.CheckSIGINT():  if env['WITH_SIGNALS']:
1514      print "SIGINT unable to be caught. Aborting."      if not conf.CheckSIGINT():
1515      exit(1)          with_signals = False
1516            without_signals_reason = "SIGINT uncatchable"
1517    
1518  # Catching SIGFPE  # Catching SIGFPE
1519    
# Line 1438  if not conf.CheckYacc(): Line 1535  if not conf.CheckYacc():
1535  else:  else:
1536      conf.env['HAVE_YACC']=True      conf.env['HAVE_YACC']=True
1537    
1538  conf.env['HAVE_LEX']=True  if not conf.CheckLex():
1539        print "YACC NOT FOUND OR NOT WORKING"
1540    else:
1541        conf.env['HAVE_LEX']=True
1542    
1543  # Tcl/Tk  # Tcl/Tk
1544    
# Line 1500  if with_dmalloc: Line 1600  if with_dmalloc:
1600          without_dmalloc_reason = 'dmalloc not found'          without_dmalloc_reason = 'dmalloc not found'
1601          with_dmalloc = False          with_dmalloc = False
1602    
1603    # DMALLOC
1604    
1605    if with_mfgraph:
1606        if not conf.CheckMFGraph():
1607            without_mfgraph_reason = 'mfgraph not found'
1608            with_mfgraph = False
1609            env['WITH_MFGRAPH'] = False
1610    
1611  # IDA  # IDA
1612    
1613  if not with_ida:  if not with_ida:
# Line 1631  subst_dict = { Line 1739  subst_dict = {
1739      , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')      , '@ASC_CONOPT_LIB@':env.get('CONOPT_LIB')
1740      , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')      , '@ASC_CONOPT_ENVVAR@':env.get('CONOPT_ENVVAR')
1741      , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_LIBPATH"))      , '@ASC_CONOPT_DLPATH@':c_escape(env.subst("$CONOPT_LIBPATH"))
1742      , '@SOURCE_ROOT@':os.path.abspath(str(env.Dir("#")))      , '@SOURCE_ROOT@':c_escape(os.path.abspath(str(env.Dir("#"))))
1743  }  }
1744    
1745  if env.get('WITH_LOCAL_HELP'):  if env.get('WITH_LOCAL_HELP'):
# Line 1640  if env.get('WITH_LOCAL_HELP'): Line 1748  if env.get('WITH_LOCAL_HELP'):
1748    
1749  # bool options...  # bool options...
1750  for k,v in {  for k,v in {
1751          'ABSOLUTE_PATHS' : 'ASC_ABSOLUTE_PATHS'          'ASC_WITH_IDA':with_ida
1752          ,'WITH_XTERM_COLORS' : 'ASC_XTERM_COLORS'          ,'ASC_WITH_DMALLOC':with_dmalloc
1753          ,'MALLOC_DEBUG' : 'MALLOC_DEBUG'          ,'ASC_WITH_MFGRAPH':with_mfgraph
1754  }.iteritems():          ,'ASC_WITH_CONOPT':with_conopt
1755      if env.get(k):          ,'ASC_WITH_LSODE':with_lsode
1756  #       subst_dict['@'+v+'@']='1'          ,'ASC_WITH_MMIO':with_mmio
1757          subst_dict["/\\* #define "+v+' @'+v+"@ \\*/"]='# define '+v+' 1 '          ,'ASC_SIGNAL_TRAPS':with_signals
1758            ,'ASC_RESETNEEDED':env.get('ASC_RESETNEEDED')
1759  if with_ida:          ,'HAVE_C99FPE':env.get('HAVE_C99FPE')
1760      subst_dict["/\\* #define ASC_WITH_IDA @ASC_WITH_IDA@ \\*/"]='#define ASC_WITH_IDA '          ,'ASC_ABSOLUTE_PATHS':env.get('ASC_ABSOLUTE_PATHS')
1761            ,'ASC_XTERM_COLORS':env.get('WITH_XTERM_COLORS')
1762  if with_dmalloc:          ,'MALLOC_DEBUG':env.get('MALLOC_DEBUG')
1763      subst_dict["/\\* #define ASC_WITH_DMALLOC @ASC_WITH_DMALLOC@ \\*/"]='#define ASC_WITH_DMALLOC '          }.iteritems():
1764            
1765  if with_conopt:      if v: subst_dict["/\\* #define %s @%s@ \\*/" % (k,k)]='# define %s 1 ' % k
     subst_dict["/\\* #define ASC_WITH_CONOPT @ASC_WITH_CONOPT@ \\*/"]='#define ASC_WITH_CONOPT '  
   
 if with_lsode:  
     subst_dict["/\\* #define ASC_WITH_LSODE @ASC_WITH_LSODE@ \\*/"]='#define ASC_WITH_LSODE '  
   
 if with_mmio:  
     subst_dict["/\\* #define ASC_WITH_MMIO @ASC_WITH_MMIO@ \\*/"]='#define ASC_WITH_MMIO '  
1766    
1767  if with_python:  if with_python:
1768      subst_dict['@ASCXX_USE_PYTHON@']="1"      subst_dict['@ASCXX_USE_PYTHON@']="1"
# Line 1670  if with_python: Line 1771  if with_python:
1771  if env.has_key('HAVE_GCCVISIBILITY'):  if env.has_key('HAVE_GCCVISIBILITY'):
1772      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
1773    
 if env.get('ASC_RESETNEEDED'):  
     subst_dict["/\\* #define ASC_RESETNEEDED @ASC_RESETNEEDED@ \\*/"]='#define ASC_RESETNEEDED '  
   
 if env.get('HAVE_C99FPE'):  
     subst_dict["/\\* #define HAVE_C99FPE @HAVE_C99FPE@ \\*/"]='#define HAVE_C99FPE '  
   
1774  env.Append(SUBST_DICT=subst_dict)  env.Append(SUBST_DICT=subst_dict)
1775    
1776  #------------------------------------------------------  #for k,v in subst_dict.iteritems():
1777  # RECIPE: Fix up long command-line bug on Win2k  #   print "%-50s%s" % ("'%s'"%k,v)
   
 # Currently this is broken, awaiting help from the SCons users list  
   
 if 0 and env['PLATFORM'] == 'win32':  
     import win32file  
     import win32event  
     import win32process  
     import win32security  
     import string  
   
     def my_spawn(sh, escape, cmd, args, spawnenv):  
         for var in spawnenv:  
             spawnenv[var] = spawnenv[var].encode('ascii', 'replace')  
   
         sAttrs = win32security.SECURITY_ATTRIBUTES()  
         StartupInfo = win32process.STARTUPINFO()  
         newargs = string.join(map(escape, args[1:]), ' ')  
         cmdline = cmd + " " + newargs  
   
         # check for any special operating system commands  
         if cmd == 'del':  
             for arg in args[1:]:  
                 win32file.DeleteFile(arg)  
             exit_code = 0  
         else:  
             # otherwise execute the command.  
             hProcess, hThread, dwPid, dwTid = win32process.CreateProcess(None, cmdline, None, None, 1, 0, spawnenv, None, StartupInfo)  
             win32event.WaitForSingleObject(hProcess, win32event.INFINITE)  
             exit_code = win32process.GetExitCodeProcess(hProcess)  
             win32file.CloseHandle(hProcess);  
             win32file.CloseHandle(hThread);  
         return exit_code  
1778    
1779      env['SPAWN'] = my_spawn  # REMOVED: long command-line support on Win2k
1780    
1781  #------------------------------------------------------  #------------------------------------------------------
1782  # RECIPE: SWIG scanner  # RECIPE: SWIG scanner
# Line 1758  def TOOL_SUBST(env): Line 1821  def TOOL_SUBST(env):
1821          except:          except:
1822              raise SCons.Errors.UserError, "Can't read source file %s"%sourcefile              raise SCons.Errors.UserError, "Can't read source file %s"%sourcefile
1823          for (k,v) in dict.items():          for (k,v) in dict.items():
1824              contents = re.sub(k, v, contents)              try:
1825                    #print "%s ---> %s" % (k,v)
1826                    contents = re.sub(k, v, contents)
1827                except Exception,e:
1828                    sys.stderr.write("Failed to substute '%s' with '%s': %s\n" % (k,v,e))
1829            
1830          try:          try:
1831              f = open(targetfile, 'wb')              f = open(targetfile, 'wb')
1832              f.write(contents)              f.write(contents)
# Line 1867  else: Line 1935  else:
1935    
1936  libascend_env = env.Copy()  libascend_env = env.Copy()
1937    
1938  dirs = ['general','utilities','compiler','solver','packages']  dirs = ['general','utilities','compiler','solver','integrator','packages']
1939    
1940  srcs = []  srcs = []
1941  for d in dirs:  for d in dirs:

Legend:
Removed from v.993  
changed lines
  Added in v.1181

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