Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    ra5121bf rdfb7c96  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jul 13 17:40:12 2018
    13 // Update Count     : 258
     12// Last Modified On : Thu Aug 23 15:41:55 2018
     13// Update Count     : 270
    1414//
    1515
     
    4343const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    4444
    45 bool suffix( string arg ) {
     45void suffix( string arg, const char * args[], int & nargs ) {
    4646        //std::cerr << arg << std::endl;
    4747        size_t dot = arg.find_last_of( "." );
    4848        //std::cerr << dot << " " << (dot != string::npos ? arg.substr( dot + 1 ) : "fred" ) << std::endl;
    49         if ( dot == string::npos ) return false;
     49        if ( dot == string::npos ) return;
    5050        string sx = arg.substr( dot + 1 );
    5151        for ( int i = 0; i < NumSuffixes; i += 1 ) {
    52                 if ( sx == suffixes[i] ) return true;
     52                if ( sx == suffixes[i] ) {
     53                        args[nargs] = "-x";
     54                        nargs += 1;
     55                        args[nargs] = "c";
     56                        nargs += 1;
     57                        return;
     58                } // if
    5359        } // for
    54         return false;
    5560} // suffix
    5661
     
    8691        string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
    8792
    88         string installincdir( CFA_INCDIR );                         // fixed location of include files
    89         string installlibdir( CFA_LIBDIR );                         // fixed location of cc1 and cfa-cpp commands when installed
    90         string srcdriverdir ( TOP_BUILDDIR "driver");                // fixed location of cc1 and cfa-cpp commands when in tree
     93        string installincdir( CFA_INCDIR );                                     // fixed location of include files
     94        string installlibdir( CFA_LIBDIR );                                     // fixed location of cc1 and cfa-cpp commands when installed
     95        string srcdriverdir ( TOP_BUILDDIR "driver");           // fixed location of cc1 and cfa-cpp commands when in tree
    9196
    9297        string heading;                                                                         // banner printed at start of cfa compilation
     
    178183                                if ( i == argc ) continue;                              // next argument available ?
    179184                                compiler_path = argv[i];
    180                                 if ( putenv( (char *)( *new string( string( "__U_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {
     185                                if ( putenv( (char *)( *new string( string( "__CFA_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {
    181186                                        cerr << argv[0] << " error, cannot set environment variable." << endl;
    182187                                        exit( EXIT_FAILURE );
     
    294299                } else {
    295300                        bool opt = false;
    296                         if ( ! xflag && suffix( arg ) ) {
    297                                 args[nargs] = "-x";
    298                                 nargs += 1;
    299                                 args[nargs] = "c";
    300                                 nargs += 1;
     301                        if ( ! xflag ) {
     302                                suffix( arg, args, nargs );                             // check suffix
    301303                                // args[nargs] = ( *new string( string("-D__GCC_X__=c") ) ).c_str(); // add the argument for -x
    302304                                // nargs += 1;
     
    341343                args[nargs] = "-I" CFA_INCDIR;
    342344                nargs += 1;
    343                 if ( ! noincstd_flag ) {                                                        // do not use during build
    344                         args[nargs] = "-I" CFA_INCDIR "/stdhdr";
     345                if ( ! noincstd_flag ) {                                                // do not use during build
     346                        args[nargs] = "-I" CFA_INCDIR "stdhdr";
    345347                        nargs += 1;
    346348                } // if
    347                 args[nargs] = "-I" CFA_INCDIR "/concurrency";
    348                 nargs += 1;
    349                 args[nargs] = "-I" CFA_INCDIR "/containers";
     349                args[nargs] = "-I" CFA_INCDIR "concurrency";
     350                nargs += 1;
     351                args[nargs] = "-I" CFA_INCDIR "containers";
    350352                nargs += 1;
    351353        } else {
    352354                args[nargs] = "-I" TOP_SRCDIR "libcfa/src";
    353355                nargs += 1;
    354                 if ( ! noincstd_flag ) {                                                        // do not use during build
     356                if ( ! noincstd_flag ) {                                                // do not use during build
    355357                        args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
    356358                        nargs += 1;
     
    361363                nargs += 1;
    362364        }
     365
     366        // add stdbool to get defines for bool/true/false
     367        args[nargs] = "-imacros";
     368        nargs += 1;
     369        args[nargs] = "stdbool.h";
     370        nargs += 1;
    363371
    364372        string libbase;
     
    371379        }
    372380
    373         const char * const arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
     381        string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
     382        if ( ! m32 && ! m64 && arch == "x86" ) {                        // no override and 32-bit architecture
     383                args[nargs] = "-m32";
     384                nargs += 1;
     385        } // if
    374386        const char * config = debug ? "debug": "nodebug";
    375387        string libdir = libbase + arch + "-" + config;
    376         if( !dirExists(libdir) ) {
     388
     389        if ( ! dirExists( libdir ) ) {
    377390                cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
    378391                cerr << "Was looking for " << libdir << endl;
    379392                libdir = libbase + arch + "-" + "nolib";
    380         }
    381 
    382         if( !dirExists(libdir) ) {
     393        } // if
     394
     395        if ( ! dirExists( libdir ) ) {
    383396                cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
    384397                cerr << "Was looking for " << libdir << endl;
    385398                exit( EXIT_FAILURE );
    386         }
     399        } // if
    387400
    388401        args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str();
     
    401414                nargs += 1;
    402415                args[nargs] = "--undefined=__cfaabi_appready_startup";
     416                nargs += 1;
     417                args[nargs] = "-Xlinker";
     418                nargs += 1;
     419                args[nargs] = "--undefined=__cfaabi_dbg_record";
    403420                nargs += 1;
    404421
     
    460477
    461478        if ( Bprefix.length() == 0 ) {
    462                 Bprefix = !intree ? installlibdir : srcdriverdir;
     479                Bprefix = ! intree ? installlibdir : srcdriverdir;
     480                if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/';
    463481                args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
    464482                nargs += 1;
     
    494512                args[nargs] = "-D__int8_t_defined";                             // prevent gcc type-size attributes
    495513                nargs += 1;
    496                 args[nargs] = ( *new string( string("-B") + Bprefix + "/" ) ).c_str();
     514                args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str();
    497515                nargs += 1;
    498516                args[nargs] = "-lm";
Note: See TracChangeset for help on using the changeset viewer.