Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • driver/cfa.cc

    r13a984c r8bdc1c36  
    1010// Created On       : Tue Aug 20 13:44:49 2002
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Sep  3 16:47:59 2018
    13 // Update Count     : 275
     12// Last Modified On : Fri Aug 10 18:17:58 2018
     13// Update Count     : 259
    1414//
    1515
     
    4343const string suffixes[NumSuffixes] = { "cfa", "hfa", };
    4444
    45 bool suffix( string arg, const char * args[], int & nargs ) {
     45bool suffix( string arg ) {
    4646        //std::cerr << arg << std::endl;
    4747        size_t dot = arg.find_last_of( "." );
     
    5050        string sx = arg.substr( dot + 1 );
    5151        for ( int i = 0; i < NumSuffixes; i += 1 ) {
    52                 if ( sx == suffixes[i] ) {
    53                         args[nargs] = "-x";
    54                         nargs += 1;
    55                         args[nargs] = "c";
    56                         nargs += 1;
    57                         return true;
    58                 } // if
     52                if ( sx == suffixes[i] ) return true;
    5953        } // for
    6054        return false;
     
    9286        string Major( str( CFA_VERSION_MAJOR ) ), Minor( str( CFA_VERSION_MINOR ) ), Patch( str( CFA_VERSION_PATCH ) );
    9387
    94         string installincdir( CFA_INCDIR );                                     // fixed location of include files
    95         string installlibdir( CFA_LIBDIR );                                     // fixed location of cc1 and cfa-cpp commands when installed
    96         string srcdriverdir ( TOP_BUILDDIR "driver");           // fixed location of cc1 and cfa-cpp commands when in tree
     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
    9791
    9892        string heading;                                                                         // banner printed at start of cfa compilation
     
    129123        #ifdef __DEBUG_H__
    130124        cerr << "CFA:" << endl;
     125        #endif // __DEBUG_H__
     126
     127        // process command-line arguments
     128
    131129        for ( int i = 1; i < argc; i += 1 ) {
    132             cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
    133         } // for
    134         #endif // __DEBUG_H__
    135 
    136         // process command-line arguments
    137 
    138         for ( int i = 1; i < argc; i += 1 ) {
     130                #ifdef __DEBUG_H__
     131                cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl;
     132                #endif // __DEBUG_H__
    139133                arg = argv[i];                                                                  // convert to string value
     134                #ifdef __DEBUG_H__
     135                cerr << "arg:\"" << arg << "\"" << endl;
     136                #endif // __DEBUG_H__
    140137                if ( prefix( arg, "-" ) ) {
    141138                        // pass through arguments
     
    181178                                if ( i == argc ) continue;                              // next argument available ?
    182179                                compiler_path = argv[i];
    183                                 if ( putenv( (char *)( *new string( string( "__CFA_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {
     180                                if ( putenv( (char *)( *new string( string( "__U_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) {
    184181                                        cerr << argv[0] << " error, cannot set environment variable." << endl;
    185182                                        exit( EXIT_FAILURE );
     
    200197                                args[nargs] = argv[i];                                  // pass the argument along
    201198                                nargs += 1;
     199                        } else if ( arg == "-x" ) {
     200                                xflag = true;
     201                                args[nargs] = argv[i];                                  // pass the argument along
     202                                nargs += 1;
     203                                i += 1;                                                                 // advance to argument
     204                                args[nargs] = argv[i];                                  // pass the argument along
     205                                nargs += 1;
     206                                // args[nargs] = ( *new string( string("-D__GCC_X__=") + argv[i] ) ).c_str(); // add the argument for -x
     207                                // nargs += 1;
     208                        } else if ( prefix( arg, "-x" ) ) {
     209                                xflag = true;
     210                                args[nargs] = argv[i];                                  // pass the argument along
     211                                nargs += 1;
     212                                // args[nargs] = ( *new string( string("-D__GCC_X__=") + arg.substr(2) ) ).c_str(); // add the argument for -x
     213                                // nargs += 1;
    202214                        } else if ( arg == "-w" ) {
    203215                                args[nargs] = argv[i];                                  // pass the argument along
     
    281293                        } // if
    282294                } else {
    283                         bool cfa = suffix( arg, args, nargs );          // check suffix
    284                         args[nargs] = argv[i];                                          // concatenate file
     295                        bool opt = false;
     296                        if ( ! xflag && suffix( arg ) ) {
     297                                args[nargs] = "-x";
     298                                nargs += 1;
     299                                args[nargs] = "c";
     300                                nargs += 1;
     301                                // args[nargs] = ( *new string( string("-D__GCC_X__=c") ) ).c_str(); // add the argument for -x
     302                                // nargs += 1;
     303                                opt = true;
     304                        } // if
     305                        // concatenate other arguments
     306                        args[nargs] = argv[i];
    285307                        nargs += 1;
    286                         if ( cfa ) {
     308                        if ( opt ) {
    287309                                args[nargs] = "-x";
    288310                                nargs += 1;
    289311                                args[nargs] = "none";
    290312                                nargs += 1;
     313                                // args[nargs] = ( *new string( string("-D__GCC_X__=none") ) ).c_str(); // add the argument for -x
     314                                // nargs += 1;
    291315                        } // if
    292316                        nonoptarg = true;
     
    294318                } // if
    295319        } // for
    296 
    297     args[nargs] = "-x";                                 // turn off language
    298     nargs += 1;
    299     args[nargs] = "none";
    300     nargs += 1;
    301320
    302321        #ifdef __x86_64__
     
    322341                args[nargs] = "-I" CFA_INCDIR;
    323342                nargs += 1;
    324                 if ( ! noincstd_flag ) {                                                // do not use during build
    325                         args[nargs] = "-I" CFA_INCDIR "stdhdr";
     343                if ( ! noincstd_flag ) {                                                        // do not use during build
     344                        args[nargs] = "-I" CFA_INCDIR "/stdhdr";
    326345                        nargs += 1;
    327346                } // if
    328                 args[nargs] = "-I" CFA_INCDIR "concurrency";
    329                 nargs += 1;
    330                 args[nargs] = "-I" CFA_INCDIR "containers";
     347                args[nargs] = "-I" CFA_INCDIR "/concurrency";
     348                nargs += 1;
     349                args[nargs] = "-I" CFA_INCDIR "/containers";
    331350                nargs += 1;
    332351        } else {
    333352                args[nargs] = "-I" TOP_SRCDIR "libcfa/src";
    334353                nargs += 1;
    335                 if ( ! noincstd_flag ) {                                                // do not use during build
     354                if ( ! noincstd_flag ) {                                                        // do not use during build
    336355                        args[nargs] = "-I" TOP_SRCDIR "libcfa/src" "/stdhdr";
    337356                        nargs += 1;
     
    358377        }
    359378
    360         string arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
    361         if ( ! m32 && ! m64 ) {
    362                 if ( arch == "x86" ) {
    363                         args[nargs] = "-m32";
    364                         nargs += 1;
    365                 } else if ( arch == "x64" ) {
    366                         args[nargs] = "-m64";
    367                         nargs += 1;
    368                 }  // if
    369         } // if
     379        const char * const arch = m32 ? CFA_32_CPU : (m64 ? CFA_64_CPU : CFA_DEFAULT_CPU);
    370380        const char * config = debug ? "debug": "nodebug";
    371381        string libdir = libbase + arch + "-" + config;
    372 
    373         if ( ! dirExists( libdir ) ) {
     382        if( !dirExists(libdir) ) {
    374383                cerr << argv[0] << " internal error, configuration " << config << " not installed." << endl;
    375384                cerr << "Was looking for " << libdir << endl;
    376385                libdir = libbase + arch + "-" + "nolib";
    377         } // if
    378 
    379         if ( ! dirExists( libdir ) ) {
     386        }
     387
     388        if( !dirExists(libdir) ) {
    380389                cerr << argv[0] << " internal error, cannot find prelude directory." << endl;
    381390                cerr << "Was looking for " << libdir << endl;
    382391                exit( EXIT_FAILURE );
    383         } // if
     392        }
    384393
    385394        args[nargs] = ( *new string( string("-D__CFA_FLAG__=--prelude-dir=" ) + libdir + (intree ? "/prelude" : "")) ).c_str();
     
    405414
    406415                // include the cfa library in case it's needed
    407                 args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src" : "")) ).c_str();
     416                args[nargs] = ( *new string( string("-L" ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
     417                nargs += 1;
     418                args[nargs] = ( *new string( string("-Wl,-rpath," ) + libdir + (intree ? "/src/.libs" : "")) ).c_str();
    408419                nargs += 1;
    409420                args[nargs] = "-lcfa";
     
    461472
    462473        if ( Bprefix.length() == 0 ) {
    463                 Bprefix = ! intree ? installlibdir : srcdriverdir;
    464                 if ( Bprefix[Bprefix.length() - 1] != '/' ) Bprefix += '/';
     474                Bprefix = !intree ? installlibdir : srcdriverdir;
    465475                args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str();
    466476                nargs += 1;
     
    496506                args[nargs] = "-D__int8_t_defined";                             // prevent gcc type-size attributes
    497507                nargs += 1;
    498                 args[nargs] = ( *new string( string("-B") + Bprefix ) ).c_str();
     508                args[nargs] = ( *new string( string("-B") + Bprefix + "/" ) ).c_str();
    499509                nargs += 1;
    500510                args[nargs] = "-lm";
Note: See TracChangeset for help on using the changeset viewer.