Print this page
make: remove maketool support

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/make/lib/mksh/dosys.cc
          +++ new/usr/src/cmd/make/lib/mksh/dosys.cc
↓ open down ↓ 41 lines elided ↑ open up ↑
  42   42  #include <mksh/dosys.h>
  43   43  #include <mksh/macro.h>         /* getvar() */
  44   44  #include <mksh/misc.h>          /* getmem(), fatal_mksh(), errmsg() */
  45   45  #include <mksdmsi18n/mksdmsi18n.h>      /* libmksdmsi18n_init() */
  46   46  #include <sys/signal.h>         /* SIG_DFL */
  47   47  #include <sys/stat.h>           /* open() */
  48   48  #include <sys/wait.h>           /* wait() */
  49   49  #include <ulimit.h>             /* ulimit() */
  50   50  #include <unistd.h>             /* close(), dup2() */
  51   51  
  52      -
  53      -
  54      -/*
  55      - * Defined macros
  56      - */
  57      -#define SEND_MTOOL_MSG(cmds)
  58      -
  59   52  /*
  60   53   * typedefs & structs
  61   54   */
  62   55  
  63   56  /*
  64   57   * Static variables
  65   58   */
  66   59  
  67   60  /*
  68   61   * File table of contents
↓ open down ↓ 60 lines elided ↑ open up ↑
 129  122          } else {
 130  123                  if (dup2(i, 2) == -1) {
 131  124                          fatal_mksh(NOCATGETS("*** Error: dup2(3, 2) failed: %s"),
 132  125                                  errmsg(errno));
 133  126                  }
 134  127                  close(i);
 135  128          }
 136  129  }
 137  130  
 138  131  /*
 139      - *      dosys_mksh(command, ignore_error, call_make, silent_error, target)
 140      - *
 141      - *      Check if command string contains meta chars and dispatch to
 142      - *      the proper routine for executing one command line.
 143      - *
 144      - *      Return value:
 145      - *                              Indicates if the command execution failed
 146      - *
 147      - *      Parameters:
 148      - *              command         The command to run
 149      - *              ignore_error    Should we abort when an error is seen?
 150      - *              call_make       Did command reference $(MAKE) ?
 151      - *              silent_error    Should error messages be suppressed for dmake?
 152      - *              target          Target we are building
 153      - *
 154      - *      Global variables used:
 155      - *              do_not_exec_rule Is -n on?
 156      - *              working_on_targets We started processing real targets
 157      - */
 158      -Doname
 159      -dosys_mksh(register Name command, register Boolean ignore_error, register Boolean call_make, Boolean silent_error, Boolean always_exec, Name target, Boolean redirect_out_err, char *stdout_file, char *stderr_file, pathpt vroot_path, int nice_prio)
 160      -{
 161      -        register int            length = command->hash.length;
 162      -        register wchar_t        *p;
 163      -        register wchar_t        *q;
 164      -        register wchar_t        *cmd_string;
 165      -        struct stat             before;
 166      -        Doname                  result;
 167      -        Boolean                 working_on_targets_mksh = true;
 168      -        Wstring wcb(command);
 169      -        p = wcb.get_string();
 170      -        cmd_string = p;
 171      -
 172      -        /* Strip spaces from head of command string */
 173      -        while (iswspace(*p)) {
 174      -                p++, length--;
 175      -        }
 176      -        if (*p == (int) nul_char) {
 177      -                return build_failed;
 178      -        }
 179      -        /* If we are faking it we just return */
 180      -        if (do_not_exec_rule &&
 181      -            working_on_targets_mksh &&
 182      -            !call_make &&
 183      -            !always_exec) {
 184      -                return build_ok;
 185      -        }
 186      -
 187      -        /* Copy string to make it OK to write it. */
 188      -        q = ALLOC_WC(length + 1);
 189      -        (void) wscpy(q, p);
 190      -        /* Write the state file iff this command uses make. */
 191      -/* XXX - currently does not support recursive make's, $(MAKE)'s
 192      -        if (call_make && command_changed) {
 193      -                write_state_file(0, false);
 194      -        }
 195      -        (void) stat(make_state->string_mb, &before);
 196      - */
 197      -        /*
 198      -         * Run command directly if it contains no shell meta chars,
 199      -         * else run it using the shell.
 200      -         */
 201      -        /* XXX - command->meta *may* not be set correctly */
 202      -        if (await(ignore_error,
 203      -                  silent_error,
 204      -                  target,
 205      -                  cmd_string,
 206      -                  command->meta ?
 207      -                    doshell(q, ignore_error, redirect_out_err, stdout_file, stderr_file, nice_prio) :
 208      -                    doexec(q, ignore_error, redirect_out_err, stdout_file, stderr_file, vroot_path, nice_prio),
 209      -                  false,
 210      -                  NULL,
 211      -                  -1)) {
 212      -
 213      -#ifdef PRINT_EXIT_STATUS
 214      -                warning_mksh(NOCATGETS("I'm in dosys_mksh(), and await() returned result of build_ok."));
 215      -#endif
 216      -
 217      -                result = build_ok;
 218      -        } else {
 219      -
 220      -#ifdef PRINT_EXIT_STATUS
 221      -                warning_mksh(NOCATGETS("I'm in dosys_mksh(), and await() returned result of build_failed."));
 222      -#endif
 223      -
 224      -                result = build_failed;
 225      -        }
 226      -        retmem(q);
 227      -
 228      -/* XXX - currently does not support recursive make's, $(MAKE)'s
 229      -        if ((report_dependencies_level == 0) &&
 230      -            call_make) {
 231      -                make_state->stat.time = (time_t)file_no_time;
 232      -                (void)exists(make_state);
 233      -                if (before.st_mtime == make_state->stat.time) {
 234      -                        return result;
 235      -                }
 236      -                makefile_type = reading_statefile;
 237      -                if (read_trace_level > 1) {
 238      -                        trace_reader = true;
 239      -                }
 240      -                (void) read_simple_file(make_state,
 241      -                                        false,
 242      -                                        false,
 243      -                                        false,
 244      -                                        false,
 245      -                                        false,
 246      -                                        true);
 247      -                trace_reader = false;
 248      -        }
 249      - */
 250      -        return result;
 251      -}
 252      -
 253      -/*
 254  132   *      doshell(command, ignore_error)
 255  133   *
 256  134   *      Used to run command lines that include shell meta-characters.
 257  135   *      The make macro SHELL is supposed to contain a path to the shell.
 258  136   *
 259  137   *      Return value:
 260  138   *                              The pid of the process we started
 261  139   *
 262  140   *      Parameters:
 263  141   *              command         The command to run
 264  142   *              ignore_error    Should we abort on error?
 265  143   *
 266  144   *      Global variables used:
 267  145   *              filter_stderr   If -X is on we redirect stderr
 268  146   *              shell_name      The Name "SHELL", used to get the path to shell
 269  147   */
 270  148  int
 271      -doshell(wchar_t *command, register Boolean ignore_error, Boolean redirect_out_err, char *stdout_file, char *stderr_file, int nice_prio)
      149 +doshell(wchar_t *command, register Boolean ignore_error, char *stdout_file, char *stderr_file, int nice_prio)
 272  150  {
 273  151          char                    *argv[6];
 274  152          int                     argv_index = 0;
 275  153          int                     cmd_argv_index;
 276  154          int                     length;
 277  155          char                    nice_prio_buf[MAXPATHLEN];
 278  156          register Name           shell = getvar(shell_name);
 279  157          register char           *shellname;
 280  158          char                    *tmp_mbs_buffer;
 281  159  
↓ open down ↓ 27 lines elided ↑ open up ↑
 309  187                  retmem_mb(tmp_mbs_buffer);
 310  188          } else {
 311  189                  WCSTOMBS(mbs_buffer, command);
 312  190                  cmd_argv_index = argv_index;
 313  191                  argv[argv_index++] = strdup(mbs_buffer);
 314  192          }
 315  193          argv[argv_index] = NULL;
 316  194          (void) fflush(stdout);
 317  195          if ((childPid = fork()) == 0) {
 318  196                  enable_interrupt((void (*) (int)) SIG_DFL);
 319      -                if (redirect_out_err) {
 320      -                        redirect_io(stdout_file, stderr_file);
 321      -                }
 322  197  #if 0
 323  198                  if (filter_stderr) {
 324  199                          redirect_stderr();
 325  200                  }
 326  201  #endif
 327  202                  if (nice_prio != 0) {
 328  203                          (void) execve(NOCATGETS("/usr/bin/nice"), argv, environ);
 329  204                          fatal_mksh(catgets(libmksdmsi18n_catd, 1, 92, "Could not load `/usr/bin/nice': %s"),
 330  205                                errmsg(errno));
 331  206                  } else {
↓ open down ↓ 97 lines elided ↑ open up ↑
 429  304   *                              The pid of the process started here
 430  305   *
 431  306   *      Parameters:
 432  307   *              command         The command to run
 433  308   *              ignore_error    Should we abort on error?
 434  309   *
 435  310   *      Global variables used:
 436  311   *              filter_stderr   If -X is on we redirect stderr
 437  312   */
 438  313  int
 439      -doexec(register wchar_t *command, register Boolean ignore_error, Boolean redirect_out_err, char *stdout_file, char *stderr_file, pathpt vroot_path, int nice_prio)
      314 +doexec(register wchar_t *command, register Boolean ignore_error, char *stdout_file, char *stderr_file, pathpt vroot_path, int nice_prio)
 440  315  {
 441  316          int                     arg_count = 5;
 442  317          char                    **argv;
 443  318          int                     length;
 444  319          char                    nice_prio_buf[MAXPATHLEN];
 445  320          register char           **p;
 446  321          wchar_t                 *q;
 447  322          register wchar_t        *t;
 448  323          char                    *tmp_mbs_buffer;
 449  324  
↓ open down ↓ 57 lines elided ↑ open up ↑
 507  382                          WCSTOMBS(mbs_buffer, q);
 508  383                          *p++ = strdup(mbs_buffer);
 509  384                  }
 510  385          }
 511  386          *p = NULL;
 512  387  
 513  388          /* Then exec the command with that argument list. */
 514  389          (void) fflush(stdout);
 515  390          if ((childPid = fork()) == 0) {
 516  391                  enable_interrupt((void (*) (int)) SIG_DFL);
 517      -                if (redirect_out_err) {
 518      -                        redirect_io(stdout_file, stderr_file);
 519      -                }
 520  392  #if 0
 521  393                  if (filter_stderr) {
 522  394                          redirect_stderr();
 523  395                  }
 524  396  #endif
 525  397                  (void) exec_vp(argv[1], argv, environ, ignore_error, vroot_path);
 526  398                  fatal_mksh(catgets(libmksdmsi18n_catd, 1, 96, "Cannot load command `%s': %s"), argv[1], errmsg(errno));
 527  399          }
 528  400          if (childPid  == -1) {
 529  401                  fatal_mksh(catgets(libmksdmsi18n_catd, 1, 97, "fork failed: %s"),
↓ open down ↓ 22 lines elided ↑ open up ↑
 552  424   *              running_pid     The pid of the process we are waiting for
 553  425   *              
 554  426   *      Static variables used:
 555  427   *              filter_file     The fd for the filter file
 556  428   *              filter_file_name The name of the filter file
 557  429   *
 558  430   *      Global variables used:
 559  431   *              filter_stderr   Set if -X is on
 560  432   */
 561  433  Boolean
 562      -await(register Boolean ignore_error, register Boolean silent_error, Name target, wchar_t *command, pid_t running_pid, Boolean send_mtool_msgs, void *xdrs_p, int job_msg_id)
      434 +await(register Boolean ignore_error, register Boolean silent_error, Name target, wchar_t *command, pid_t running_pid, void *xdrs_p, int job_msg_id)
 563  435  {
 564  436          int                     status;
 565  437          char                    *buffer;
 566  438          int                     core_dumped;
 567  439          int                     exit_status;
 568  440          FILE                    *outfp;
 569  441          register pid_t          pid;
 570  442          struct stat             stat_buff;
 571  443          int                     termination_signal;
 572  444          char                    tmp_buf[MAXPATHLEN];
↓ open down ↓ 26 lines elided ↑ open up ↑
 599  471          warning_mksh(NOCATGETS("I'm in await(), and exit_status is %d."), exit_status);
 600  472  #endif
 601  473  
 602  474          termination_signal = WTERMSIG(status);
 603  475          core_dumped = WCOREDUMP(status);
 604  476  
 605  477          /*
 606  478           * If the child returned an error, we now try to print a
 607  479           * nice message about it.
 608  480           */
 609      -        SEND_MTOOL_MSG(
 610      -                make_output_msg = new Avo_CmdOutput();
 611      -                (void) sprintf(tmp_buf, "%d", job_msg_id);
 612      -                make_output_msg->appendOutput(strdup(tmp_buf));
 613      -        );
 614      -
      481 +        
 615  482          tmp_buf[0] = (int) nul_char;
 616  483          if (!silent_error) {
 617  484                  if (exit_status != 0) {
 618  485                          (void) fprintf(stdout,
 619  486                                         catgets(libmksdmsi18n_catd, 1, 103, "*** Error code %d"),
 620  487                                         exit_status);
 621      -                        SEND_MTOOL_MSG(
 622      -                                (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 623      -                                               catgets(libmksdmsi18n_catd, 1, 104, "*** Error code %d"),
 624      -                                               exit_status);
 625      -                        );
 626  488                  } else {
 627  489                                  (void) fprintf(stdout,
 628  490                                                 catgets(libmksdmsi18n_catd, 1, 105, "*** Signal %d"),
 629  491                                                 termination_signal);
 630      -                                SEND_MTOOL_MSG(
 631      -                                        (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 632      -                                                       catgets(libmksdmsi18n_catd, 1, 106, "*** Signal %d"),
 633      -                                                       termination_signal);
 634      -                                );
 635  492                          if (core_dumped) {
 636  493                                  (void) fprintf(stdout,
 637  494                                                 catgets(libmksdmsi18n_catd, 1, 107, " - core dumped"));
 638      -                                SEND_MTOOL_MSG(
 639      -                                        (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 640      -                                                       catgets(libmksdmsi18n_catd, 1, 108, " - core dumped"));
 641      -                                );
 642  495                          }
 643  496                  }
 644  497                  if (ignore_error) {
 645  498                          (void) fprintf(stdout,
 646  499                                         catgets(libmksdmsi18n_catd, 1, 109, " (ignored)"));
 647      -                        SEND_MTOOL_MSG(
 648      -                                (void) sprintf(&tmp_buf[strlen(tmp_buf)],
 649      -                                               catgets(libmksdmsi18n_catd, 1, 110, " (ignored)"));
 650      -                        );
 651  500                  }
 652  501                  (void) fprintf(stdout, "\n");
 653  502                  (void) fflush(stdout);
 654      -                SEND_MTOOL_MSG(
 655      -                        make_output_msg->appendOutput(strdup(tmp_buf));
 656      -                );
 657      -        }
 658      -        SEND_MTOOL_MSG(
 659      -                xdr_msg = (RWCollectable*) make_output_msg;
 660      -                xdr(xdrs_p, xdr_msg);
 661      -                delete make_output_msg;
 662      -        );
      503 +        }
 663  504  
 664  505  #ifdef PRINT_EXIT_STATUS
 665  506          warning_mksh(NOCATGETS("I'm in await(), returning failed."));
 666  507  #endif
 667  508  
 668  509          return failed;
 669  510  }
 670  511  
 671  512  /*
 672  513   *      sh_command2string(command, destination)
↓ open down ↓ 65 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX