/[ascend]/trunk/SConstruct
ViewVC logotype

Diff of /trunk/SConstruct

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

revision 965 by johnpye, Wed Dec 13 23:53:57 2006 UTC revision 968 by johnpye, Mon Dec 18 05:49:00 2006 UTC
# Line 1205  def CheckX11(context): Line 1205  def CheckX11(context):
1205      return CheckExtLib(context,'X11',x11_check_text)      return CheckExtLib(context,'X11',x11_check_text)
1206    
1207  #----------------  #----------------
1208    # Check that we can raise and catch sigint
1209    
1210    sigint_test_text = r"""
1211    #include <signal.h>
1212    #include <setjmp.h>
1213    #include <stdlib.h>
1214    static jmp_buf g_jmpenv;
1215    void sighandler(int sig){
1216        longjmp(g_jmpenv,sig);
1217    }
1218    void testsigint(){
1219        raise(SIGINT);
1220    }
1221    int main(void){
1222        signal(SIGINT,&sighandler);
1223        switch(setjmp(g_jmpenv)){
1224            case 0:
1225                testsigint();
1226                exit(1);
1227            case SIGINT:
1228                exit(0);
1229            default:
1230                exit(2);
1231        }
1232    }
1233    """
1234    
1235    def CheckSIGINT(context):
1236        context.Message("Checking SIGINT is catchable... ")
1237        (is_ok,output)=context.TryRun(sigint_test_text,".c")
1238        context.Result(is_ok)
1239        return is_ok
1240    
1241    #----------------
1242  # Check that we're able to catch floating point errors  # Check that we're able to catch floating point errors
1243    
1244  sigfpe_test_text = r"""  sigfpe_test_text = r"""
# Line 1235  int main(void){ Line 1269  int main(void){
1269  """  """
1270    
1271  def CheckFPE(context):  def CheckFPE(context):
1272      context.Message("Checking for C99 FPE behaviour... ")      context.Message("Checking C99 FPE behaviour... ")
1273      (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')      (is_ok,output) = context.TryRun(sigfpe_test_text,'.c')
1274      context.Result(is_ok)      context.Result(is_ok)
1275      return is_ok      return is_ok
1276    
1277  #----------------  #----------------
1278    # signal reset needed?
1279    
1280    sigreset_test_text = r"""
1281    #include <signal.h>
1282    #include <setjmp.h>
1283    #include <stdlib.h>
1284    #include <stdio.h>
1285    typedef void SigHandlerFn(int);
1286    static jmp_buf g_jmpenv;
1287    void sighandler(int sig){
1288        longjmp(g_jmpenv,sig);
1289    }
1290    void testsigint(){
1291        fprintf(stderr,"Raising SIGINT\n");
1292        raise(SIGINT);
1293    }
1294    int main(void){
1295        SigHandlerFn *last,*saved;
1296        saved = signal(SIGINT,&sighandler);
1297        if(saved!=SIG_DFL){
1298            fprintf(stderr,"Default handler was not correctly set\n");
1299            exit(3);
1300        }
1301        switch(setjmp(g_jmpenv)){
1302            case 0:
1303                testsigint();
1304                fprintf(stderr,"Back from SIGINT\n");
1305                exit(1);
1306            case SIGINT:
1307                break;
1308            default:
1309                exit(2);
1310        };
1311        last = signal(SIGINT,(saved!=NULL)?saved:SIG_DFL);
1312        if(last!=&sighandler){
1313            printf("1");
1314            exit(0);
1315        }
1316        printf("0");
1317        exit(0);
1318    }
1319    """
1320    
1321    def CheckSigReset(context):
1322        context.Message("Checking signal handler reset... ")
1323        (is_ok,output) = context.TryRun(sigreset_test_text,'.c')
1324        if not is_ok:
1325            context.Result("ERROR")
1326            return 0
1327        if(int(output)):
1328            context.Result("required");
1329            context.env['ASC_RESETNEEDED'] = True
1330        else:
1331            context.Result("not required");
1332            context.env['ASC_RESETNEEDED'] = False
1333        return is_ok
1334    
1335    #----------------
1336  # GCC Version sniffing  # GCC Version sniffing
1337    
1338  # TODO FIXME  # TODO FIXME
# Line 1271  conf = Configure(env Line 1363  conf = Configure(env
1363          , 'CheckCONOPT' : CheckCONOPT          , 'CheckCONOPT' : CheckCONOPT
1364          , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig          , 'CheckScrollkeeperConfig' : CheckScrollkeeperConfig
1365          , 'CheckFPE' : CheckFPE          , 'CheckFPE' : CheckFPE
1366            , 'CheckSIGINT' : CheckSIGINT
1367            , 'CheckSigReset' : CheckSigReset
1368  #       , 'CheckIsNan' : CheckIsNan  #       , 'CheckIsNan' : CheckIsNan
1369  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig  #       , 'CheckCppUnitConfig' : CheckCppUnitConfig
1370      }      }
# Line 1308  if conf.CheckGcc(): Line 1402  if conf.CheckGcc():
1402          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])          conf.env.Append(CPPDEFINES=['HAVE_GCCVISIBILITY'])
1403      conf.env.Append(CCFLAGS=['-Wall'])      conf.env.Append(CCFLAGS=['-Wall'])
1404    
1405    # Catching SIGINT
1406    
1407    if not conf.CheckSIGINT():
1408        print "SIGINT unable to be caught. Aborting."
1409        exit(1)
1410    
1411  # Catching SIGFPE  # Catching SIGFPE
1412    
1413  if conf.CheckFPE():  if conf.CheckFPE():
1414      conf.env['HAVE_SIGFPE']=True      conf.env['HAVE_C99FPE']=True
1415  else:  else:
1416      conf.env['HAVE_SIGFPE']=False      conf.env['HAVE_C99FPE']=False
1417    
1418    # Checking for signal reset requirement
1419    
1420    if not conf.CheckSigReset():
1421        print "Unable to determine if signal reset is required"
1422        exit(1)
1423    
1424  # YACC  # YACC
1425    
# Line 1549  if with_python: Line 1655  if with_python:
1655  if env.has_key('HAVE_GCCVISIBILITY'):  if env.has_key('HAVE_GCCVISIBILITY'):
1656      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"      subst_dict['@HAVE_GCCVISIBILITY@'] = "1"
1657    
1658    if env.get('ASC_RESETNEEDED'):
1659        subst_dict["/\\* #define ASC_RESETNEEDED @ASC_RESETNEEDED@ \\*/"]='#define ASC_RESETNEEDED '
1660    
1661    if env.get('HAVE_C99FPE'):
1662        subst_dict["/\\* #define HAVE_C99FPE @HAVE_C99FPE@ \\*/"]='#define HAVE_C99FPE '
1663    
1664  env.Append(SUBST_DICT=subst_dict)  env.Append(SUBST_DICT=subst_dict)
1665    
1666  #------------------------------------------------------  #------------------------------------------------------

Legend:
Removed from v.965  
changed lines
  Added in v.968

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