Print this page
make: unifdef for other OSes (undefined)


  85 
  86 #       include <sys/systeminfo.h>        /* sysinfo() */
  87 
  88 #include <sys/types.h>            /* stat() */
  89 #include <sys/wait.h>             /* wait() */
  90 #include <unistd.h>               /* execv(), unlink(), access() */
  91 #include <vroot/report.h> /* report_dependency(), get_report_file() */
  92 
  93 // From read2.cc
  94 extern  Name            normalize_name(register wchar_t *name_string, register int length);
  95 
  96 // From parallel.cc
  97 #if defined(TEAMWARE_MAKE_CMN)
  98 #define MAXJOBS_ADJUST_RFE4694000
  99 
 100 #ifdef MAXJOBS_ADJUST_RFE4694000
 101 extern void job_adjust_fini();
 102 #endif /* MAXJOBS_ADJUST_RFE4694000 */
 103 #endif /* TEAMWARE_MAKE_CMN */
 104 
 105 #if defined(linux)
 106 #include <ctype.h>
 107 #endif
 108 
 109 /*
 110  * Defined macros
 111  */
 112 #define LD_SUPPORT_ENV_VAR      NOCATGETS("SGS_SUPPORT")
 113 #define LD_SUPPORT_MAKE_LIB     NOCATGETS("libmakestate.so.1")
 114 
 115 /*
 116  * typedefs & structs
 117  */
 118 
 119 /*
 120  * Static variables
 121  */
 122 static  char            *argv_zero_string;
 123 static  Boolean         build_failed_ever_seen;
 124 static  Boolean         continue_after_error_ever_seen; /* `-k' */
 125 static  Boolean         dmake_group_specified;          /* `-g' */
 126 static  Boolean         dmake_max_jobs_specified;       /* `-j' */
 127 static  Boolean         dmake_mode_specified;           /* `-m' */


 184 static  Boolean         read_makefile(Name, Boolean, Boolean, Boolean);
 185 static  void            report_recursion(Name);
 186 static  void            set_sgs_support(void);
 187 static  void            setup_for_projectdir(void);
 188 static  void            setup_makeflags_argv(void);
 189 static  void            report_dir_enter_leave(Boolean entering);
 190 
 191 extern void expand_value(Name, register String , Boolean);
 192 
 193 #ifdef DISTRIBUTED
 194         extern  int             dmake_ofd;
 195         extern  FILE*           dmake_ofp;
 196         extern  int             rxmPid;
 197         extern  XDR             xdrs_out;
 198 #endif
 199 #ifdef TEAMWARE_MAKE_CMN
 200         extern  char            verstring[];
 201 #endif
 202 
 203 jmp_buf jmpbuffer;
 204 #if !defined(linux)
 205 extern nl_catd catd;
 206 #endif
 207 
 208 /*
 209  *      main(argc, argv)
 210  *
 211  *      Parameters:
 212  *              argc                    You know what this is
 213  *              argv                    You know what this is
 214  *
 215  *      Static variables used:
 216  *              list_all_targets        make -T seen
 217  *              trace_status            make -p seen
 218  *
 219  *      Global variables used:
 220  *              debug_level             Should we trace make actions?
 221  *              keep_state              Set if .KEEP_STATE seen
 222  *              makeflags               The Name "MAKEFLAGS", used to get macro
 223  *              remote_command_name     Name of remote invocation cmd ("on")
 224  *              running_list            List of parallel running processes
 225  *              stdout_stderr_same      true if stdout and stderr are the same
 226  *              auto_dependencies       The Name "SUNPRO_DEPENDENCIES"


 246         struct itimerval        value;
 247         char                    def_dmakerc_path[MAXPATHLEN];
 248         Name                    dmake_name, dmake_name2;
 249         Name                    dmake_value, dmake_value2;
 250         Property                prop, prop2;
 251         struct stat             statbuf;
 252         int                     statval;
 253 #endif
 254 
 255 #ifndef PARALLEL
 256         struct stat             out_stat, err_stat;
 257 #endif
 258         hostid = gethostid();
 259 #ifdef TEAMWARE_MAKE_CMN
 260         avo_get_user(NULL, NULL); // Initialize user name
 261 #endif
 262         bsd_signals();
 263 
 264         (void) setlocale(LC_ALL, "");
 265 
 266 #if defined (HP_UX) || defined(linux)
 267        /* HP-UX users typically will not have NLSPATH set, and this binary
 268         * requires that it be set.  On HP-UX 9.0x, /usr/lib/nls/%L/%N.cat is
 269         * the path to set it to.
 270         */
 271 
 272        if (getenv(NOCATGETS("NLSPATH")) == NULL) {
 273          putenv(NOCATGETS("NLSPATH=/usr/lib/nls/%L/%N.cat"));
 274         }
 275 #endif
 276 
 277 #ifdef DMAKE_STATISTICS
 278         if (getenv(NOCATGETS("DMAKE_STATISTICS"))) {
 279                 getname_stat = true;
 280         }
 281 #endif
 282 
 283 
 284         /*
 285          * avo_init() sets the umask to 0.  Save it here and restore
 286          * it after the avo_init() call.
 287          */
 288 #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL)
 289         um = umask(0);
 290         avo_init(argv[0]);
 291         umask(um);
 292 
 293 #ifdef USE_DMS_CCR
 294         usageTracking = new Avo_usage_tracking(NOCATGETS("dmake"), argc, argv);
 295 #else


 398          */
 399 
 400         /* Sun OS make standart */
 401         svr4 = false;  
 402         posix = false;
 403         if(!strcmp(argv_zero_string, NOCATGETS("/usr/xpg4/bin/make"))) {
 404                 svr4 = false;
 405                 posix = true;
 406         } else {
 407                 prognameptr = strrchr(argv[0], '/');
 408                 if(prognameptr) {
 409                         prognameptr++;
 410                 } else {
 411                         prognameptr = argv[0];
 412                 }
 413                 if(!strcmp(prognameptr, NOCATGETS("svr4.make"))) {
 414                         svr4 = true;
 415                         posix = false;
 416                 }
 417         }
 418 #if !defined(HP_UX) && !defined(linux)
 419         if (getenv(USE_SVR4_MAKE) || getenv(NOCATGETS("USE_SVID"))){
 420            svr4 = true;
 421            posix = false;
 422         }
 423 #endif
 424 
 425         /*
 426          * Find the dmake_compat_mode: posix, sun, svr4, or gnu_style, .
 427          */
 428         char * dmake_compat_mode_var = getenv(NOCATGETS("SUN_MAKE_COMPAT_MODE"));
 429         if (dmake_compat_mode_var != NULL) {
 430                 if (0 == strcasecmp(dmake_compat_mode_var, NOCATGETS("GNU"))) {
 431                         gnu_style = true;
 432                 }
 433                 //svr4 = false;
 434                 //posix = false;
 435         }
 436 
 437         /*
 438          * Temporary directory set up.
 439          */
 440         char * tmpdir_var = getenv(NOCATGETS("TMPDIR"));
 441         if (tmpdir_var != NULL && *tmpdir_var == '/' && strlen(tmpdir_var) < MAXPATHLEN) {
 442                 strcpy(mbs_buffer, tmpdir_var);
 443                 for (tmpdir_var = mbs_buffer+strlen(mbs_buffer);


1358                                         catgets(catd, 1, 274, "              [ -d ][ -dd ][ -D ][ -DD ][ -e ][ -i ][ -k ][ -n ][ -p ][ -P ][ -u ][ -w ]\n"));
1359                                 fprintf(stderr,
1360                                         catgets(catd, 1, 275, "              [ -q ][ -r ][ -s ][ -S ][ -t ][ -v ][ -V ][ target... ][ macro=value... ][ \"macro +=value\"... ]\n"));
1361 #else
1362                                 fprintf(stderr,
1363                                         catgets(catd, 1, 276, "Usage : make [ -f makefile ][ -K statefile ]... [ -d ][ -dd ][ -D ][ -DD ]\n"));
1364                                 fprintf(stderr,
1365                                         catgets(catd, 1, 277, "             [ -e ][ -i ][ -k ][ -n ][ -p ][ -P ][ -q ][ -r ][ -s ][ -S ][ -t ]\n"));
1366                                 fprintf(stderr,
1367                                         catgets(catd, 1, 278, "             [ -u ][ -w ][ -V ][ target... ][ macro=value... ][ \"macro +=value\"... ]\n"));
1368 #endif
1369                                 tptr = strchr(SUNPRO_CMD_OPTS, optopt);
1370                         }
1371                         if (!tptr) {
1372                                 fatal(catgets(catd, 1, 279, "Unknown option `-%c'"), optopt);
1373                         } else {
1374                                 fatal(catgets(catd, 1, 280, "Missing argument after `-%c'"), optopt);
1375                         }
1376                 }
1377 
1378 #if defined(linux)
1379                 if (ch == 1) {
1380                         if(optind < argc) {
1381                                 //optind++;
1382                                 //current_optind++;
1383                         makefile_next = 0;
1384                         current_optind = optind;
1385                                 continue;
1386                         } else {
1387                                 break;
1388                         }
1389                 }
1390 #endif
1391 
1392 
1393                 makefile_next |= parse_command_option(ch);
1394                 /*
1395                  * If we're done processing all of the options of
1396                  * ONE argument string...
1397                  */
1398                 if (current_optind < optind) {
1399                         i = current_optind;
1400                         k = 0;
1401                         /* If there's an argument for an option... */
1402                         if ((optind - current_optind) > 1) {
1403                                 k = i + 1;
1404                         }
1405                         switch (makefile_next) {
1406                         case 0:
1407                                 argv[i] = NULL;
1408                                 /* This shouldn't happen */
1409                                 if (k) {
1410                                         argv[k] = NULL;


1710         case 'b':                        /* Obsolete */
1711                 return 0;
1712         case 'c':                        /* Read alternative dmakerc file */
1713                 if (invert_this) {
1714                         dmake_rcfile_specified = false;
1715                 } else {
1716                         dmake_rcfile_specified = true;
1717                 }
1718                 return 2;
1719         case 'D':                        /* Show lines read */
1720                 if (invert_this) {
1721                         read_trace_level--;
1722                 } else {
1723                         read_trace_level++;
1724                 }
1725                 return 0;
1726         case 'd':                        /* Debug flag */
1727                 if (invert_this) {
1728                         debug_level--;
1729                 } else {
1730 #if defined( HP_UX) || defined(linux)
1731                       if (debug_level < 2)  /* Fixes a bug on HP-UX */
1732 #endif
1733                         debug_level++;
1734                 }
1735                 return 0;
1736 #ifdef NSE
1737         case 'E':
1738                 if (invert_this) {
1739                         nse = false;
1740                 } else {
1741                         nse = true;
1742                 }
1743                 nse_init_source_suffixes();
1744                 return 0;
1745 #endif
1746         case 'e':                        /* Environment override flag */
1747                 if (invert_this) {
1748                         env_wins = false;
1749                 } else {
1750                         env_wins = true;
1751                 }
1752                 return 0;




  85 
  86 #       include <sys/systeminfo.h>        /* sysinfo() */
  87 
  88 #include <sys/types.h>            /* stat() */
  89 #include <sys/wait.h>             /* wait() */
  90 #include <unistd.h>               /* execv(), unlink(), access() */
  91 #include <vroot/report.h> /* report_dependency(), get_report_file() */
  92 
  93 // From read2.cc
  94 extern  Name            normalize_name(register wchar_t *name_string, register int length);
  95 
  96 // From parallel.cc
  97 #if defined(TEAMWARE_MAKE_CMN)
  98 #define MAXJOBS_ADJUST_RFE4694000
  99 
 100 #ifdef MAXJOBS_ADJUST_RFE4694000
 101 extern void job_adjust_fini();
 102 #endif /* MAXJOBS_ADJUST_RFE4694000 */
 103 #endif /* TEAMWARE_MAKE_CMN */
 104 



 105 
 106 /*
 107  * Defined macros
 108  */
 109 #define LD_SUPPORT_ENV_VAR      NOCATGETS("SGS_SUPPORT")
 110 #define LD_SUPPORT_MAKE_LIB     NOCATGETS("libmakestate.so.1")
 111 
 112 /*
 113  * typedefs & structs
 114  */
 115 
 116 /*
 117  * Static variables
 118  */
 119 static  char            *argv_zero_string;
 120 static  Boolean         build_failed_ever_seen;
 121 static  Boolean         continue_after_error_ever_seen; /* `-k' */
 122 static  Boolean         dmake_group_specified;          /* `-g' */
 123 static  Boolean         dmake_max_jobs_specified;       /* `-j' */
 124 static  Boolean         dmake_mode_specified;           /* `-m' */


 181 static  Boolean         read_makefile(Name, Boolean, Boolean, Boolean);
 182 static  void            report_recursion(Name);
 183 static  void            set_sgs_support(void);
 184 static  void            setup_for_projectdir(void);
 185 static  void            setup_makeflags_argv(void);
 186 static  void            report_dir_enter_leave(Boolean entering);
 187 
 188 extern void expand_value(Name, register String , Boolean);
 189 
 190 #ifdef DISTRIBUTED
 191         extern  int             dmake_ofd;
 192         extern  FILE*           dmake_ofp;
 193         extern  int             rxmPid;
 194         extern  XDR             xdrs_out;
 195 #endif
 196 #ifdef TEAMWARE_MAKE_CMN
 197         extern  char            verstring[];
 198 #endif
 199 
 200 jmp_buf jmpbuffer;

 201 extern nl_catd catd;

 202 
 203 /*
 204  *      main(argc, argv)
 205  *
 206  *      Parameters:
 207  *              argc                    You know what this is
 208  *              argv                    You know what this is
 209  *
 210  *      Static variables used:
 211  *              list_all_targets        make -T seen
 212  *              trace_status            make -p seen
 213  *
 214  *      Global variables used:
 215  *              debug_level             Should we trace make actions?
 216  *              keep_state              Set if .KEEP_STATE seen
 217  *              makeflags               The Name "MAKEFLAGS", used to get macro
 218  *              remote_command_name     Name of remote invocation cmd ("on")
 219  *              running_list            List of parallel running processes
 220  *              stdout_stderr_same      true if stdout and stderr are the same
 221  *              auto_dependencies       The Name "SUNPRO_DEPENDENCIES"


 241         struct itimerval        value;
 242         char                    def_dmakerc_path[MAXPATHLEN];
 243         Name                    dmake_name, dmake_name2;
 244         Name                    dmake_value, dmake_value2;
 245         Property                prop, prop2;
 246         struct stat             statbuf;
 247         int                     statval;
 248 #endif
 249 
 250 #ifndef PARALLEL
 251         struct stat             out_stat, err_stat;
 252 #endif
 253         hostid = gethostid();
 254 #ifdef TEAMWARE_MAKE_CMN
 255         avo_get_user(NULL, NULL); // Initialize user name
 256 #endif
 257         bsd_signals();
 258 
 259         (void) setlocale(LC_ALL, "");
 260 










 261 
 262 #ifdef DMAKE_STATISTICS
 263         if (getenv(NOCATGETS("DMAKE_STATISTICS"))) {
 264                 getname_stat = true;
 265         }
 266 #endif
 267 
 268 
 269         /*
 270          * avo_init() sets the umask to 0.  Save it here and restore
 271          * it after the avo_init() call.
 272          */
 273 #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL)
 274         um = umask(0);
 275         avo_init(argv[0]);
 276         umask(um);
 277 
 278 #ifdef USE_DMS_CCR
 279         usageTracking = new Avo_usage_tracking(NOCATGETS("dmake"), argc, argv);
 280 #else


 383          */
 384 
 385         /* Sun OS make standart */
 386         svr4 = false;  
 387         posix = false;
 388         if(!strcmp(argv_zero_string, NOCATGETS("/usr/xpg4/bin/make"))) {
 389                 svr4 = false;
 390                 posix = true;
 391         } else {
 392                 prognameptr = strrchr(argv[0], '/');
 393                 if(prognameptr) {
 394                         prognameptr++;
 395                 } else {
 396                         prognameptr = argv[0];
 397                 }
 398                 if(!strcmp(prognameptr, NOCATGETS("svr4.make"))) {
 399                         svr4 = true;
 400                         posix = false;
 401                 }
 402         }

 403         if (getenv(USE_SVR4_MAKE) || getenv(NOCATGETS("USE_SVID"))){
 404            svr4 = true;
 405            posix = false;
 406         }

 407 
 408         /*
 409          * Find the dmake_compat_mode: posix, sun, svr4, or gnu_style, .
 410          */
 411         char * dmake_compat_mode_var = getenv(NOCATGETS("SUN_MAKE_COMPAT_MODE"));
 412         if (dmake_compat_mode_var != NULL) {
 413                 if (0 == strcasecmp(dmake_compat_mode_var, NOCATGETS("GNU"))) {
 414                         gnu_style = true;
 415                 }
 416                 //svr4 = false;
 417                 //posix = false;
 418         }
 419 
 420         /*
 421          * Temporary directory set up.
 422          */
 423         char * tmpdir_var = getenv(NOCATGETS("TMPDIR"));
 424         if (tmpdir_var != NULL && *tmpdir_var == '/' && strlen(tmpdir_var) < MAXPATHLEN) {
 425                 strcpy(mbs_buffer, tmpdir_var);
 426                 for (tmpdir_var = mbs_buffer+strlen(mbs_buffer);


1341                                         catgets(catd, 1, 274, "              [ -d ][ -dd ][ -D ][ -DD ][ -e ][ -i ][ -k ][ -n ][ -p ][ -P ][ -u ][ -w ]\n"));
1342                                 fprintf(stderr,
1343                                         catgets(catd, 1, 275, "              [ -q ][ -r ][ -s ][ -S ][ -t ][ -v ][ -V ][ target... ][ macro=value... ][ \"macro +=value\"... ]\n"));
1344 #else
1345                                 fprintf(stderr,
1346                                         catgets(catd, 1, 276, "Usage : make [ -f makefile ][ -K statefile ]... [ -d ][ -dd ][ -D ][ -DD ]\n"));
1347                                 fprintf(stderr,
1348                                         catgets(catd, 1, 277, "             [ -e ][ -i ][ -k ][ -n ][ -p ][ -P ][ -q ][ -r ][ -s ][ -S ][ -t ]\n"));
1349                                 fprintf(stderr,
1350                                         catgets(catd, 1, 278, "             [ -u ][ -w ][ -V ][ target... ][ macro=value... ][ \"macro +=value\"... ]\n"));
1351 #endif
1352                                 tptr = strchr(SUNPRO_CMD_OPTS, optopt);
1353                         }
1354                         if (!tptr) {
1355                                 fatal(catgets(catd, 1, 279, "Unknown option `-%c'"), optopt);
1356                         } else {
1357                                 fatal(catgets(catd, 1, 280, "Missing argument after `-%c'"), optopt);
1358                         }
1359                 }
1360 













1361 
1362 
1363                 makefile_next |= parse_command_option(ch);
1364                 /*
1365                  * If we're done processing all of the options of
1366                  * ONE argument string...
1367                  */
1368                 if (current_optind < optind) {
1369                         i = current_optind;
1370                         k = 0;
1371                         /* If there's an argument for an option... */
1372                         if ((optind - current_optind) > 1) {
1373                                 k = i + 1;
1374                         }
1375                         switch (makefile_next) {
1376                         case 0:
1377                                 argv[i] = NULL;
1378                                 /* This shouldn't happen */
1379                                 if (k) {
1380                                         argv[k] = NULL;


1680         case 'b':                        /* Obsolete */
1681                 return 0;
1682         case 'c':                        /* Read alternative dmakerc file */
1683                 if (invert_this) {
1684                         dmake_rcfile_specified = false;
1685                 } else {
1686                         dmake_rcfile_specified = true;
1687                 }
1688                 return 2;
1689         case 'D':                        /* Show lines read */
1690                 if (invert_this) {
1691                         read_trace_level--;
1692                 } else {
1693                         read_trace_level++;
1694                 }
1695                 return 0;
1696         case 'd':                        /* Debug flag */
1697                 if (invert_this) {
1698                         debug_level--;
1699                 } else {



1700                         debug_level++;
1701                 }
1702                 return 0;
1703 #ifdef NSE
1704         case 'E':
1705                 if (invert_this) {
1706                         nse = false;
1707                 } else {
1708                         nse = true;
1709                 }
1710                 nse_init_source_suffixes();
1711                 return 0;
1712 #endif
1713         case 'e':                        /* Environment override flag */
1714                 if (invert_this) {
1715                         env_wins = false;
1716                 } else {
1717                         env_wins = true;
1718                 }
1719                 return 0;