| [b87a5ed] | 1 | // | 
|---|
|  | 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | 
|---|
|  | 3 | // | 
|---|
|  | 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
|  | 5 | // file "LICENCE" distributed with Cforall. | 
|---|
|  | 6 | // | 
|---|
| [76c7f65e] | 7 | // cfa.cc -- | 
|---|
| [b87a5ed] | 8 | // | 
|---|
| [51b73452] | 9 | // Author           : Peter A. Buhr | 
|---|
|  | 10 | // Created On       : Tue Aug 20 13:44:49 2002 | 
|---|
|  | 11 | // Last Modified By : Peter A. Buhr | 
|---|
| [6e4b913] | 12 | // Last Modified On : Thu Jul  7 08:56:01 2016 | 
|---|
|  | 13 | // Update Count     : 144 | 
|---|
| [b87a5ed] | 14 | // | 
|---|
| [51b73452] | 15 |  | 
|---|
|  | 16 | #include <iostream> | 
|---|
| [b87a5ed] | 17 | #include <cstdio>                                                                               // perror | 
|---|
|  | 18 | #include <cstdlib>                                                                              // putenv, exit | 
|---|
|  | 19 | #include <unistd.h>                                                                             // execvp | 
|---|
|  | 20 | #include <string>                                                                               // STL version | 
|---|
| [51b73452] | 21 |  | 
|---|
| [b87a5ed] | 22 | #include "config.h"                                                                             // configure info | 
|---|
| [51b73452] | 23 |  | 
|---|
|  | 24 | using std::cerr; | 
|---|
|  | 25 | using std::endl; | 
|---|
|  | 26 | using std::string; | 
|---|
|  | 27 |  | 
|---|
|  | 28 |  | 
|---|
|  | 29 | //#define __DEBUG_H__ | 
|---|
|  | 30 |  | 
|---|
|  | 31 |  | 
|---|
|  | 32 | bool prefix( string arg, string pre ) { | 
|---|
| [b87a5ed] | 33 | return arg.substr( 0, pre.size() ) == pre; | 
|---|
| [51b73452] | 34 | } // prefix | 
|---|
|  | 35 |  | 
|---|
|  | 36 |  | 
|---|
|  | 37 | void shuffle( const char *args[], int S, int E, int N ) { | 
|---|
| [b87a5ed] | 38 | // S & E index 1 passed the end so adjust with -1 | 
|---|
| [51b73452] | 39 | #ifdef __DEBUG_H__ | 
|---|
| [b87a5ed] | 40 | cerr << "shuffle:" << S << " " << E << " " << N << endl; | 
|---|
| [51b73452] | 41 | #endif // __DEBUG_H__ | 
|---|
| [b87a5ed] | 42 | for ( int j = E-1 + N; j > S-1 + N; j -=1 ) { | 
|---|
| [51b73452] | 43 | #ifdef __DEBUG_H__ | 
|---|
| [b87a5ed] | 44 | cerr << "\t" << j << " " << j-N << endl; | 
|---|
| [51b73452] | 45 | #endif // __DEBUG_H__ | 
|---|
| [b87a5ed] | 46 | args[j] = args[j-N]; | 
|---|
|  | 47 | } // for | 
|---|
| [51b73452] | 48 | } // shuffle | 
|---|
|  | 49 |  | 
|---|
|  | 50 |  | 
|---|
|  | 51 | int main( int argc, char *argv[] ) { | 
|---|
| [b87a5ed] | 52 | string Version( VERSION );                                                      // current version number from CONFIG | 
|---|
|  | 53 | string Major( "0" ), Minor( "0" ), Patch( "0" );        // default version numbers | 
|---|
| [1db21619] | 54 |  | 
|---|
| [b87a5ed] | 55 | int posn1 = Version.find( "." );                                        // find the divider between major and minor version numbers | 
|---|
|  | 56 | if ( posn1 == -1 ) {                                                            // not there ? | 
|---|
|  | 57 | Major = Version; | 
|---|
| [51b73452] | 58 | } else { | 
|---|
| [b87a5ed] | 59 | Major = Version.substr( 0, posn1 ); | 
|---|
|  | 60 | int posn2 = Version.find( ".", posn1 + 1 );             // find the divider between minor and patch numbers | 
|---|
|  | 61 | if ( posn2 == -1 ) {                                                    // not there ? | 
|---|
|  | 62 | Minor = Version.substr( posn1 ); | 
|---|
|  | 63 | } else { | 
|---|
|  | 64 | Minor = Version.substr( posn1 + 1, posn2 - posn1 - 1 ); | 
|---|
|  | 65 | Patch = Version.substr( posn2 + 1 ); | 
|---|
|  | 66 | } // if | 
|---|
| [51b73452] | 67 | } // if | 
|---|
|  | 68 |  | 
|---|
| [00cc023] | 69 | string installincdir( CFA_INCDIR );                                     // fixed location of include files | 
|---|
|  | 70 | string installlibdir( CFA_LIBDIR );                                     // fixed location of cc1 and cfa-cpp commands | 
|---|
| [51b73452] | 71 |  | 
|---|
| [b87a5ed] | 72 | string heading;                                                                         // banner printed at start of cfa compilation | 
|---|
|  | 73 | string arg;                                                                                     // current command-line argument during command-line parsing | 
|---|
|  | 74 | string Bprefix;                                                                         // path where gcc looks for compiler command steps | 
|---|
|  | 75 | string langstd;                                                                         // language standard | 
|---|
| [51b73452] | 76 |  | 
|---|
| [e24f13a] | 77 | string compiler_path( CFA_BACKEND_CC );                         // path/name of C compiler | 
|---|
| [b87a5ed] | 78 | string compiler_name;                                                           // name of C compiler | 
|---|
| [51b73452] | 79 |  | 
|---|
| [b87a5ed] | 80 | bool nonoptarg = false;                                                         // indicates non-option argument specified | 
|---|
|  | 81 | bool link = true;                                                                       // linking as well as compiling | 
|---|
|  | 82 | bool verbose = false;                                                           // -v flag | 
|---|
|  | 83 | bool quiet = false;                                                                     // -quiet flag | 
|---|
|  | 84 | bool debug = true;                                                                      // -debug flag | 
|---|
|  | 85 | bool help = false;                                                                      // -help flag | 
|---|
|  | 86 | bool CFA_flag = false;                                                          // -CFA flag | 
|---|
|  | 87 | bool cpp_flag = false;                                                          // -E or -M flag, preprocessor only | 
|---|
| [de62360d] | 88 | bool std_flag = false;                                                          // -std= flag | 
|---|
| [6e4b913] | 89 | bool debugging __attribute(( unused )) = false;         // -g flag | 
|---|
| [51b73452] | 90 |  | 
|---|
| [b87a5ed] | 91 | const char *args[argc + 100];                                           // cfa command line values, plus some space for additional flags | 
|---|
|  | 92 | int sargs = 1;                                                                          // starting location for arguments in args list | 
|---|
|  | 93 | int nargs = sargs;                                                                      // number of arguments in args list; 0 => command name | 
|---|
| [51b73452] | 94 |  | 
|---|
| [b87a5ed] | 95 | const char *libs[argc + 20];                                            // non-user libraries must come separately, plus some added libraries and flags | 
|---|
|  | 96 | int nlibs = 0; | 
|---|
| [51b73452] | 97 |  | 
|---|
|  | 98 | #ifdef __DEBUG_H__ | 
|---|
| [b87a5ed] | 99 | cerr << "CFA:" << endl; | 
|---|
| [51b73452] | 100 | #endif // __DEBUG_H__ | 
|---|
|  | 101 |  | 
|---|
| [b87a5ed] | 102 | // process command-line arguments | 
|---|
| [51b73452] | 103 |  | 
|---|
| [b87a5ed] | 104 | for ( int i = 1; i < argc; i += 1 ) { | 
|---|
| [51b73452] | 105 | #ifdef __DEBUG_H__ | 
|---|
| [b87a5ed] | 106 | cerr << "argv[" << i << "]:\"" << argv[i] << "\"" << endl; | 
|---|
| [51b73452] | 107 | #endif // __DEBUG_H__ | 
|---|
| [b87a5ed] | 108 | arg = argv[i];                                                                  // convert to string value | 
|---|
| [51b73452] | 109 | #ifdef __DEBUG_H__ | 
|---|
| [b87a5ed] | 110 | cerr << "arg:\"" << arg << "\"" << endl; | 
|---|
| [51b73452] | 111 | #endif // __DEBUG_H__ | 
|---|
| [b87a5ed] | 112 | if ( prefix( arg, "-" ) ) { | 
|---|
|  | 113 | // pass through arguments | 
|---|
|  | 114 |  | 
|---|
|  | 115 | if ( arg == "-Xlinker" || arg == "-o" ) { | 
|---|
|  | 116 | args[nargs] = argv[i];                                  // pass the argument along | 
|---|
|  | 117 | nargs += 1; | 
|---|
|  | 118 | i += 1; | 
|---|
|  | 119 | if ( i == argc ) continue;                              // next argument available ? | 
|---|
|  | 120 | args[nargs] = argv[i];                                  // pass the argument along | 
|---|
|  | 121 | nargs += 1; | 
|---|
|  | 122 | } else if ( arg == "-XCFA" ) {                          // CFA pass through | 
|---|
|  | 123 | i += 1; | 
|---|
|  | 124 | args[nargs] = ( *new string( string("-D__CFA_FLAG__=") + argv[i] ) ).c_str(); | 
|---|
|  | 125 | nargs += 1; | 
|---|
|  | 126 |  | 
|---|
|  | 127 | // CFA specific arguments | 
|---|
|  | 128 |  | 
|---|
|  | 129 | } else if ( arg == "-CFA" ) { | 
|---|
|  | 130 | CFA_flag = true;                                                // strip the -CFA flag | 
|---|
|  | 131 | link = false; | 
|---|
|  | 132 | args[nargs] = "-E";                                             // replace the argument with -E | 
|---|
|  | 133 | nargs += 1; | 
|---|
|  | 134 | } else if ( arg == "-debug" ) { | 
|---|
|  | 135 | debug = true;                                                   // strip the debug flag | 
|---|
|  | 136 | } else if ( arg == "-nodebug" ) { | 
|---|
|  | 137 | debug = false;                                                  // strip the nodebug flag | 
|---|
|  | 138 | } else if ( arg == "-quiet" ) { | 
|---|
|  | 139 | quiet = true;                                                   // strip the quiet flag | 
|---|
|  | 140 | } else if ( arg == "-noquiet" ) { | 
|---|
|  | 141 | quiet = false;                                                  // strip the noquiet flag | 
|---|
|  | 142 | } else if ( arg == "-help" ) { | 
|---|
|  | 143 | help = true;                                                    // strip the help flag | 
|---|
|  | 144 | } else if ( arg == "-nohelp" ) { | 
|---|
|  | 145 | help = false;                                                   // strip the nohelp flag | 
|---|
|  | 146 | } else if ( arg == "-compiler" ) { | 
|---|
|  | 147 | // use the user specified compiler | 
|---|
|  | 148 | i += 1; | 
|---|
|  | 149 | if ( i == argc ) continue;                              // next argument available ? | 
|---|
|  | 150 | compiler_path = argv[i]; | 
|---|
|  | 151 | if ( putenv( (char *)( *new string( string( "__U_COMPILER__=" ) + argv[i]) ).c_str() ) != 0 ) { | 
|---|
|  | 152 | cerr << argv[0] << " error, cannot set environment variable." << endl; | 
|---|
|  | 153 | exit( EXIT_FAILURE ); | 
|---|
|  | 154 | } // if | 
|---|
|  | 155 |  | 
|---|
| [de62360d] | 156 | // C specific arguments | 
|---|
| [b87a5ed] | 157 |  | 
|---|
|  | 158 | } else if ( arg == "-v" ) { | 
|---|
|  | 159 | verbose = true;                                                 // verbosity required | 
|---|
|  | 160 | args[nargs] = argv[i];                                  // pass the argument along | 
|---|
|  | 161 | nargs += 1; | 
|---|
|  | 162 | } else if ( arg == "-g" ) { | 
|---|
|  | 163 | debugging = true;                                               // symbolic debugging required | 
|---|
|  | 164 | args[nargs] = argv[i];                                  // pass the argument along | 
|---|
|  | 165 | nargs += 1; | 
|---|
| [de62360d] | 166 | } else if ( prefix( arg, "-std=" ) ) { | 
|---|
| [53ba273] | 167 | std_flag = true;                                                // -std=XX provided | 
|---|
| [de62360d] | 168 | args[nargs] = argv[i];                                  // pass the argument along | 
|---|
|  | 169 | nargs += 1; | 
|---|
| [b87a5ed] | 170 | } else if ( prefix( arg, "-B" ) ) { | 
|---|
|  | 171 | Bprefix = arg.substr(2);                                // strip the -B flag | 
|---|
|  | 172 | args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str(); | 
|---|
|  | 173 | nargs += 1; | 
|---|
|  | 174 | } else if ( prefix( arg, "-b" ) ) { | 
|---|
|  | 175 | if ( arg.length() == 2 ) {                              // separate argument ? | 
|---|
|  | 176 | i += 1; | 
|---|
|  | 177 | if ( i == argc ) continue;                      // next argument available ? | 
|---|
|  | 178 | arg += argv[i];                                         // concatenate argument | 
|---|
|  | 179 | } // if | 
|---|
|  | 180 | // later versions of gcc require the -b option to appear at the start of the command line | 
|---|
|  | 181 | shuffle( args, sargs, nargs, 1 );               // make room at front of argument list | 
|---|
|  | 182 | args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along | 
|---|
|  | 183 | if ( putenv( (char *)( *new string( string( "__GCC_MACHINE__=" ) + arg ) ).c_str() ) != 0 ) { | 
|---|
|  | 184 | cerr << argv[0] << " error, cannot set environment variable." << endl; | 
|---|
|  | 185 | exit( EXIT_FAILURE ); | 
|---|
|  | 186 | } // if | 
|---|
|  | 187 | sargs += 1; | 
|---|
|  | 188 | nargs += 1; | 
|---|
|  | 189 | } else if ( prefix( arg, "-V" ) ) { | 
|---|
|  | 190 | if ( arg.length() == 2 ) {                              // separate argument ? | 
|---|
|  | 191 | i += 1; | 
|---|
|  | 192 | if ( i == argc ) continue;                      // next argument available ? | 
|---|
|  | 193 | arg += argv[i];                                         // concatenate argument | 
|---|
|  | 194 | } // if | 
|---|
|  | 195 | // later versions of gcc require the -V option to appear at the start of the command line | 
|---|
|  | 196 | shuffle( args, sargs, nargs, 1 );               // make room at front of argument list | 
|---|
|  | 197 | args[sargs] = ( *new string( arg ) ).c_str(); // pass the argument along | 
|---|
|  | 198 | if ( putenv( (char *)( *new string( string( "__GCC_VERSION__=" ) + arg ) ).c_str() ) != 0 ) { | 
|---|
|  | 199 | cerr << argv[0] << " error, cannot set environment variable." << endl; | 
|---|
|  | 200 | exit( EXIT_FAILURE ); | 
|---|
|  | 201 | } // if | 
|---|
|  | 202 | sargs += 1; | 
|---|
|  | 203 | nargs += 1; | 
|---|
|  | 204 | } else if ( arg == "-c" || arg == "-S" || arg == "-E" || arg == "-M" || arg == "-MM" ) { | 
|---|
|  | 205 | args[nargs] = argv[i];                                  // pass the argument along | 
|---|
|  | 206 | nargs += 1; | 
|---|
|  | 207 | if ( arg == "-E" || arg == "-M" || arg == "-MM" ) { | 
|---|
|  | 208 | cpp_flag = true;                                        // cpp only | 
|---|
|  | 209 | } // if | 
|---|
|  | 210 | link = false;                           // no linkage required | 
|---|
|  | 211 | } else if ( arg[1] == 'l' ) { | 
|---|
|  | 212 | // if the user specifies a library, load it after user code | 
|---|
|  | 213 | libs[nlibs] = argv[i]; | 
|---|
|  | 214 | nlibs += 1; | 
|---|
|  | 215 | } else { | 
|---|
|  | 216 | // concatenate any other arguments | 
|---|
|  | 217 | args[nargs] = argv[i]; | 
|---|
|  | 218 | nargs += 1; | 
|---|
|  | 219 | } // if | 
|---|
|  | 220 | } else { | 
|---|
|  | 221 | // concatenate other arguments | 
|---|
|  | 222 | args[nargs] = argv[i]; | 
|---|
|  | 223 | nargs += 1; | 
|---|
|  | 224 | nonoptarg = true; | 
|---|
|  | 225 | } // if | 
|---|
|  | 226 | } // for | 
|---|
| [51b73452] | 227 |  | 
|---|
| [b87a5ed] | 228 | #ifdef __DEBUG_H__ | 
|---|
|  | 229 | cerr << "args:"; | 
|---|
|  | 230 | for ( int i = 1; i < nargs; i += 1 ) { | 
|---|
|  | 231 | cerr << " " << args[i]; | 
|---|
|  | 232 | } // for | 
|---|
|  | 233 | cerr << endl; | 
|---|
|  | 234 | #endif // __DEBUG_H__ | 
|---|
| [51b73452] | 235 |  | 
|---|
| [b87a5ed] | 236 | if ( cpp_flag && CFA_flag ) { | 
|---|
|  | 237 | cerr << argv[0] << " error, cannot use -E and -CFA flags together." << endl; | 
|---|
|  | 238 | exit( EXIT_FAILURE ); | 
|---|
|  | 239 | } // if | 
|---|
| [51b73452] | 240 |  | 
|---|
| [b87a5ed] | 241 | string d; | 
|---|
|  | 242 | if ( debug ) { | 
|---|
|  | 243 | d = "-d"; | 
|---|
|  | 244 | } // if | 
|---|
| [51b73452] | 245 |  | 
|---|
| [6e4b913] | 246 | // add the CFA include-library paths, which allow direct access to header files without directory qualification | 
|---|
|  | 247 |  | 
|---|
| [b87a5ed] | 248 | args[nargs] = "-I" CFA_INCDIR; | 
|---|
|  | 249 | nargs += 1; | 
|---|
| [ed0e67a] | 250 | args[nargs] = "-I" CFA_INCDIR "/stdhdr"; | 
|---|
| [7fe4cc3e] | 251 | nargs += 1; | 
|---|
| [76c7f65e] | 252 | args[nargs] = "-I" CFA_INCDIR "/containers"; | 
|---|
|  | 253 | nargs += 1; | 
|---|
|  | 254 |  | 
|---|
| [b87a5ed] | 255 | if ( link ) { | 
|---|
|  | 256 | // include the cfa library in case it's needed | 
|---|
|  | 257 | args[nargs] = "-L" CFA_LIBDIR; | 
|---|
| [51b73452] | 258 | nargs += 1; | 
|---|
| [b87a5ed] | 259 | args[nargs] = "-lcfa"; | 
|---|
| [51b73452] | 260 | nargs += 1; | 
|---|
|  | 261 | } // if | 
|---|
|  | 262 |  | 
|---|
| [b87a5ed] | 263 | // add the correct set of flags based on the type of compile this is | 
|---|
| [8c17ab0] | 264 |  | 
|---|
| [1db21619] | 265 | args[nargs] = ( *new string( string("-D__CFA__=") + Major ) ).c_str(); | 
|---|
| [51b73452] | 266 | nargs += 1; | 
|---|
| [b87a5ed] | 267 | args[nargs] = ( *new string( string("-D__CFA_MINOR__=") + Minor ) ).c_str(); | 
|---|
| [51b73452] | 268 | nargs += 1; | 
|---|
| [1db21619] | 269 | args[nargs] = ( *new string( string("-D__CFA_PATCHLEVEL__=") + Patch ) ).c_str(); | 
|---|
|  | 270 | nargs += 1; | 
|---|
| [4c82a3c] | 271 | args[nargs] = "-D__CFA__"; | 
|---|
|  | 272 | nargs += 1; | 
|---|
|  | 273 | args[nargs] = "-D__CFORALL__"; | 
|---|
| [02e5ab6] | 274 | nargs += 1; | 
|---|
| [51b73452] | 275 |  | 
|---|
| [b87a5ed] | 276 | if ( cpp_flag ) { | 
|---|
|  | 277 | args[nargs] = "-D__CPP__"; | 
|---|
|  | 278 | nargs += 1; | 
|---|
|  | 279 | } // if | 
|---|
| [51b73452] | 280 |  | 
|---|
| [b87a5ed] | 281 | if ( CFA_flag ) { | 
|---|
| [4c82a3c] | 282 | args[nargs] = "-D__CFA_PREPROCESS_"; | 
|---|
| [b87a5ed] | 283 | nargs += 1; | 
|---|
|  | 284 | } // if | 
|---|
| [51b73452] | 285 |  | 
|---|
| [b87a5ed] | 286 | if ( debug ) { | 
|---|
|  | 287 | heading += " (debug)"; | 
|---|
|  | 288 | args[nargs] = "-D__CFA_DEBUG__"; | 
|---|
|  | 289 | nargs += 1; | 
|---|
|  | 290 | } else { | 
|---|
|  | 291 | heading += " (no debug)"; | 
|---|
|  | 292 | } // if | 
|---|
| [51b73452] | 293 |  | 
|---|
| [b87a5ed] | 294 | if ( Bprefix.length() == 0 ) { | 
|---|
|  | 295 | Bprefix = installlibdir; | 
|---|
|  | 296 | args[nargs] = ( *new string( string("-D__GCC_BPREFIX__=") + Bprefix ) ).c_str(); | 
|---|
|  | 297 | nargs += 1; | 
|---|
|  | 298 | } // if | 
|---|
| [51b73452] | 299 |  | 
|---|
| [b87a5ed] | 300 | // execute the compilation command | 
|---|
| [51b73452] | 301 |  | 
|---|
| [b87a5ed] | 302 | args[0] = compiler_path.c_str();                                        // set compiler command for exec | 
|---|
|  | 303 | // find actual name of the compiler independent of the path to it | 
|---|
|  | 304 | int p = compiler_path.find_last_of( '/' );                      // scan r -> l for first '/' | 
|---|
|  | 305 | if ( p == -1 ) { | 
|---|
|  | 306 | compiler_name = compiler_path; | 
|---|
|  | 307 | } else { | 
|---|
|  | 308 | compiler_name = *new string( compiler_path.substr( p + 1 ) ); | 
|---|
|  | 309 | } // if | 
|---|
| [51b73452] | 310 |  | 
|---|
| [b87a5ed] | 311 | if ( prefix( compiler_name, "gcc" ) ) {                         // allow suffix on gcc name | 
|---|
|  | 312 | args[nargs] = "-no-integrated-cpp"; | 
|---|
|  | 313 | nargs += 1; | 
|---|
| [76c7f65e] | 314 | args[nargs] = "-Wno-deprecated"; | 
|---|
| [b87a5ed] | 315 | nargs += 1; | 
|---|
| [de62360d] | 316 | if ( ! std_flag ) {                                                             // default c99, if none specified | 
|---|
| [53ba273] | 317 | args[nargs] = "-std=gnu99"; | 
|---|
| [de62360d] | 318 | nargs += 1; | 
|---|
|  | 319 | } // if | 
|---|
| [76c7f65e] | 320 | args[nargs] = "-fgnu89-inline"; | 
|---|
| [6e991d6] | 321 | nargs += 1; | 
|---|
| [b87a5ed] | 322 | args[nargs] = ( *new string( string("-B") + Bprefix + "/" ) ).c_str(); | 
|---|
|  | 323 | nargs += 1; | 
|---|
| [d3b7937] | 324 | args[nargs] = "-lm"; | 
|---|
|  | 325 | nargs += 1; | 
|---|
| [b87a5ed] | 326 | } else { | 
|---|
| [e24f13a] | 327 | cerr << argv[0] << " error, compiler \"" << compiler_name << "\" unsupported." << endl; | 
|---|
| [b87a5ed] | 328 | exit( EXIT_FAILURE ); | 
|---|
|  | 329 | } // if | 
|---|
| [51b73452] | 330 |  | 
|---|
| [b87a5ed] | 331 | for ( int i = 0; i < nlibs; i += 1 ) {                          // copy non-user libraries after all user libraries | 
|---|
|  | 332 | args[nargs] = libs[i]; | 
|---|
|  | 333 | nargs += 1; | 
|---|
|  | 334 | } // for | 
|---|
| [51b73452] | 335 |  | 
|---|
| [b87a5ed] | 336 | args[nargs] = NULL;                                                                     // terminate with NULL | 
|---|
| [51b73452] | 337 |  | 
|---|
|  | 338 | #ifdef __DEBUG_H__ | 
|---|
| [b87a5ed] | 339 | cerr << "nargs: " << nargs << endl; | 
|---|
|  | 340 | cerr << "args:" << endl; | 
|---|
|  | 341 | for ( int i = 0; args[i] != NULL; i += 1 ) { | 
|---|
|  | 342 | cerr << " \"" << args[i] << "\"" << endl; | 
|---|
|  | 343 | } // for | 
|---|
| [51b73452] | 344 | #endif // __DEBUG_H__ | 
|---|
|  | 345 |  | 
|---|
| [b87a5ed] | 346 | if ( ! quiet ) { | 
|---|
|  | 347 | cerr << "CFA " << "Version " << Version << heading << endl; | 
|---|
|  | 348 |  | 
|---|
|  | 349 | if ( help ) { | 
|---|
|  | 350 | cerr << | 
|---|
|  | 351 | "-debug\t\t\t: use cfa runtime with debug checking" << endl << | 
|---|
|  | 352 | "-help\t\t\t: print this help message" << endl << | 
|---|
|  | 353 | "-quiet\t\t\t: print no messages from the cfa command" << endl << | 
|---|
|  | 354 | "-CFA\t\t\t: run the cpp preprocessor and the cfa-cpp translator" << endl << | 
|---|
|  | 355 | "-XCFA -cfa-cpp-flag\t: pass next flag as-is to the cfa-cpp translator" << endl << | 
|---|
|  | 356 | "...\t\t\t: any other " << compiler_name << " flags" << endl; | 
|---|
|  | 357 | } // if | 
|---|
| [51b73452] | 358 | } // if | 
|---|
|  | 359 |  | 
|---|
| [b87a5ed] | 360 | if ( verbose ) { | 
|---|
|  | 361 | if ( argc == 2 ) exit( EXIT_SUCCESS );                  // if only the -v flag is specified, do not invoke gcc | 
|---|
| [51b73452] | 362 |  | 
|---|
| [b87a5ed] | 363 | for ( int i = 0; args[i] != NULL; i += 1 ) { | 
|---|
|  | 364 | cerr << args[i] << " "; | 
|---|
|  | 365 | } // for | 
|---|
|  | 366 | cerr << endl; | 
|---|
|  | 367 | } // if | 
|---|
| [51b73452] | 368 |  | 
|---|
| [b87a5ed] | 369 | if ( ! nonoptarg ) { | 
|---|
|  | 370 | cerr << argv[0] << " error, no input files" << endl; | 
|---|
|  | 371 | exit( EXIT_FAILURE ); | 
|---|
|  | 372 | } // if | 
|---|
| [51b73452] | 373 |  | 
|---|
| [b87a5ed] | 374 | // execute the command and return the result | 
|---|
| [51b73452] | 375 |  | 
|---|
| [b87a5ed] | 376 | execvp( args[0], (char *const *)args );                         // should not return | 
|---|
|  | 377 | perror( "CFA Translator error: cfa level, execvp" ); | 
|---|
|  | 378 | exit( EXIT_FAILURE ); | 
|---|
| [51b73452] | 379 | } // main | 
|---|
|  | 380 |  | 
|---|
|  | 381 | // Local Variables: // | 
|---|
| [b87a5ed] | 382 | // tab-width: 4 // | 
|---|
|  | 383 | // mode: c++ // | 
|---|
| [51b73452] | 384 | // compile-command: "make install" // | 
|---|
|  | 385 | // End: // | 
|---|