Print this page
make: be serial if 'make', parallel if 'dmake', and parallel if '-j' is specified either way

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/bin/main.cc
          +++ new/usr/src/cmd/make/bin/main.cc
↓ open down ↓ 32 lines elided ↑ open up ↑
  33   33   * Included files
  34   34   */
  35   35  #if defined(TEAMWARE_MAKE_CMN)
  36   36  #       include <avo/intl.h>
  37   37  #endif
  38   38  
  39   39  #include <bsd/bsd.h>            /* bsd_signal() */
  40   40  
  41   41  
  42   42  #include <locale.h>             /* setlocale() */
       43 +#include <libgen.h>
  43   44  #include <mk/defs.h>
  44   45  #include <mksdmsi18n/mksdmsi18n.h>      /* libmksdmsi18n_init() */
  45   46  #include <mksh/macro.h>         /* getvar() */
  46   47  #include <mksh/misc.h>          /* getmem(), setup_char_semantics() */
  47   48  
  48   49  #if defined(TEAMWARE_MAKE_CMN)
  49   50  #endif
  50   51  
  51   52  #include <pwd.h>                /* getpwnam() */
  52   53  #include <setjmp.h>
↓ open down ↓ 353 lines elided ↑ open up ↑
 406  407                  } else {
 407  408                          warning(catgets(catd, 1, 352, "Unsupported value `%s' for DMAKE_OUTPUT_MODE after -x flag (ignored)"),
 408  409                                dmake_value2->string_mb);
 409  410                  }
 410  411          }
 411  412          /*
 412  413           * Find the dmake_mode: parallel, or serial.
 413  414           */
 414  415      if ((!pmake_cap_r_specified) &&
 415  416          (!pmake_machinesfile_specified)) {
      417 +        char *s = strdup(argv[0]);    
      418 +            
 416  419          MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
 417  420          dmake_name2 = GETNAME(wcs_buffer, FIND_LENGTH);
 418  421          prop2 = get_prop(dmake_name2->prop, macro_prop);
 419      -        if (prop2 == NULL) {
 420      -                /* DMAKE_MODE not defined, default to parallel mode */
 421      -                dmake_mode_type = parallel_mode;
 422      -                no_parallel = false;
      422 +        // If we're invoked as 'make' run serially, regardless of DMAKE_MODE
      423 +        // If we're invoked as 'make' but passed -j, run parallel
      424 +        // If we're invoked as 'dmake', without DMAKE_MODE, default parallel
      425 +        // If we're invoked as 'dmake' and DMAKE_MODE is set, honour it.
      426 +        if ((strcmp(basename(s), NOCATGETS("make")) == 0) &&
      427 +            !dmake_max_jobs_specified) {
      428 +                dmake_mode_type = serial_mode;
      429 +                no_parallel = true;
      430 +        } else if (prop2 == NULL) {
      431 +                /* DMAKE_MODE not defined, default based on our name */
      432 +                char *s = strdup(argv[0]);
      433 +
      434 +                if (strcmp(basename(s), NOCATGETS("dmake")) == 0) {
      435 +                        dmake_mode_type = parallel_mode;
      436 +                        no_parallel = false;
      437 +                }
 423  438          } else {
 424  439                  dmake_value2 = prop2->body.macro.value;
 425  440                  if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("parallel"))) {
 426  441                          dmake_mode_type = parallel_mode;
 427  442                          no_parallel = false;
 428  443                  } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("serial"))) {
 429  444                          dmake_mode_type = serial_mode;
 430  445                          no_parallel = true;
 431  446                  } else {
 432  447                          fatal(catgets(catd, 1, 307, "Unknown dmake mode argument `%s' after -m flag"), dmake_value2->string_mb);
 433  448                  }
 434  449          }
 435      -
      450 +        free(s);
 436  451      }
 437  452  
 438  453          parallel_flag = true;
 439  454          putenv(strdup(NOCATGETS("DMAKE_CHILD=TRUE")));
 440  455  
 441  456  //
 442  457  // If dmake is running with -t option, set dmake_mode_type to serial.
 443  458  // This is done because doname() calls touch_command() that runs serially.
 444  459  // If we do not do that, maketool will have problems. 
 445  460  //
↓ open down ↓ 910 lines elided ↑ open up ↑
1356 1371                  if (invert_this) {
1357 1372                          ignore_errors_all = false;
1358 1373                  } else {
1359 1374                          ignore_errors_all = true;
1360 1375                  }
1361 1376                  return 0;
1362 1377          case 'j':                        /* Use alternative DMake max jobs */
1363 1378                  if (invert_this) {
1364 1379                          dmake_max_jobs_specified = false;
1365 1380                  } else {
     1381 +                        dmake_mode_type = parallel_mode;
     1382 +                        no_parallel = false;
1366 1383                          dmake_max_jobs_specified = true;
1367 1384                  }
1368 1385                  return 8;
1369 1386          case 'K':                        /* Read alternative .make.state */
1370 1387                  return 256;
1371 1388          case 'k':                        /* Keep making even after errors */
1372 1389                  if (invert_this) {
1373 1390                          continue_after_error = false;
1374 1391                  } else {
1375 1392                          continue_after_error = true;
↓ open down ↓ 1861 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX