Print this page
make: unifdef SUN5_0 (defined)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/bin/main.cc
+++ new/usr/src/cmd/make/bin/main.cc
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 /*
27 27 * main.cc
28 28 *
29 29 * make program main routine plus some helper routines
30 30 */
31 31
32 32 /*
33 33 * Included files
34 34 */
35 35 #if defined(TEAMWARE_MAKE_CMN)
36 36 # include <avo/intl.h>
37 37 # include <avo/libcli.h> /* libcli_init() */
38 38 # include <avo/cli_license.h> /* avo_cli_get_license() */
39 39 # include <avo/find_dir.h> /* avo_find_run_dir() */
40 40 # include <avo/version_string.h>
41 41 # include <avo/util.h> /* avo_init() */
42 42 #ifdef USE_DMS_CCR
43 43 # include <avo/usage_tracking.h>
44 44 #else
45 45 # include <avo/cleanup.h>
46 46 #endif
47 47 #endif
48 48
49 49 #if defined(TEAMWARE_MAKE_CMN)
50 50 /* This is for dmake only (not for Solaris make).
51 51 * Include code to check updates (dmake patches)
52 52 */
53 53 #ifdef _CHECK_UPDATE_H
54 54 #include <libAU.h>
55 55 #endif
56 56 #endif
57 57
58 58 #include <bsd/bsd.h> /* bsd_signal() */
59 59
60 60 #ifdef DISTRIBUTED
61 61 # include <dm/Avo_AcknowledgeMsg.h>
62 62 # include <rw/xdrstrea.h>
63 63 # include <dmrc/dmrc.h> /* dmakerc file processing */
64 64 #endif
65 65
66 66 #include <locale.h> /* setlocale() */
67 67 #include <mk/defs.h>
68 68 #include <mksdmsi18n/mksdmsi18n.h> /* libmksdmsi18n_init() */
69 69 #include <mksh/macro.h> /* getvar() */
70 70 #include <mksh/misc.h> /* getmem(), setup_char_semantics() */
71 71
72 72 #if defined(TEAMWARE_MAKE_CMN)
73 73 #ifdef USE_DMS_CCR
74 74 # include <pubdmsi18n/pubdmsi18n.h> /* libpubdmsi18n_init() */
75 75 #endif
↓ open down ↓ |
75 lines elided |
↑ open up ↑ |
76 76 #endif
77 77
78 78 #include <pwd.h> /* getpwnam() */
79 79 #include <setjmp.h>
80 80 #include <signal.h>
81 81 #include <stdlib.h>
82 82 #include <sys/errno.h> /* ENOENT */
83 83 #include <sys/stat.h> /* fstat() */
84 84 #include <fcntl.h> /* open() */
85 85
86 -#ifdef SUN5_0
87 86 # include <sys/systeminfo.h> /* sysinfo() */
88 -#endif
89 87
90 88 #include <sys/types.h> /* stat() */
91 89 #include <sys/wait.h> /* wait() */
92 90 #include <unistd.h> /* execv(), unlink(), access() */
93 91 #include <vroot/report.h> /* report_dependency(), get_report_file() */
94 92
95 93 // From read2.cc
96 94 extern Name normalize_name(register wchar_t *name_string, register int length);
97 95
98 96 // From parallel.cc
99 97 #if defined(TEAMWARE_MAKE_CMN)
100 98 #define MAXJOBS_ADJUST_RFE4694000
101 99
102 100 #ifdef MAXJOBS_ADJUST_RFE4694000
103 101 extern void job_adjust_fini();
104 102 #endif /* MAXJOBS_ADJUST_RFE4694000 */
105 103 #endif /* TEAMWARE_MAKE_CMN */
106 104
107 105 #if defined(linux)
108 106 #include <ctype.h>
109 107 #endif
110 108
111 109 /*
112 110 * Defined macros
113 111 */
114 112 #define LD_SUPPORT_ENV_VAR NOCATGETS("SGS_SUPPORT")
115 113 #define LD_SUPPORT_MAKE_LIB NOCATGETS("libmakestate.so.1")
116 114
117 115 /*
118 116 * typedefs & structs
119 117 */
120 118
121 119 /*
122 120 * Static variables
123 121 */
124 122 static char *argv_zero_string;
125 123 static Boolean build_failed_ever_seen;
126 124 static Boolean continue_after_error_ever_seen; /* `-k' */
127 125 static Boolean dmake_group_specified; /* `-g' */
128 126 static Boolean dmake_max_jobs_specified; /* `-j' */
129 127 static Boolean dmake_mode_specified; /* `-m' */
130 128 static Boolean dmake_add_mode_specified; /* `-x' */
131 129 static Boolean dmake_output_mode_specified; /* `-x DMAKE_OUTPUT_MODE=' */
132 130 static Boolean dmake_compat_mode_specified; /* `-x SUN_MAKE_COMPAT_MODE=' */
133 131 static Boolean dmake_odir_specified; /* `-o' */
134 132 static Boolean dmake_rcfile_specified; /* `-c' */
135 133 static Boolean env_wins; /* `-e' */
136 134 static Boolean ignore_default_mk; /* `-r' */
137 135 static Boolean list_all_targets; /* `-T' */
138 136 static int mf_argc;
139 137 static char **mf_argv;
140 138 static Dependency_rec not_auto_depen_struct;
141 139 static Dependency not_auto_depen = ¬_auto_depen_struct;
142 140 static Boolean pmake_cap_r_specified; /* `-R' */
143 141 static Boolean pmake_machinesfile_specified; /* `-M' */
144 142 static Boolean stop_after_error_ever_seen; /* `-S' */
145 143 static Boolean trace_status; /* `-p' */
146 144
147 145 #ifdef DMAKE_STATISTICS
148 146 static Boolean getname_stat = false;
149 147 #endif
150 148
151 149 #if defined(TEAMWARE_MAKE_CMN)
152 150 static time_t start_time;
153 151 static int g_argc;
154 152 static char **g_argv;
↓ open down ↓ |
56 lines elided |
↑ open up ↑ |
155 153 #ifdef USE_DMS_CCR
156 154 static Avo_usage_tracking *usageTracking = NULL;
157 155 #else
158 156 static Avo_cleanup *cleanup = NULL;
159 157 #endif
160 158 #endif
161 159
162 160 /*
163 161 * File table of contents
164 162 */
165 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
166 163 extern "C" void cleanup_after_exit(void);
167 -#else
168 - extern void cleanup_after_exit(int, ...);
169 -#endif
170 164
171 165 #ifdef TEAMWARE_MAKE_CMN
172 166 extern "C" {
173 167 extern void dmake_exit_callback(void);
174 168 extern void dmake_message_callback(char *);
175 169 }
176 170 #endif
177 171
178 172 extern Name normalize_name(register wchar_t *name_string, register int length);
179 173
180 174 extern int main(int, char * []);
181 175
182 176 static void append_makeflags_string(Name, String);
183 177 static void doalarm(int);
184 178 static void enter_argv_values(int , char **, ASCII_Dyn_Array *);
185 179 static void make_targets(int, char **, Boolean);
186 180 static int parse_command_option(char);
187 181 static void read_command_options(int, char **);
188 182 static void read_environment(Boolean);
189 183 static void read_files_and_state(int, char **);
190 184 static Boolean read_makefile(Name, Boolean, Boolean, Boolean);
191 185 static void report_recursion(Name);
192 186 static void set_sgs_support(void);
193 187 static void setup_for_projectdir(void);
194 188 static void setup_makeflags_argv(void);
195 189 static void report_dir_enter_leave(Boolean entering);
196 190
197 191 extern void expand_value(Name, register String , Boolean);
198 192
199 193 #ifdef DISTRIBUTED
200 194 extern int dmake_ofd;
201 195 extern FILE* dmake_ofp;
202 196 extern int rxmPid;
203 197 extern XDR xdrs_out;
204 198 #endif
205 199 #ifdef TEAMWARE_MAKE_CMN
206 200 extern char verstring[];
207 201 #endif
208 202
209 203 jmp_buf jmpbuffer;
210 204 #if !defined(linux)
211 205 extern nl_catd catd;
212 206 #endif
213 207
214 208 /*
215 209 * main(argc, argv)
216 210 *
217 211 * Parameters:
218 212 * argc You know what this is
219 213 * argv You know what this is
220 214 *
221 215 * Static variables used:
222 216 * list_all_targets make -T seen
223 217 * trace_status make -p seen
224 218 *
225 219 * Global variables used:
226 220 * debug_level Should we trace make actions?
227 221 * keep_state Set if .KEEP_STATE seen
228 222 * makeflags The Name "MAKEFLAGS", used to get macro
229 223 * remote_command_name Name of remote invocation cmd ("on")
230 224 * running_list List of parallel running processes
231 225 * stdout_stderr_same true if stdout and stderr are the same
232 226 * auto_dependencies The Name "SUNPRO_DEPENDENCIES"
233 227 * temp_file_directory Set to the dir where we create tmp file
234 228 * trace_reader Set to reflect tracing status
235 229 * working_on_targets Set when building user targets
236 230 */
237 231 int
238 232 main(int argc, char *argv[])
239 233 {
240 234 /*
241 235 * cp is a -> to the value of the MAKEFLAGS env var,
242 236 * which has to be regular chars.
243 237 */
244 238 register char *cp;
245 239 char make_state_dir[MAXPATHLEN];
246 240 Boolean parallel_flag = false;
247 241 char *prognameptr;
248 242 char *slash_ptr;
249 243 mode_t um;
250 244 int i;
251 245 #ifdef TEAMWARE_MAKE_CMN
252 246 struct itimerval value;
253 247 char def_dmakerc_path[MAXPATHLEN];
254 248 Name dmake_name, dmake_name2;
255 249 Name dmake_value, dmake_value2;
256 250 Property prop, prop2;
257 251 struct stat statbuf;
258 252 int statval;
259 253 #endif
260 254
261 255 #ifndef PARALLEL
262 256 struct stat out_stat, err_stat;
263 257 #endif
264 258 hostid = gethostid();
265 259 #ifdef TEAMWARE_MAKE_CMN
266 260 avo_get_user(NULL, NULL); // Initialize user name
267 261 #endif
268 262 bsd_signals();
269 263
270 264 (void) setlocale(LC_ALL, "");
271 265
272 266 #if defined (HP_UX) || defined(linux)
273 267 /* HP-UX users typically will not have NLSPATH set, and this binary
274 268 * requires that it be set. On HP-UX 9.0x, /usr/lib/nls/%L/%N.cat is
275 269 * the path to set it to.
276 270 */
277 271
278 272 if (getenv(NOCATGETS("NLSPATH")) == NULL) {
279 273 putenv(NOCATGETS("NLSPATH=/usr/lib/nls/%L/%N.cat"));
280 274 }
281 275 #endif
282 276
283 277 #ifdef DMAKE_STATISTICS
284 278 if (getenv(NOCATGETS("DMAKE_STATISTICS"))) {
285 279 getname_stat = true;
286 280 }
287 281 #endif
288 282
289 283
290 284 /*
291 285 * avo_init() sets the umask to 0. Save it here and restore
292 286 * it after the avo_init() call.
293 287 */
294 288 #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL)
295 289 um = umask(0);
296 290 avo_init(argv[0]);
297 291 umask(um);
298 292
299 293 #ifdef USE_DMS_CCR
300 294 usageTracking = new Avo_usage_tracking(NOCATGETS("dmake"), argc, argv);
301 295 #else
302 296 cleanup = new Avo_cleanup(NOCATGETS("dmake"), argc, argv);
303 297 #endif
304 298 #endif
305 299
306 300 #if defined(TEAMWARE_MAKE_CMN)
307 301 catd = catopen(AVO_DOMAIN_DMAKE, NL_CAT_LOCALE);
308 302 libcli_init();
309 303
310 304 #ifdef _CHECK_UPDATE_H
311 305 /* This is for dmake only (not for Solaris make).
312 306 * Check (in background) if there is an update (dmake patch)
313 307 * and inform user
314 308 */
315 309 {
316 310 Avo_err *err;
317 311 char *dir;
318 312 err = avo_find_run_dir(&dir);
319 313 if (AVO_OK == err) {
320 314 AU_check_update_service(NOCATGETS("Dmake"), dir);
321 315 }
322 316 }
323 317 #endif /* _CHECK_UPDATE_H */
324 318 #endif
325 319
326 320 // ---> fprintf(stderr, catgets(catd, 15, 666, "--- SUN make ---\n"));
327 321
328 322
329 323 #if defined(TEAMWARE_MAKE_CMN) || defined(MAKETOOL)
330 324 /*
331 325 * I put libmksdmsi18n_init() under #ifdef because it requires avo_i18n_init()
332 326 * from avo_util library.
333 327 */
334 328 libmksdmsi18n_init();
335 329 #ifdef USE_DMS_CCR
336 330 libpubdmsi18n_init();
337 331 #endif
338 332 #endif
339 333
340 334
341 335 #ifndef TEAMWARE_MAKE_CMN
342 336 textdomain(NOCATGETS("SUNW_SPRO_MAKE"));
343 337 #endif /* TEAMWARE_MAKE_CMN */
344 338
345 339 #ifdef TEAMWARE_MAKE_CMN
346 340 g_argc = argc;
347 341 g_argv = (char **) malloc((g_argc + 1) * sizeof(char *));
348 342 for (i = 0; i < argc; i++) {
349 343 g_argv[i] = argv[i];
350 344 }
351 345 g_argv[i] = NULL;
352 346 #endif /* TEAMWARE_MAKE_CMN */
353 347
354 348 /*
355 349 * Set argv_zero_string to some form of argv[0] for
356 350 * recursive MAKE builds.
357 351 */
358 352
359 353 if (*argv[0] == (int) slash_char) {
360 354 /* argv[0] starts with a slash */
361 355 argv_zero_string = strdup(argv[0]);
362 356 } else if (strchr(argv[0], (int) slash_char) == NULL) {
363 357 /* argv[0] contains no slashes */
364 358 argv_zero_string = strdup(argv[0]);
365 359 } else {
366 360 /*
367 361 * argv[0] contains at least one slash,
368 362 * but doesn't start with a slash
369 363 */
370 364 char *tmp_current_path;
371 365 char *tmp_string;
372 366
373 367 tmp_current_path = get_current_path();
374 368 tmp_string = getmem(strlen(tmp_current_path) + 1 +
375 369 strlen(argv[0]) + 1);
376 370 (void) sprintf(tmp_string,
377 371 "%s/%s",
378 372 tmp_current_path,
379 373 argv[0]);
380 374 argv_zero_string = strdup(tmp_string);
381 375 retmem_mb(tmp_string);
382 376 }
383 377
384 378 /*
385 379 * The following flags are reset if we don't have the
386 380 * (.nse_depinfo or .make.state) files locked and only set
387 381 * AFTER the file has been locked. This ensures that if the user
388 382 * interrupts the program while file_lock() is waiting to lock
389 383 * the file, the interrupt handler doesn't remove a lock
390 384 * that doesn't belong to us.
391 385 */
392 386 make_state_lockfile = NULL;
393 387 make_state_locked = false;
394 388
395 389 #ifdef NSE
396 390 nse_depinfo_lockfile[0] = '\0';
397 391 nse_depinfo_locked = false;
398 392 #endif
399 393
400 394 /*
401 395 * look for last slash char in the path to look at the binary
402 396 * name. This is to resolve the hard link and invoke make
403 397 * in svr4 mode.
404 398 */
405 399
406 400 /* Sun OS make standart */
407 401 svr4 = false;
408 402 posix = false;
409 403 if(!strcmp(argv_zero_string, NOCATGETS("/usr/xpg4/bin/make"))) {
410 404 svr4 = false;
411 405 posix = true;
412 406 } else {
413 407 prognameptr = strrchr(argv[0], '/');
414 408 if(prognameptr) {
415 409 prognameptr++;
416 410 } else {
417 411 prognameptr = argv[0];
418 412 }
419 413 if(!strcmp(prognameptr, NOCATGETS("svr4.make"))) {
420 414 svr4 = true;
421 415 posix = false;
422 416 }
423 417 }
424 418 #if !defined(HP_UX) && !defined(linux)
425 419 if (getenv(USE_SVR4_MAKE) || getenv(NOCATGETS("USE_SVID"))){
426 420 svr4 = true;
427 421 posix = false;
428 422 }
429 423 #endif
430 424
431 425 /*
432 426 * Find the dmake_compat_mode: posix, sun, svr4, or gnu_style, .
433 427 */
434 428 char * dmake_compat_mode_var = getenv(NOCATGETS("SUN_MAKE_COMPAT_MODE"));
435 429 if (dmake_compat_mode_var != NULL) {
436 430 if (0 == strcasecmp(dmake_compat_mode_var, NOCATGETS("GNU"))) {
437 431 gnu_style = true;
438 432 }
439 433 //svr4 = false;
440 434 //posix = false;
441 435 }
442 436
443 437 /*
444 438 * Temporary directory set up.
445 439 */
446 440 char * tmpdir_var = getenv(NOCATGETS("TMPDIR"));
447 441 if (tmpdir_var != NULL && *tmpdir_var == '/' && strlen(tmpdir_var) < MAXPATHLEN) {
448 442 strcpy(mbs_buffer, tmpdir_var);
449 443 for (tmpdir_var = mbs_buffer+strlen(mbs_buffer);
450 444 *(--tmpdir_var) == '/' && tmpdir_var > mbs_buffer;
451 445 *tmpdir_var = '\0');
452 446 if (strlen(mbs_buffer) + 32 < MAXPATHLEN) { /* 32 = strlen("/dmake.stdout.%d.%d.XXXXXX") */
453 447 sprintf(mbs_buffer2, NOCATGETS("%s/dmake.tst.%d.XXXXXX"),
454 448 mbs_buffer, getpid());
455 449 int fd = mkstemp(mbs_buffer2);
456 450 if (fd >= 0) {
457 451 close(fd);
458 452 unlink(mbs_buffer2);
459 453 tmpdir = strdup(mbs_buffer);
460 454 }
461 455 }
462 456 }
463 457
464 458 #ifndef PARALLEL
465 459 /* find out if stdout and stderr point to the same place */
466 460 if (fstat(1, &out_stat) < 0) {
467 461 fatal(catgets(catd, 1, 165, "fstat of standard out failed: %s"), errmsg(errno));
468 462 }
469 463 if (fstat(2, &err_stat) < 0) {
470 464 fatal(catgets(catd, 1, 166, "fstat of standard error failed: %s"), errmsg(errno));
471 465 }
472 466 if ((out_stat.st_dev == err_stat.st_dev) &&
473 467 (out_stat.st_ino == err_stat.st_ino)) {
474 468 stdout_stderr_same = true;
475 469 } else {
476 470 stdout_stderr_same = false;
477 471 }
478 472 #else
479 473 stdout_stderr_same = false;
480 474 #endif
481 475 /* Make the vroot package scan the path using shell semantics */
↓ open down ↓ |
302 lines elided |
↑ open up ↑ |
482 476 set_path_style(0);
483 477
484 478 setup_char_semantics();
485 479
486 480 setup_for_projectdir();
487 481
488 482 /*
489 483 * If running with .KEEP_STATE, curdir will be set with
490 484 * the connected directory.
491 485 */
492 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
493 486 (void) atexit(cleanup_after_exit);
494 -#else
495 - (void) on_exit(cleanup_after_exit, (char *) NULL);
496 -#endif
497 487
498 488 load_cached_names();
499 489
500 490 /*
501 491 * Set command line flags
502 492 */
503 493 setup_makeflags_argv();
504 494 read_command_options(mf_argc, mf_argv);
505 495 read_command_options(argc, argv);
506 496 if (debug_level > 0) {
507 497 cp = getenv(makeflags->string_mb);
508 498 (void) printf(catgets(catd, 1, 167, "MAKEFLAGS value: %s\n"), cp == NULL ? "" : cp);
509 499 }
510 500
511 501 setup_interrupt(handle_interrupt);
512 502
513 503 read_files_and_state(argc, argv);
514 504
515 505 #ifdef TEAMWARE_MAKE_CMN
516 506 /*
517 507 * Find the dmake_output_mode: TXT1, TXT2 or HTML1.
518 508 */
519 509 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_OUTPUT_MODE"));
520 510 dmake_name2 = GETNAME(wcs_buffer, FIND_LENGTH);
521 511 prop2 = get_prop(dmake_name2->prop, macro_prop);
522 512 if (prop2 == NULL) {
523 513 /* DMAKE_OUTPUT_MODE not defined, default to TXT1 mode */
524 514 output_mode = txt1_mode;
525 515 } else {
526 516 dmake_value2 = prop2->body.macro.value;
527 517 if ((dmake_value2 == NULL) ||
528 518 (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("TXT1")))) {
529 519 output_mode = txt1_mode;
530 520 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("TXT2"))) {
531 521 output_mode = txt2_mode;
532 522 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("HTML1"))) {
533 523 output_mode = html1_mode;
534 524 } else {
535 525 warning(catgets(catd, 1, 352, "Unsupported value `%s' for DMAKE_OUTPUT_MODE after -x flag (ignored)"),
536 526 dmake_value2->string_mb);
537 527 }
538 528 }
539 529 /*
540 530 * Find the dmake_mode: distributed, parallel, or serial.
541 531 */
542 532 if ((!pmake_cap_r_specified) &&
543 533 (!pmake_machinesfile_specified)) {
544 534 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
545 535 dmake_name2 = GETNAME(wcs_buffer, FIND_LENGTH);
546 536 prop2 = get_prop(dmake_name2->prop, macro_prop);
547 537 if (prop2 == NULL) {
548 538 /* DMAKE_MODE not defined, default to distributed mode */
549 539 dmake_mode_type = distributed_mode;
550 540 no_parallel = false;
551 541 } else {
552 542 dmake_value2 = prop2->body.macro.value;
553 543 if ((dmake_value2 == NULL) ||
554 544 (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("distributed")))) {
555 545 dmake_mode_type = distributed_mode;
556 546 no_parallel = false;
557 547 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("parallel"))) {
558 548 dmake_mode_type = parallel_mode;
559 549 no_parallel = false;
560 550 #ifdef SGE_SUPPORT
561 551 grid = false;
562 552 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("grid"))) {
563 553 dmake_mode_type = parallel_mode;
564 554 no_parallel = false;
565 555 grid = true;
566 556 #endif
567 557 } else if (IS_EQUAL(dmake_value2->string_mb, NOCATGETS("serial"))) {
568 558 dmake_mode_type = serial_mode;
569 559 no_parallel = true;
570 560 } else {
571 561 fatal(catgets(catd, 1, 307, "Unknown dmake mode argument `%s' after -m flag"), dmake_value2->string_mb);
572 562 }
573 563 }
574 564
575 565 if ((!list_all_targets) &&
576 566 (report_dependencies_level == 0)) {
577 567 /*
578 568 * Check to see if either DMAKE_RCFILE or DMAKE_MODE is defined.
579 569 * They could be defined in the env, in the makefile, or on the
580 570 * command line.
581 571 * If neither is defined, and $(HOME)/.dmakerc does not exists,
582 572 * then print a message, and default to parallel mode.
583 573 */
584 574 #ifdef DISTRIBUTED
585 575 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_RCFILE"));
586 576 dmake_name = GETNAME(wcs_buffer, FIND_LENGTH);
587 577 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
588 578 dmake_name2 = GETNAME(wcs_buffer, FIND_LENGTH);
589 579 if ((((prop = get_prop(dmake_name->prop, macro_prop)) == NULL) ||
590 580 ((dmake_value = prop->body.macro.value) == NULL)) &&
591 581 (((prop2 = get_prop(dmake_name2->prop, macro_prop)) == NULL) ||
592 582 ((dmake_value2 = prop2->body.macro.value) == NULL))) {
593 583 Boolean empty_dmakerc = true;
594 584 char *homedir = getenv(NOCATGETS("HOME"));
595 585 if ((homedir != NULL) && (strlen(homedir) < (sizeof(def_dmakerc_path) - 16))) {
596 586 sprintf(def_dmakerc_path, NOCATGETS("%s/.dmakerc"), homedir);
597 587 if ((((statval = stat(def_dmakerc_path, &statbuf)) != 0) && (errno == ENOENT)) ||
598 588 ((statval == 0) && (statbuf.st_size == 0))) {
599 589 } else {
600 590 Avo_dmakerc *rcfile = new Avo_dmakerc();
601 591 Avo_err *err = rcfile->read(def_dmakerc_path, NULL, TRUE);
602 592 if (err) {
603 593 fatal(err->str);
604 594 }
605 595 empty_dmakerc = rcfile->was_empty();
606 596 delete rcfile;
607 597 }
608 598 }
609 599 if (empty_dmakerc) {
610 600 if (getenv(NOCATGETS("DMAKE_DEF_PRINTED")) == NULL) {
611 601 putenv(NOCATGETS("DMAKE_DEF_PRINTED=TRUE"));
612 602 (void) fprintf(stdout, catgets(catd, 1, 302, "dmake: defaulting to parallel mode.\n"));
613 603 (void) fprintf(stdout, catgets(catd, 1, 303, "See the man page dmake(1) for more information on setting up the .dmakerc file.\n"));
614 604 }
615 605 dmake_mode_type = parallel_mode;
616 606 no_parallel = false;
617 607 }
618 608 }
619 609 #else
620 610 if(dmake_mode_type == distributed_mode) {
621 611 (void) fprintf(stdout, NOCATGETS("dmake: Distributed mode not implemented.\n"));
622 612 (void) fprintf(stdout, NOCATGETS(" Defaulting to parallel mode.\n"));
623 613 dmake_mode_type = parallel_mode;
624 614 no_parallel = false;
625 615 }
626 616 #endif /* DISTRIBUTED */
627 617 }
628 618 }
629 619 #endif
630 620
631 621 #ifdef TEAMWARE_MAKE_CMN
632 622 parallel_flag = true;
633 623 /* XXX - This is a major hack for DMake/Licensing. */
634 624 if (getenv(NOCATGETS("DMAKE_CHILD")) == NULL) {
635 625 if (!avo_cli_search_license(argv[0], dmake_exit_callback, TRUE, dmake_message_callback)) {
636 626 /*
637 627 * If the user can not get a TeamWare license,
638 628 * default to serial mode.
639 629 */
640 630 dmake_mode_type = serial_mode;
641 631 no_parallel = true;
642 632 } else {
643 633 putenv(NOCATGETS("DMAKE_CHILD=TRUE"));
644 634 }
645 635 start_time = time(NULL);
646 636 /*
647 637 * XXX - Hack to disable SIGALRM's from licensing library's
648 638 * setitimer().
649 639 */
650 640 value.it_interval.tv_sec = 0;
651 641 value.it_interval.tv_usec = 0;
652 642 value.it_value.tv_sec = 0;
653 643 value.it_value.tv_usec = 0;
654 644 (void) setitimer(ITIMER_REAL, &value, NULL);
655 645 }
656 646
657 647 //
658 648 // If dmake is running with -t option, set dmake_mode_type to serial.
659 649 // This is done because doname() calls touch_command() that runs serially.
660 650 // If we do not do that, maketool will have problems.
661 651 //
662 652 if(touch) {
663 653 dmake_mode_type = serial_mode;
664 654 no_parallel = true;
665 655 }
666 656 #else
667 657 parallel_flag = false;
668 658 #endif
669 659
670 660 #if defined (TEAMWARE_MAKE_CMN) && defined(REDIRECT_ERR)
671 661 /*
672 662 * Check whether stdout and stderr are physically same.
673 663 * This is in order to decide whether we need to redirect
674 664 * stderr separately from stdout.
675 665 * This check is performed only if __DMAKE_SEPARATE_STDERR
676 666 * is not set. This variable may be used in order to preserve
677 667 * the 'old' behaviour.
678 668 */
679 669 out_err_same = true;
680 670 char * dmake_sep_var = getenv(NOCATGETS("__DMAKE_SEPARATE_STDERR"));
681 671 if (dmake_sep_var == NULL || (0 != strcasecmp(dmake_sep_var, NOCATGETS("NO")))) {
682 672 struct stat stdout_stat;
683 673 struct stat stderr_stat;
684 674 if( (fstat(1, &stdout_stat) == 0)
685 675 && (fstat(2, &stderr_stat) == 0) )
686 676 {
687 677 if( (stdout_stat.st_dev != stderr_stat.st_dev)
688 678 || (stdout_stat.st_ino != stderr_stat.st_ino) )
689 679 {
690 680 out_err_same = false;
691 681 }
692 682 }
693 683 }
694 684 #endif
695 685
696 686 #ifdef DISTRIBUTED
697 687 /*
698 688 * At this point, DMake should startup an rxm with any and all
699 689 * DMake command line options. Rxm will, among other things,
700 690 * read the rc file.
701 691 */
702 692 if ((!list_all_targets) &&
703 693 (report_dependencies_level == 0) &&
704 694 (dmake_mode_type == distributed_mode)) {
705 695 startup_rxm();
706 696 }
707 697 #endif
708 698
709 699 /*
710 700 * Enable interrupt handler for alarms
711 701 */
712 702 (void) bsd_signal(SIGALRM, (SIG_PF)doalarm);
713 703
714 704 /*
715 705 * Check if make should report
716 706 */
717 707 if (getenv(sunpro_dependencies->string_mb) != NULL) {
718 708 FILE *report_file;
719 709
720 710 report_dependency("");
721 711 report_file = get_report_file();
722 712 if ((report_file != NULL) && (report_file != (FILE*)-1)) {
723 713 (void) fprintf(report_file, "\n");
724 714 }
725 715 }
726 716
727 717 /*
728 718 * Make sure SUNPRO_DEPENDENCIES is exported (or not) properly
729 719 * and NSE_DEP.
730 720 */
731 721 if (keep_state) {
732 722 maybe_append_prop(sunpro_dependencies, macro_prop)->
733 723 body.macro.exported = true;
734 724 #ifdef NSE
↓ open down ↓ |
228 lines elided |
↑ open up ↑ |
735 725 (void) setenv(NOCATGETS("NSE_DEP"), get_current_path());
736 726 #endif
737 727 } else {
738 728 maybe_append_prop(sunpro_dependencies, macro_prop)->
739 729 body.macro.exported = false;
740 730 }
741 731
742 732 working_on_targets = true;
743 733 if (trace_status) {
744 734 dump_make_state();
745 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
746 735 fclose(stdout);
747 736 fclose(stderr);
748 737 exit_status = 0;
749 -#endif
750 738 exit(0);
751 739 }
752 740 if (list_all_targets) {
753 741 dump_target_list();
754 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
755 742 fclose(stdout);
756 743 fclose(stderr);
757 744 exit_status = 0;
758 -#endif
759 745 exit(0);
760 746 }
761 747 trace_reader = false;
762 748
763 749 /*
764 750 * Set temp_file_directory to the directory the .make.state
765 751 * file is written to.
766 752 */
767 753 if ((slash_ptr = strrchr(make_state->string_mb, (int) slash_char)) == NULL) {
768 754 temp_file_directory = strdup(get_current_path());
769 755 } else {
770 756 *slash_ptr = (int) nul_char;
771 757 (void) strcpy(make_state_dir, make_state->string_mb);
772 758 *slash_ptr = (int) slash_char;
773 759 /* when there is only one slash and it's the first
774 760 ** character, make_state_dir should point to '/'.
775 761 */
776 762 if(make_state_dir[0] == '\0') {
777 763 make_state_dir[0] = '/';
778 764 make_state_dir[1] = '\0';
779 765 }
780 766 if (make_state_dir[0] == (int) slash_char) {
781 767 temp_file_directory = strdup(make_state_dir);
782 768 } else {
783 769 char tmp_current_path2[MAXPATHLEN];
784 770
785 771 (void) sprintf(tmp_current_path2,
786 772 "%s/%s",
787 773 get_current_path(),
788 774 make_state_dir);
789 775 temp_file_directory = strdup(tmp_current_path2);
790 776 }
791 777 }
792 778
793 779 #ifdef DISTRIBUTED
794 780 building_serial = false;
795 781 #endif
796 782
↓ open down ↓ |
28 lines elided |
↑ open up ↑ |
797 783 report_dir_enter_leave(true);
798 784
799 785 make_targets(argc, argv, parallel_flag);
800 786
801 787 report_dir_enter_leave(false);
802 788
803 789 #ifdef NSE
804 790 exit(nse_exit_status());
805 791 #else
806 792 if (build_failed_ever_seen) {
807 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
808 793 if (posix) {
809 794 exit_status = 1;
810 795 }
811 -#endif
812 796 exit(1);
813 797 }
814 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
815 798 exit_status = 0;
816 -#endif
817 799 exit(0);
818 800 #endif
819 801 /* NOTREACHED */
820 802 }
821 803
822 804 /*
823 805 * cleanup_after_exit()
824 806 *
825 807 * Called from exit(), performs cleanup actions.
826 808 *
827 809 * Parameters:
828 810 * status The argument exit() was called with
829 811 * arg Address of an argument vector to
830 812 * cleanup_after_exit()
831 813 *
832 814 * Global variables used:
833 815 * command_changed Set if we think .make.state should be rewritten
834 816 * current_line Is set we set commands_changed
835 817 * do_not_exec_rule
836 818 * True if -n flag on
837 819 * done The Name ".DONE", rule we run
838 820 * keep_state Set if .KEEP_STATE seen
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
839 821 * parallel True if building in parallel
840 822 * quest If -q is on we do not run .DONE
841 823 * report_dependencies
842 824 * True if -P flag on
843 825 * running_list List of parallel running processes
844 826 * temp_file_name The temp file is removed, if any
845 827 * catd the message catalog file
846 828 * usage_tracking Should have been constructed in main()
847 829 * should destroyed just before exiting
848 830 */
849 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
850 831 extern "C" void
851 832 cleanup_after_exit(void)
852 -#else
853 -void cleanup_after_exit(int status, ...)
854 -#endif
855 833 {
856 834 Running rp;
857 835 #ifdef NSE
858 836 char push_cmd[NSE_TFS_PUSH_LEN + 3 +
859 837 (MAXPATHLEN * MB_LEN_MAX) + 12];
860 838 char *active;
861 839 #endif
862 840
863 841 extern long getname_bytes_count;
864 842 extern long getname_names_count;
865 843 extern long getname_struct_count;
866 844 extern long freename_bytes_count;
867 845 extern long freename_names_count;
868 846 extern long freename_struct_count;
869 847 extern long other_alloc;
870 848
871 849 extern long env_alloc_num;
872 850 extern long env_alloc_bytes;
873 851
874 852
875 853 #ifdef DMAKE_STATISTICS
876 854 if(getname_stat) {
877 855 printf(NOCATGETS(">>> Getname statistics:\n"));
878 856 printf(NOCATGETS(" Allocated:\n"));
879 857 printf(NOCATGETS(" Names: %ld\n"), getname_names_count);
880 858 printf(NOCATGETS(" Strings: %ld Kb (%ld bytes)\n"), getname_bytes_count/1000, getname_bytes_count);
881 859 printf(NOCATGETS(" Structs: %ld Kb (%ld bytes)\n"), getname_struct_count/1000, getname_struct_count);
882 860 printf(NOCATGETS(" Total bytes: %ld Kb (%ld bytes)\n"), getname_struct_count/1000 + getname_bytes_count/1000, getname_struct_count + getname_bytes_count);
883 861
884 862 printf(NOCATGETS("\n Unallocated: %ld\n"), freename_names_count);
885 863 printf(NOCATGETS(" Names: %ld\n"), freename_names_count);
886 864 printf(NOCATGETS(" Strings: %ld Kb (%ld bytes)\n"), freename_bytes_count/1000, freename_bytes_count);
887 865 printf(NOCATGETS(" Structs: %ld Kb (%ld bytes)\n"), freename_struct_count/1000, freename_struct_count);
888 866 printf(NOCATGETS(" Total bytes: %ld Kb (%ld bytes)\n"), freename_struct_count/1000 + freename_bytes_count/1000, freename_struct_count + freename_bytes_count);
889 867
890 868 printf(NOCATGETS("\n Total used: %ld Kb (%ld bytes)\n"), (getname_struct_count/1000 + getname_bytes_count/1000) - (freename_struct_count/1000 + freename_bytes_count/1000), (getname_struct_count + getname_bytes_count) - (freename_struct_count + freename_bytes_count));
891 869
892 870 printf(NOCATGETS("\n>>> Other:\n"));
893 871 printf(
894 872 NOCATGETS(" Env (%ld): %ld Kb (%ld bytes)\n"),
895 873 env_alloc_num,
896 874 env_alloc_bytes/1000,
897 875 env_alloc_bytes
898 876 );
899 877
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
900 878 }
901 879 #endif
902 880
903 881 /*
904 882 #ifdef DISTRIBUTED
905 883 if (get_parent() == TRUE) {
906 884 #endif
907 885 */
908 886
909 887 parallel = false;
910 -#ifdef SUN5_0
911 888 /* If we used the SVR4_MAKE, don't build .DONE or .FAILED */
912 889 if (!getenv(USE_SVR4_MAKE)){
913 -#endif
914 890 /* Build the target .DONE or .FAILED if we caught an error */
915 891 if (!quest && !list_all_targets) {
916 892 Name failed_name;
917 893
918 894 MBSTOWCS(wcs_buffer, NOCATGETS(".FAILED"));
919 895 failed_name = GETNAME(wcs_buffer, FIND_LENGTH);
920 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
921 896 if ((exit_status != 0) && (failed_name->prop != NULL)) {
922 -#else
923 - if ((status != 0) && (failed_name->prop != NULL)) {
924 -#endif
925 897 #ifdef TEAMWARE_MAKE_CMN
926 898 /*
927 899 * [tolik] switch DMake to serial mode
928 900 */
929 901 dmake_mode_type = serial_mode;
930 902 no_parallel = true;
931 903 #endif
932 904 (void) doname(failed_name, false, true);
933 905 } else {
934 906 if (!trace_status) {
935 907 #ifdef TEAMWARE_MAKE_CMN
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
936 908 /*
937 909 * Switch DMake to serial mode
938 910 */
939 911 dmake_mode_type = serial_mode;
940 912 no_parallel = true;
941 913 #endif
942 914 (void) doname(done, false, true);
943 915 }
944 916 }
945 917 }
946 -#ifdef SUN5_0
947 918 }
948 -#endif
949 919 /*
950 920 * Remove the temp file utilities report dependencies thru if it
951 921 * is still around
952 922 */
953 923 if (temp_file_name != NULL) {
954 924 (void) unlink(temp_file_name->string_mb);
955 925 }
956 926 /*
957 927 * Do not save the current command in .make.state if make
958 928 * was interrupted.
959 929 */
960 930 if (current_line != NULL) {
961 931 command_changed = true;
962 932 current_line->body.line.command_used = NULL;
963 933 }
964 934 /*
965 935 * For each parallel build process running, remove the temp files
966 936 * and zap the command line so it won't be put in .make.state
967 937 */
968 938 for (rp = running_list; rp != NULL; rp = rp->next) {
969 939 if (rp->temp_file != NULL) {
970 940 (void) unlink(rp->temp_file->string_mb);
971 941 }
972 942 if (rp->stdout_file != NULL) {
973 943 (void) unlink(rp->stdout_file);
974 944 retmem_mb(rp->stdout_file);
975 945 rp->stdout_file = NULL;
976 946 }
977 947 if (rp->stderr_file != NULL) {
978 948 (void) unlink(rp->stderr_file);
979 949 retmem_mb(rp->stderr_file);
980 950 rp->stderr_file = NULL;
981 951 }
982 952 command_changed = true;
983 953 /*
984 954 line = get_prop(rp->target->prop, line_prop);
985 955 if (line != NULL) {
986 956 line->body.line.command_used = NULL;
987 957 }
988 958 */
989 959 }
990 960 /* Remove the statefile lock file if the file has been locked */
991 961 if ((make_state_lockfile != NULL) && (make_state_locked)) {
992 962 (void) unlink(make_state_lockfile);
993 963 make_state_lockfile = NULL;
994 964 make_state_locked = false;
995 965 }
996 966 /* Write .make.state */
997 967 write_state_file(1, (Boolean) 1);
998 968
999 969 #ifdef TEAMWARE_MAKE_CMN
1000 970 // Deleting the usage tracking object sends the usage mail
1001 971 #ifdef USE_DMS_CCR
1002 972 //usageTracking->setExitStatus(exit_status, NULL);
1003 973 //delete usageTracking;
1004 974 #else
1005 975 cleanup->set_exit_status(exit_status);
1006 976 delete cleanup;
1007 977 #endif
1008 978 #endif
1009 979
1010 980 #ifdef NSE
1011 981 /* If running inside an activated environment, push the */
1012 982 /* .nse_depinfo file (if written) */
1013 983 active = getenv(NSE_VARIANT_ENV);
1014 984 if (keep_state &&
1015 985 (active != NULL) &&
1016 986 !IS_EQUAL(active, NSE_RT_SOURCE_NAME) &&
1017 987 !do_not_exec_rule &&
1018 988 (report_dependencies_level == 0)) {
1019 989 (void) sprintf(push_cmd,
1020 990 "%s %s/%s",
1021 991 NSE_TFS_PUSH,
1022 992 get_current_path(),
1023 993 NSE_DEPINFO);
1024 994 (void) system(push_cmd);
1025 995 }
1026 996 #endif
1027 997
1028 998 /*
1029 999 #ifdef DISTRIBUTED
1030 1000 }
1031 1001 #endif
1032 1002 */
1033 1003
1034 1004 #if defined (TEAMWARE_MAKE_CMN) && defined (MAXJOBS_ADJUST_RFE4694000)
1035 1005 job_adjust_fini();
1036 1006 #endif
1037 1007
1038 1008 #ifdef TEAMWARE_MAKE_CMN
1039 1009 catclose(catd);
1040 1010 #endif
1041 1011 #ifdef DISTRIBUTED
1042 1012 if (rxmPid > 0) {
1043 1013 // Tell rxm to exit by sending it an Avo_AcknowledgeMsg
1044 1014 Avo_AcknowledgeMsg acknowledgeMsg;
1045 1015 RWCollectable *msg = (RWCollectable *)&acknowledgeMsg;
1046 1016
1047 1017 int xdrResult = xdr(&xdrs_out, msg);
1048 1018
1049 1019 if (xdrResult) {
1050 1020 fflush(dmake_ofp);
1051 1021 } else {
1052 1022 /*
1053 1023 fatal(catgets(catd, 1, 266, "couldn't tell rxm to exit"));
1054 1024 */
1055 1025 kill(rxmPid, SIGTERM);
1056 1026 }
1057 1027
1058 1028 waitpid(rxmPid, NULL, 0);
1059 1029 rxmPid = 0;
1060 1030 }
1061 1031 #endif
1062 1032 }
1063 1033
1064 1034 /*
1065 1035 * handle_interrupt()
1066 1036 *
1067 1037 * This is where C-C traps are caught.
1068 1038 *
1069 1039 * Parameters:
1070 1040 *
1071 1041 * Global variables used (except DMake 1.0):
1072 1042 * current_target Sometimes the current target is removed
1073 1043 * do_not_exec_rule But not if -n is on
1074 1044 * quest or -q
1075 1045 * running_list List of parallel running processes
1076 1046 * touch Current target is not removed if -t on
1077 1047 */
1078 1048 void
1079 1049 handle_interrupt(int)
1080 1050 {
1081 1051 Property member;
1082 1052 Running rp;
1083 1053
1084 1054 (void) fflush(stdout);
1085 1055 #ifdef DISTRIBUTED
1086 1056 if (rxmPid > 0) {
1087 1057 // Tell rxm to exit by sending it an Avo_AcknowledgeMsg
1088 1058 Avo_AcknowledgeMsg acknowledgeMsg;
1089 1059 RWCollectable *msg = (RWCollectable *)&acknowledgeMsg;
1090 1060
1091 1061 int xdrResult = xdr(&xdrs_out, msg);
1092 1062
1093 1063 if (xdrResult) {
1094 1064 fflush(dmake_ofp);
1095 1065 } else {
1096 1066 kill(rxmPid, SIGTERM);
1097 1067 rxmPid = 0;
1098 1068 }
1099 1069 }
1100 1070 #endif
1101 1071 if (childPid > 0) {
1102 1072 kill(childPid, SIGTERM);
1103 1073 childPid = -1;
1104 1074 }
1105 1075 for (rp = running_list; rp != NULL; rp = rp->next) {
1106 1076 if (rp->state != build_running) {
1107 1077 continue;
1108 1078 }
1109 1079 if (rp->pid > 0) {
1110 1080 kill(rp->pid, SIGTERM);
1111 1081 rp->pid = -1;
1112 1082 }
1113 1083 }
1114 1084 if (getpid() == getpgrp()) {
↓ open down ↓ |
156 lines elided |
↑ open up ↑ |
1115 1085 bsd_signal(SIGTERM, SIG_IGN);
1116 1086 kill (-getpid(), SIGTERM);
1117 1087 }
1118 1088 #ifdef TEAMWARE_MAKE_CMN
1119 1089 /* Clean up all parallel/distributed children already finished */
1120 1090 finish_children(false);
1121 1091 #endif
1122 1092
1123 1093 /* Make sure the processes running under us terminate first */
1124 1094
1125 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
1126 1095 while (wait((int *) NULL) != -1);
1127 -#else
1128 - while (wait((union wait*) NULL) != -1);
1129 -#endif
1130 1096 /* Delete the current targets unless they are precious */
1131 1097 if ((current_target != NULL) &&
1132 1098 current_target->is_member &&
1133 1099 ((member = get_prop(current_target->prop, member_prop)) != NULL)) {
1134 1100 current_target = member->body.member.library;
1135 1101 }
1136 1102 if (!do_not_exec_rule &&
1137 1103 !touch &&
1138 1104 !quest &&
1139 1105 (current_target != NULL) &&
1140 1106 !(current_target->stat.is_precious || all_precious)) {
1141 1107
1142 1108 /* BID_1030811 */
1143 1109 /* azv 16 Oct 95 */
1144 1110 current_target->stat.time = file_no_time;
1145 1111
1146 1112 if (exists(current_target) != file_doesnt_exist) {
1147 1113 (void) fprintf(stderr,
1148 1114 "\n*** %s ",
1149 1115 current_target->string_mb);
1150 1116 if (current_target->stat.is_dir) {
1151 1117 (void) fprintf(stderr,
1152 1118 catgets(catd, 1, 168, "not removed.\n"),
1153 1119 current_target->string_mb);
1154 1120 } else if (unlink(current_target->string_mb) == 0) {
1155 1121 (void) fprintf(stderr,
1156 1122 catgets(catd, 1, 169, "removed.\n"),
1157 1123 current_target->string_mb);
1158 1124 } else {
1159 1125 (void) fprintf(stderr,
1160 1126 catgets(catd, 1, 170, "could not be removed: %s.\n"),
1161 1127 current_target->string_mb,
1162 1128 errmsg(errno));
1163 1129 }
1164 1130 }
1165 1131 }
1166 1132 for (rp = running_list; rp != NULL; rp = rp->next) {
1167 1133 if (rp->state != build_running) {
1168 1134 continue;
1169 1135 }
1170 1136 if (rp->target->is_member &&
1171 1137 ((member = get_prop(rp->target->prop, member_prop)) !=
1172 1138 NULL)) {
1173 1139 rp->target = member->body.member.library;
1174 1140 }
1175 1141 if (!do_not_exec_rule &&
1176 1142 !touch &&
1177 1143 !quest &&
1178 1144 !(rp->target->stat.is_precious || all_precious)) {
1179 1145
1180 1146 rp->target->stat.time = file_no_time;
1181 1147 if (exists(rp->target) != file_doesnt_exist) {
1182 1148 (void) fprintf(stderr,
1183 1149 "\n*** %s ",
1184 1150 rp->target->string_mb);
1185 1151 if (rp->target->stat.is_dir) {
1186 1152 (void) fprintf(stderr,
1187 1153 catgets(catd, 1, 171, "not removed.\n"),
1188 1154 rp->target->string_mb);
1189 1155 } else if (unlink(rp->target->string_mb) == 0) {
1190 1156 (void) fprintf(stderr,
1191 1157 catgets(catd, 1, 172, "removed.\n"),
1192 1158 rp->target->string_mb);
1193 1159 } else {
1194 1160 (void) fprintf(stderr,
1195 1161 catgets(catd, 1, 173, "could not be removed: %s.\n"),
1196 1162 rp->target->string_mb,
1197 1163 errmsg(errno));
1198 1164 }
1199 1165 }
1200 1166 }
1201 1167 }
1202 1168
1203 1169 #ifdef SGE_SUPPORT
1204 1170 /* Remove SGE script file */
1205 1171 if (grid) {
1206 1172 unlink(script_file);
1207 1173 }
1208 1174 #endif
1209 1175
1210 1176 /* Have we locked .make.state or .nse_depinfo? */
1211 1177 if ((make_state_lockfile != NULL) && (make_state_locked)) {
1212 1178 unlink(make_state_lockfile);
1213 1179 make_state_lockfile = NULL;
1214 1180 make_state_locked = false;
1215 1181 }
1216 1182 #ifdef NSE
1217 1183 if ((nse_depinfo_lockfile[0] != '\0') && (nse_depinfo_locked)) {
1218 1184 unlink(nse_depinfo_lockfile);
1219 1185 nse_depinfo_lockfile[0] = '\0';
↓ open down ↓ |
80 lines elided |
↑ open up ↑ |
1220 1186 nse_depinfo_locked = false;
1221 1187 }
1222 1188 #endif
1223 1189 /*
1224 1190 * Re-read .make.state file (it might be changed by recursive make)
1225 1191 */
1226 1192 check_state(NULL);
1227 1193
1228 1194 report_dir_enter_leave(false);
1229 1195
1230 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
1231 1196 exit_status = 2;
1232 -#endif
1233 1197 exit(2);
1234 1198 }
1235 1199
1236 1200 /*
1237 1201 * doalarm(sig, ...)
1238 1202 *
1239 1203 * Handle the alarm interrupt but do nothing. Side effect is to
1240 1204 * cause return from wait3.
1241 1205 *
1242 1206 * Parameters:
1243 1207 * sig
1244 1208 *
1245 1209 * Global variables used:
1246 1210 */
1247 1211 /*ARGSUSED*/
1248 1212 static void
1249 1213 doalarm(int)
1250 1214 {
1251 1215 return;
1252 1216 }
1253 1217
1254 1218
1255 1219 /*
1256 1220 * read_command_options(argc, argv)
1257 1221 *
1258 1222 * Scan the cmd line options and process the ones that start with "-"
1259 1223 *
1260 1224 * Return value:
1261 1225 * -M argument, if any
1262 1226 *
1263 1227 * Parameters:
1264 1228 * argc You know what this is
1265 1229 * argv You know what this is
1266 1230 *
1267 1231 * Global variables used:
1268 1232 */
1269 1233 static void
1270 1234 read_command_options(register int argc, register char **argv)
1271 1235 {
1272 1236 register int ch;
1273 1237 int current_optind = 1;
1274 1238 int last_optind_with_double_hyphen = 0;
1275 1239 int last_optind;
1276 1240 int last_current_optind;
1277 1241 register int i;
1278 1242 register int j;
1279 1243 register int k;
1280 1244 register int makefile_next = 0; /*
1281 1245 * flag to note options:
1282 1246 * -c, f, g, j, m, o
1283 1247 */
1284 1248 const char *tptr;
1285 1249 const char *CMD_OPTS;
1286 1250
1287 1251 extern char *optarg;
1288 1252 extern int optind, opterr, optopt;
1289 1253
1290 1254 #define SUNPRO_CMD_OPTS "-~Bbc:Ddef:g:ij:K:kM:m:NnO:o:PpqRrSsTtuVvwx:"
1291 1255
1292 1256 #ifdef TEAMWARE_MAKE_CMN
1293 1257 # define SVR4_CMD_OPTS "-c:ef:g:ij:km:nO:o:pqrsTtVv"
1294 1258 #else
1295 1259 # define SVR4_CMD_OPTS "-ef:iknpqrstV"
1296 1260 #endif
1297 1261
1298 1262 /*
1299 1263 * Added V in SVR4_CMD_OPTS also, which is going to be a hidden
1300 1264 * option, just to make sure that the getopt doesn't fail when some
1301 1265 * users leave their USE_SVR4_MAKE set and try to use the makefiles
1302 1266 * that are designed to issue commands like $(MAKE) -V. Anyway it
1303 1267 * sets the same flag but ensures that getopt doesn't fail.
1304 1268 */
1305 1269
1306 1270 opterr = 0;
1307 1271 optind = 1;
1308 1272 while (1) {
1309 1273 last_optind=optind; /* Save optind and current_optind values */
1310 1274 last_current_optind=current_optind; /* in case we have to repeat this round. */
1311 1275 if (svr4) {
1312 1276 CMD_OPTS=SVR4_CMD_OPTS;
1313 1277 ch = getopt(argc, argv, SVR4_CMD_OPTS);
1314 1278 } else {
1315 1279 CMD_OPTS=SUNPRO_CMD_OPTS;
1316 1280 ch = getopt(argc, argv, SUNPRO_CMD_OPTS);
1317 1281 }
1318 1282 if (ch == EOF) {
1319 1283 if(optind < argc) {
1320 1284 /*
1321 1285 * Fixing bug 4102537:
1322 1286 * Strange behaviour of command make using -- option.
1323 1287 * Not all argv have been processed
1324 1288 * Skip non-flag argv and continue processing.
1325 1289 */
1326 1290 optind++;
1327 1291 current_optind++;
1328 1292 continue;
1329 1293 } else {
1330 1294 break;
1331 1295 }
1332 1296
1333 1297 }
1334 1298 if (ch == '?') {
1335 1299 if (optopt == '-') {
1336 1300 /* Bug 5060758: getopt() changed behavior (s10_60),
1337 1301 * and now we have to deal with cases when options
1338 1302 * with double hyphen appear here, from -$(MAKEFLAGS)
1339 1303 */
1340 1304 i = current_optind;
1341 1305 if (argv[i][0] == '-') {
1342 1306 if (argv[i][1] == '-') {
1343 1307 if (argv[i][2] != '\0') {
1344 1308 /* Check if this option is allowed */
1345 1309 tptr = strchr(CMD_OPTS, argv[i][2]);
1346 1310 if (tptr) {
1347 1311 if (last_optind_with_double_hyphen != current_optind) {
1348 1312 /* This is first time we are trying to fix "--"
1349 1313 * problem with this option. If we come here second
1350 1314 * time, we will go to fatal error.
1351 1315 */
1352 1316 last_optind_with_double_hyphen = current_optind;
1353 1317
1354 1318 /* Eliminate first hyphen character */
1355 1319 for (j=0; argv[i][j] != '\0'; j++) {
1356 1320 argv[i][j] = argv[i][j+1];
1357 1321 }
1358 1322
1359 1323 /* Repeat the processing of this argument */
1360 1324 optind=last_optind;
1361 1325 current_optind=last_current_optind;
1362 1326 continue;
1363 1327 }
1364 1328 }
1365 1329 }
1366 1330 }
1367 1331 }
1368 1332 }
1369 1333 }
1370 1334
1371 1335 if (ch == '?') {
1372 1336 if (svr4) {
1373 1337 #ifdef TEAMWARE_MAKE_CMN
1374 1338 fprintf(stderr,
1375 1339 catgets(catd, 1, 267, "Usage : dmake [ -f makefile ][ -c dmake_rcfile ][ -g dmake_group ]\n"));
1376 1340 fprintf(stderr,
1377 1341 catgets(catd, 1, 268, " [ -j dmake_max_jobs ][ -m dmake_mode ][ -o dmake_odir ]...\n"));
1378 1342 fprintf(stderr,
1379 1343 catgets(catd, 1, 269, " [ -e ][ -i ][ -k ][ -n ][ -p ][ -q ][ -r ][ -s ][ -t ][ -v ]\n"));
1380 1344 #else
1381 1345 fprintf(stderr,
1382 1346 catgets(catd, 1, 270, "Usage : make [ -f makefile ]... [ -e ][ -i ][ -k ][ -n ][ -p ][ -q ][ -r ]\n"));
1383 1347 fprintf(stderr,
1384 1348 catgets(catd, 1, 271, " [ -s ][ -t ]\n"));
1385 1349 #endif
1386 1350 tptr = strchr(SVR4_CMD_OPTS, optopt);
1387 1351 } else {
1388 1352 #ifdef TEAMWARE_MAKE_CMN
1389 1353 fprintf(stderr,
1390 1354 catgets(catd, 1, 272, "Usage : dmake [ -f makefile ][ -c dmake_rcfile ][ -g dmake_group ]\n"));
1391 1355 fprintf(stderr,
1392 1356 catgets(catd, 1, 273, " [ -j dmake_max_jobs ][ -K statefile ][ -m dmake_mode ][ -x MODE_NAME=VALUE ][ -o dmake_odir ]...\n"));
1393 1357 fprintf(stderr,
1394 1358 catgets(catd, 1, 274, " [ -d ][ -dd ][ -D ][ -DD ][ -e ][ -i ][ -k ][ -n ][ -p ][ -P ][ -u ][ -w ]\n"));
1395 1359 fprintf(stderr,
1396 1360 catgets(catd, 1, 275, " [ -q ][ -r ][ -s ][ -S ][ -t ][ -v ][ -V ][ target... ][ macro=value... ][ \"macro +=value\"... ]\n"));
1397 1361 #else
1398 1362 fprintf(stderr,
1399 1363 catgets(catd, 1, 276, "Usage : make [ -f makefile ][ -K statefile ]... [ -d ][ -dd ][ -D ][ -DD ]\n"));
1400 1364 fprintf(stderr,
1401 1365 catgets(catd, 1, 277, " [ -e ][ -i ][ -k ][ -n ][ -p ][ -P ][ -q ][ -r ][ -s ][ -S ][ -t ]\n"));
1402 1366 fprintf(stderr,
1403 1367 catgets(catd, 1, 278, " [ -u ][ -w ][ -V ][ target... ][ macro=value... ][ \"macro +=value\"... ]\n"));
1404 1368 #endif
1405 1369 tptr = strchr(SUNPRO_CMD_OPTS, optopt);
1406 1370 }
1407 1371 if (!tptr) {
1408 1372 fatal(catgets(catd, 1, 279, "Unknown option `-%c'"), optopt);
1409 1373 } else {
1410 1374 fatal(catgets(catd, 1, 280, "Missing argument after `-%c'"), optopt);
1411 1375 }
1412 1376 }
1413 1377
1414 1378 #if defined(linux)
1415 1379 if (ch == 1) {
1416 1380 if(optind < argc) {
1417 1381 //optind++;
1418 1382 //current_optind++;
1419 1383 makefile_next = 0;
1420 1384 current_optind = optind;
1421 1385 continue;
1422 1386 } else {
1423 1387 break;
1424 1388 }
1425 1389 }
1426 1390 #endif
1427 1391
1428 1392
1429 1393 makefile_next |= parse_command_option(ch);
1430 1394 /*
1431 1395 * If we're done processing all of the options of
1432 1396 * ONE argument string...
1433 1397 */
1434 1398 if (current_optind < optind) {
1435 1399 i = current_optind;
1436 1400 k = 0;
1437 1401 /* If there's an argument for an option... */
1438 1402 if ((optind - current_optind) > 1) {
1439 1403 k = i + 1;
1440 1404 }
1441 1405 switch (makefile_next) {
1442 1406 case 0:
1443 1407 argv[i] = NULL;
1444 1408 /* This shouldn't happen */
1445 1409 if (k) {
1446 1410 argv[k] = NULL;
1447 1411 }
1448 1412 break;
1449 1413 case 1: /* -f seen */
1450 1414 argv[i] = (char *)NOCATGETS("-f");
1451 1415 break;
1452 1416 case 2: /* -c seen */
1453 1417 argv[i] = (char *)NOCATGETS("-c");
1454 1418 #ifndef TEAMWARE_MAKE_CMN
1455 1419 warning(catgets(catd, 1, 281, "Ignoring DistributedMake -c option"));
1456 1420 #endif
1457 1421 break;
1458 1422 case 4: /* -g seen */
1459 1423 argv[i] = (char *)NOCATGETS("-g");
1460 1424 #ifndef TEAMWARE_MAKE_CMN
1461 1425 warning(catgets(catd, 1, 282, "Ignoring DistributedMake -g option"));
1462 1426 #endif
1463 1427 break;
1464 1428 case 8: /* -j seen */
1465 1429 argv[i] = (char *)NOCATGETS("-j");
1466 1430 #ifndef TEAMWARE_MAKE_CMN
1467 1431 warning(catgets(catd, 1, 283, "Ignoring DistributedMake -j option"));
1468 1432 #endif
1469 1433 break;
1470 1434 case 16: /* -M seen */
1471 1435 argv[i] = (char *)NOCATGETS("-M");
1472 1436 #ifndef TEAMWARE_MAKE_CMN
1473 1437 warning(catgets(catd, 1, 284, "Ignoring ParallelMake -M option"));
1474 1438 #endif
1475 1439 break;
1476 1440 case 32: /* -m seen */
1477 1441 argv[i] = (char *)NOCATGETS("-m");
1478 1442 #ifndef TEAMWARE_MAKE_CMN
1479 1443 warning(catgets(catd, 1, 285, "Ignoring DistributedMake -m option"));
1480 1444 #endif
1481 1445 break;
1482 1446 #ifndef PARALLEL
1483 1447 case 128: /* -O seen */
1484 1448 argv[i] = (char *)NOCATGETS("-O");
1485 1449 break;
1486 1450 #endif
1487 1451 case 256: /* -K seen */
1488 1452 argv[i] = (char *)NOCATGETS("-K");
1489 1453 break;
1490 1454 case 512: /* -o seen */
1491 1455 argv[i] = (char *)NOCATGETS("-o");
1492 1456 #ifndef TEAMWARE_MAKE_CMN
1493 1457 warning(catgets(catd, 1, 311, "Ignoring DistributedMake -o option"));
1494 1458 #endif
1495 1459 break;
1496 1460 case 1024: /* -x seen */
1497 1461 argv[i] = (char *)NOCATGETS("-x");
1498 1462 #ifndef TEAMWARE_MAKE_CMN
1499 1463 warning(catgets(catd, 1, 353, "Ignoring DistributedMake -x option"));
1500 1464 #endif
1501 1465 break;
1502 1466 default: /* > 1 of -c, f, g, j, K, M, m, O, o, x seen */
1503 1467 fatal(catgets(catd, 1, 286, "Illegal command line. More than one option requiring\nan argument given in the same argument group"));
1504 1468 }
1505 1469
1506 1470 makefile_next = 0;
1507 1471 current_optind = optind;
1508 1472 }
1509 1473 }
1510 1474 }
1511 1475
1512 1476 static void
1513 1477 quote_str(char *str, char *qstr)
1514 1478 {
1515 1479 char *to;
1516 1480 char *from;
1517 1481
1518 1482 to = qstr;
1519 1483 for (from = str; *from; from++) {
1520 1484 switch (*from) {
1521 1485 case ';': /* End of command */
1522 1486 case '(': /* Start group */
1523 1487 case ')': /* End group */
1524 1488 case '{': /* Start group */
1525 1489 case '}': /* End group */
1526 1490 case '[': /* Reg expr - any of a set of chars */
1527 1491 case ']': /* End of set of chars */
1528 1492 case '|': /* Pipe or logical-or */
1529 1493 case '^': /* Old-fashioned pipe */
1530 1494 case '&': /* Background or logical-and */
1531 1495 case '<': /* Redirect stdin */
1532 1496 case '>': /* Redirect stdout */
1533 1497 case '*': /* Reg expr - any sequence of chars */
1534 1498 case '?': /* Reg expr - any single char */
1535 1499 case '$': /* Variable substitution */
1536 1500 case '\'': /* Singe quote - turn off all magic */
1537 1501 case '"': /* Double quote - span whitespace */
1538 1502 case '`': /* Backquote - run a command */
1539 1503 case '#': /* Comment */
1540 1504 case ' ': /* Space (for MACRO=value1 value2 */
1541 1505 case '\\': /* Escape char - turn off magic of next char */
1542 1506 *to++ = '\\';
1543 1507 break;
1544 1508
1545 1509 default:
1546 1510 break;
1547 1511 }
1548 1512 *to++ = *from;
1549 1513 }
1550 1514 *to = '\0';
1551 1515 }
1552 1516
1553 1517 static void
1554 1518 unquote_str(char *str, char *qstr)
1555 1519 {
1556 1520 char *to;
1557 1521 char *from;
1558 1522
1559 1523 to = qstr;
1560 1524 for (from = str; *from; from++) {
1561 1525 if (*from == '\\') {
1562 1526 from++;
1563 1527 }
1564 1528 *to++ = *from;
1565 1529 }
1566 1530 *to = '\0';
1567 1531 }
1568 1532
1569 1533 /*
1570 1534 * Convert the MAKEFLAGS string value into a vector of char *, similar
1571 1535 * to argv.
1572 1536 */
1573 1537 static void
1574 1538 setup_makeflags_argv()
1575 1539 {
1576 1540 char *cp;
1577 1541 char *cp1;
1578 1542 char *cp2;
1579 1543 char *cp3;
1580 1544 char *cp_orig;
1581 1545 Boolean add_hyphen;
1582 1546 int i;
1583 1547 char tmp_char;
1584 1548
1585 1549 mf_argc = 1;
1586 1550 cp = getenv(makeflags->string_mb);
1587 1551 cp_orig = cp;
1588 1552
1589 1553 if (cp) {
1590 1554 /*
1591 1555 * If new MAKEFLAGS format, no need to add hyphen.
1592 1556 * If old MAKEFLAGS format, add hyphen before flags.
1593 1557 */
1594 1558
1595 1559 if ((strchr(cp, (int) hyphen_char) != NULL) ||
1596 1560 (strchr(cp, (int) equal_char) != NULL)) {
1597 1561
1598 1562 /* New MAKEFLAGS format */
1599 1563
1600 1564 add_hyphen = false;
1601 1565 #ifdef ADDFIX5060758
1602 1566 /* Check if MAKEFLAGS value begins with multiple
1603 1567 * hyphen characters, and remove all duplicates.
1604 1568 * Usually it happens when the next command is
1605 1569 * used: $(MAKE) -$(MAKEFLAGS)
1606 1570 * This is a workaround for BugID 5060758.
1607 1571 */
1608 1572 while (*cp) {
1609 1573 if (*cp != (int) hyphen_char) {
1610 1574 break;
1611 1575 }
1612 1576 cp++;
1613 1577 if (*cp == (int) hyphen_char) {
1614 1578 /* There are two hyphens. Skip one */
1615 1579 cp_orig = cp;
1616 1580 cp++;
1617 1581 }
1618 1582 if (!(*cp)) {
1619 1583 /* There are hyphens only. Skip all */
1620 1584 cp_orig = cp;
1621 1585 break;
1622 1586 }
1623 1587 }
1624 1588 #endif
1625 1589 } else {
1626 1590
1627 1591 /* Old MAKEFLAGS format */
1628 1592
1629 1593 add_hyphen = true;
1630 1594 }
1631 1595 }
1632 1596
1633 1597 /* Find the number of arguments in MAKEFLAGS */
1634 1598 while (cp && *cp) {
1635 1599 /* Skip white spaces */
1636 1600 while (cp && *cp && isspace(*cp)) {
1637 1601 cp++;
1638 1602 }
1639 1603 if (cp && *cp) {
1640 1604 /* Increment arg count */
1641 1605 mf_argc++;
1642 1606 /* Go to next white space */
1643 1607 while (cp && *cp && !isspace(*cp)) {
1644 1608 if(*cp == (int) backslash_char) {
1645 1609 cp++;
1646 1610 }
1647 1611 cp++;
1648 1612 }
1649 1613 }
1650 1614 }
1651 1615 /* Allocate memory for the new MAKEFLAGS argv */
1652 1616 mf_argv = (char **) malloc((mf_argc + 1) * sizeof(char *));
1653 1617 mf_argv[0] = (char *)NOCATGETS("MAKEFLAGS");
1654 1618 /*
1655 1619 * Convert the MAKEFLAGS string value into a vector of char *,
1656 1620 * similar to argv.
1657 1621 */
1658 1622 cp = cp_orig;
1659 1623 for (i = 1; i < mf_argc; i++) {
1660 1624 /* Skip white spaces */
1661 1625 while (cp && *cp && isspace(*cp)) {
1662 1626 cp++;
1663 1627 }
1664 1628 if (cp && *cp) {
1665 1629 cp_orig = cp;
1666 1630 /* Go to next white space */
1667 1631 while (cp && *cp && !isspace(*cp)) {
1668 1632 if(*cp == (int) backslash_char) {
1669 1633 cp++;
1670 1634 }
1671 1635 cp++;
1672 1636 }
1673 1637 tmp_char = *cp;
1674 1638 *cp = (int) nul_char;
1675 1639 if (add_hyphen) {
1676 1640 mf_argv[i] = getmem(2 + strlen(cp_orig));
1677 1641 mf_argv[i][0] = '\0';
1678 1642 (void) strcat(mf_argv[i], "-");
1679 1643 // (void) strcat(mf_argv[i], cp_orig);
1680 1644 unquote_str(cp_orig, mf_argv[i]+1);
1681 1645 } else {
1682 1646 mf_argv[i] = getmem(2 + strlen(cp_orig));
1683 1647 //mf_argv[i] = strdup(cp_orig);
1684 1648 unquote_str(cp_orig, mf_argv[i]);
1685 1649 }
1686 1650 *cp = tmp_char;
1687 1651 }
1688 1652 }
1689 1653 mf_argv[i] = NULL;
1690 1654 }
1691 1655
1692 1656 /*
1693 1657 * parse_command_option(ch)
1694 1658 *
1695 1659 * Parse make command line options.
1696 1660 *
1697 1661 * Return value:
1698 1662 * Indicates if any -f -c or -M were seen
1699 1663 *
1700 1664 * Parameters:
1701 1665 * ch The character to parse
1702 1666 *
1703 1667 * Static variables used:
1704 1668 * dmake_group_specified Set for make -g
1705 1669 * dmake_max_jobs_specified Set for make -j
1706 1670 * dmake_mode_specified Set for make -m
1707 1671 * dmake_add_mode_specified Set for make -x
1708 1672 * dmake_compat_mode_specified Set for make -x SUN_MAKE_COMPAT_MODE=
1709 1673 * dmake_output_mode_specified Set for make -x DMAKE_OUTPUT_MODE=
1710 1674 * dmake_odir_specified Set for make -o
1711 1675 * dmake_rcfile_specified Set for make -c
1712 1676 * env_wins Set for make -e
1713 1677 * ignore_default_mk Set for make -r
1714 1678 * trace_status Set for make -p
1715 1679 *
1716 1680 * Global variables used:
1717 1681 * .make.state path & name set for make -K
1718 1682 * continue_after_error Set for make -k
1719 1683 * debug_level Set for make -d
1720 1684 * do_not_exec_rule Set for make -n
1721 1685 * filter_stderr Set for make -X
1722 1686 * ignore_errors_all Set for make -i
1723 1687 * no_parallel Set for make -R
1724 1688 * quest Set for make -q
1725 1689 * read_trace_level Set for make -D
1726 1690 * report_dependencies Set for make -P
1727 1691 * send_mtool_msgs Set for make -K
1728 1692 * silent_all Set for make -s
1729 1693 * touch Set for make -t
1730 1694 */
1731 1695 static int
1732 1696 parse_command_option(register char ch)
1733 1697 {
1734 1698 static int invert_next = 0;
1735 1699 int invert_this = invert_next;
1736 1700
1737 1701 invert_next = 0;
1738 1702 switch (ch) {
1739 1703 case '-': /* Ignore "--" */
1740 1704 return 0;
1741 1705 case '~': /* Invert next option */
1742 1706 invert_next = 1;
1743 1707 return 0;
1744 1708 case 'B': /* Obsolete */
1745 1709 return 0;
1746 1710 case 'b': /* Obsolete */
1747 1711 return 0;
1748 1712 case 'c': /* Read alternative dmakerc file */
1749 1713 if (invert_this) {
1750 1714 dmake_rcfile_specified = false;
1751 1715 } else {
1752 1716 dmake_rcfile_specified = true;
1753 1717 }
1754 1718 return 2;
1755 1719 case 'D': /* Show lines read */
1756 1720 if (invert_this) {
1757 1721 read_trace_level--;
1758 1722 } else {
1759 1723 read_trace_level++;
1760 1724 }
1761 1725 return 0;
1762 1726 case 'd': /* Debug flag */
1763 1727 if (invert_this) {
1764 1728 debug_level--;
1765 1729 } else {
1766 1730 #if defined( HP_UX) || defined(linux)
1767 1731 if (debug_level < 2) /* Fixes a bug on HP-UX */
1768 1732 #endif
1769 1733 debug_level++;
1770 1734 }
1771 1735 return 0;
1772 1736 #ifdef NSE
1773 1737 case 'E':
1774 1738 if (invert_this) {
1775 1739 nse = false;
1776 1740 } else {
1777 1741 nse = true;
1778 1742 }
1779 1743 nse_init_source_suffixes();
1780 1744 return 0;
1781 1745 #endif
1782 1746 case 'e': /* Environment override flag */
1783 1747 if (invert_this) {
1784 1748 env_wins = false;
1785 1749 } else {
1786 1750 env_wins = true;
1787 1751 }
1788 1752 return 0;
1789 1753 case 'f': /* Read alternative makefile(s) */
1790 1754 return 1;
1791 1755 case 'g': /* Use alternative DMake group */
1792 1756 if (invert_this) {
1793 1757 dmake_group_specified = false;
1794 1758 } else {
1795 1759 dmake_group_specified = true;
1796 1760 }
1797 1761 return 4;
1798 1762 case 'i': /* Ignore errors */
1799 1763 if (invert_this) {
1800 1764 ignore_errors_all = false;
1801 1765 } else {
1802 1766 ignore_errors_all = true;
1803 1767 }
1804 1768 return 0;
1805 1769 case 'j': /* Use alternative DMake max jobs */
1806 1770 if (invert_this) {
1807 1771 dmake_max_jobs_specified = false;
1808 1772 } else {
1809 1773 dmake_max_jobs_specified = true;
1810 1774 }
1811 1775 return 8;
1812 1776 case 'K': /* Read alternative .make.state */
1813 1777 return 256;
1814 1778 case 'k': /* Keep making even after errors */
1815 1779 if (invert_this) {
1816 1780 continue_after_error = false;
1817 1781 } else {
1818 1782 continue_after_error = true;
1819 1783 continue_after_error_ever_seen = true;
1820 1784 }
1821 1785 return 0;
1822 1786 case 'M': /* Read alternative make.machines file */
1823 1787 if (invert_this) {
1824 1788 pmake_machinesfile_specified = false;
1825 1789 } else {
1826 1790 pmake_machinesfile_specified = true;
1827 1791 dmake_mode_type = parallel_mode;
1828 1792 no_parallel = false;
1829 1793 }
1830 1794 return 16;
1831 1795 case 'm': /* Use alternative DMake build mode */
1832 1796 if (invert_this) {
1833 1797 dmake_mode_specified = false;
1834 1798 } else {
1835 1799 dmake_mode_specified = true;
1836 1800 }
1837 1801 return 32;
1838 1802 case 'x': /* Use alternative DMake mode */
1839 1803 if (invert_this) {
1840 1804 dmake_add_mode_specified = false;
1841 1805 } else {
1842 1806 dmake_add_mode_specified = true;
1843 1807 }
1844 1808 return 1024;
1845 1809 case 'N': /* Reverse -n */
1846 1810 if (invert_this) {
1847 1811 do_not_exec_rule = true;
1848 1812 } else {
1849 1813 do_not_exec_rule = false;
1850 1814 }
1851 1815 return 0;
1852 1816 case 'n': /* Print, not exec commands */
1853 1817 if (invert_this) {
1854 1818 do_not_exec_rule = false;
1855 1819 } else {
1856 1820 do_not_exec_rule = true;
1857 1821 }
1858 1822 return 0;
1859 1823 #ifndef PARALLEL
1860 1824 case 'O': /* Send job start & result msgs */
1861 1825 if (invert_this) {
1862 1826 send_mtool_msgs = false;
1863 1827 } else {
1864 1828 #ifdef DISTRIBUTED
1865 1829 send_mtool_msgs = true;
1866 1830 #endif
1867 1831 }
1868 1832 return 128;
1869 1833 #endif
1870 1834 case 'o': /* Use alternative dmake output dir */
1871 1835 if (invert_this) {
1872 1836 dmake_odir_specified = false;
1873 1837 } else {
1874 1838 dmake_odir_specified = true;
1875 1839 }
1876 1840 return 512;
1877 1841 case 'P': /* Print for selected targets */
1878 1842 if (invert_this) {
1879 1843 report_dependencies_level--;
1880 1844 } else {
1881 1845 report_dependencies_level++;
1882 1846 }
1883 1847 return 0;
1884 1848 case 'p': /* Print description */
1885 1849 if (invert_this) {
1886 1850 trace_status = false;
1887 1851 do_not_exec_rule = false;
1888 1852 } else {
1889 1853 trace_status = true;
1890 1854 do_not_exec_rule = true;
1891 1855 }
1892 1856 return 0;
1893 1857 case 'q': /* Question flag */
1894 1858 if (invert_this) {
1895 1859 quest = false;
1896 1860 } else {
1897 1861 quest = true;
1898 1862 }
1899 1863 return 0;
1900 1864 case 'R': /* Don't run in parallel */
1901 1865 #ifdef TEAMWARE_MAKE_CMN
1902 1866 if (invert_this) {
1903 1867 pmake_cap_r_specified = false;
1904 1868 no_parallel = false;
1905 1869 } else {
1906 1870 pmake_cap_r_specified = true;
1907 1871 dmake_mode_type = serial_mode;
1908 1872 no_parallel = true;
1909 1873 }
1910 1874 #else
1911 1875 warning(catgets(catd, 1, 182, "Ignoring ParallelMake -R option"));
1912 1876 #endif
1913 1877 return 0;
1914 1878 case 'r': /* Turn off internal rules */
1915 1879 if (invert_this) {
1916 1880 ignore_default_mk = false;
1917 1881 } else {
1918 1882 ignore_default_mk = true;
1919 1883 }
1920 1884 return 0;
1921 1885 case 'S': /* Reverse -k */
1922 1886 if (invert_this) {
1923 1887 continue_after_error = true;
1924 1888 } else {
1925 1889 continue_after_error = false;
1926 1890 stop_after_error_ever_seen = true;
1927 1891 }
1928 1892 return 0;
1929 1893 case 's': /* Silent flag */
1930 1894 if (invert_this) {
1931 1895 silent_all = false;
1932 1896 } else {
1933 1897 silent_all = true;
1934 1898 }
1935 1899 return 0;
1936 1900 case 'T': /* Print target list */
1937 1901 if (invert_this) {
1938 1902 list_all_targets = false;
1939 1903 do_not_exec_rule = false;
1940 1904 } else {
1941 1905 list_all_targets = true;
1942 1906 do_not_exec_rule = true;
1943 1907 }
1944 1908 return 0;
1945 1909 case 't': /* Touch flag */
1946 1910 if (invert_this) {
1947 1911 touch = false;
1948 1912 } else {
1949 1913 touch = true;
1950 1914 }
1951 1915 return 0;
1952 1916 case 'u': /* Unconditional flag */
1953 1917 if (invert_this) {
1954 1918 build_unconditional = false;
1955 1919 } else {
1956 1920 build_unconditional = true;
↓ open down ↓ |
714 lines elided |
↑ open up ↑ |
1957 1921 }
1958 1922 return 0;
1959 1923 case 'V': /* SVR4 mode */
1960 1924 svr4 = true;
1961 1925 return 0;
1962 1926 case 'v': /* Version flag */
1963 1927 if (invert_this) {
1964 1928 } else {
1965 1929 #ifdef TEAMWARE_MAKE_CMN
1966 1930 fprintf(stdout, NOCATGETS("dmake: %s\n"), verstring);
1967 -#ifdef SUN5_0
1968 1931 exit_status = 0;
1969 -#endif
1970 1932 exit(0);
1971 1933 #else
1972 1934 warning(catgets(catd, 1, 324, "Ignoring DistributedMake -v option"));
1973 1935 #endif
1974 1936 }
1975 1937 return 0;
1976 1938 case 'w': /* Unconditional flag */
1977 1939 if (invert_this) {
1978 1940 report_cwd = false;
1979 1941 } else {
1980 1942 report_cwd = true;
1981 1943 }
1982 1944 return 0;
1983 1945 #if 0
1984 1946 case 'X': /* Filter stdout */
1985 1947 if (invert_this) {
1986 1948 filter_stderr = false;
1987 1949 } else {
1988 1950 filter_stderr = true;
1989 1951 }
1990 1952 return 0;
1991 1953 #endif
1992 1954 default:
1993 1955 break;
1994 1956 }
1995 1957 return 0;
1996 1958 }
1997 1959
1998 1960 /*
1999 1961 * setup_for_projectdir()
2000 1962 *
2001 1963 * Read the PROJECTDIR variable, if defined, and set the sccs path
2002 1964 *
2003 1965 * Parameters:
2004 1966 *
2005 1967 * Global variables used:
2006 1968 * sccs_dir_path Set to point to SCCS dir to use
2007 1969 */
2008 1970 static void
2009 1971 setup_for_projectdir(void)
2010 1972 {
2011 1973 static char path[MAXPATHLEN];
2012 1974 char cwdpath[MAXPATHLEN];
2013 1975 uid_t uid;
2014 1976 int done=0;
2015 1977
2016 1978 /* Check if we should use PROJECTDIR when reading the SCCS dir. */
2017 1979 sccs_dir_path = getenv(NOCATGETS("PROJECTDIR"));
2018 1980 if ((sccs_dir_path != NULL) &&
2019 1981 (sccs_dir_path[0] != (int) slash_char)) {
2020 1982 struct passwd *pwent;
2021 1983
2022 1984 {
2023 1985 uid = getuid();
2024 1986 pwent = getpwuid(uid);
2025 1987 if (pwent == NULL) {
2026 1988 fatal(catgets(catd, 1, 188, "Bogus USERID "));
2027 1989 }
2028 1990 if ((pwent = getpwnam(sccs_dir_path)) == NULL) {
2029 1991 /*empty block : it'll go & check cwd */
2030 1992 }
2031 1993 else {
2032 1994 (void) sprintf(path, NOCATGETS("%s/src"), pwent->pw_dir);
2033 1995 if (access(path, F_OK) == 0) {
2034 1996 sccs_dir_path = path;
2035 1997 done = 1;
2036 1998 } else {
2037 1999 (void) sprintf(path, NOCATGETS("%s/source"), pwent->pw_dir);
2038 2000 if (access(path, F_OK) == 0) {
2039 2001 sccs_dir_path = path;
2040 2002 done = 1;
2041 2003 }
2042 2004 }
2043 2005 }
2044 2006 if (!done) {
2045 2007 if (getcwd(cwdpath, MAXPATHLEN - 1 )) {
2046 2008
2047 2009 (void) sprintf(path, NOCATGETS("%s/%s"), cwdpath,sccs_dir_path);
2048 2010 if (access(path, F_OK) == 0) {
2049 2011 sccs_dir_path = path;
2050 2012 done = 1;
2051 2013 } else {
2052 2014 fatal(catgets(catd, 1, 189, "Bogus PROJECTDIR '%s'"), sccs_dir_path);
2053 2015 }
2054 2016 }
2055 2017 }
2056 2018 }
2057 2019 }
2058 2020 }
2059 2021
2060 2022 /*
2061 2023 * set_sgs_support()
2062 2024 *
2063 2025 * Add the libmakestate.so.1 lib to the env var SGS_SUPPORT
2064 2026 * if it's not already in there.
2065 2027 * The SGS_SUPPORT env var and libmakestate.so.1 is used by
2066 2028 * the linker ld to report .make.state info back to make.
2067 2029 */
2068 2030 static void
2069 2031 set_sgs_support()
2070 2032 {
2071 2033 int len;
2072 2034 char *newpath;
2073 2035 char *oldpath;
2074 2036 static char *prev_path;
2075 2037
2076 2038 oldpath = getenv(LD_SUPPORT_ENV_VAR);
2077 2039 if (oldpath == NULL) {
2078 2040 len = strlen(LD_SUPPORT_ENV_VAR) + 1 +
2079 2041 strlen(LD_SUPPORT_MAKE_LIB) + 1;
2080 2042 newpath = (char *) malloc(len);
2081 2043 sprintf(newpath, "%s=", LD_SUPPORT_ENV_VAR);
2082 2044 } else {
2083 2045 len = strlen(LD_SUPPORT_ENV_VAR) + 1 + strlen(oldpath) + 1 +
2084 2046 strlen(LD_SUPPORT_MAKE_LIB) + 1;
2085 2047 newpath = (char *) malloc(len);
2086 2048 sprintf(newpath, "%s=%s", LD_SUPPORT_ENV_VAR, oldpath);
2087 2049 }
2088 2050
2089 2051 #if defined(TEAMWARE_MAKE_CMN)
2090 2052
2091 2053 /* function maybe_append_str_to_env_var() is defined in avo_util library
2092 2054 * Serial make should not use this library !!!
2093 2055 */
2094 2056 maybe_append_str_to_env_var(newpath, LD_SUPPORT_MAKE_LIB);
2095 2057 #else
2096 2058 if (oldpath == NULL) {
2097 2059 sprintf(newpath, "%s%s", newpath, LD_SUPPORT_MAKE_LIB);
2098 2060 } else {
2099 2061 sprintf(newpath, "%s:%s", newpath, LD_SUPPORT_MAKE_LIB);
2100 2062 }
2101 2063 #endif
2102 2064 putenv(newpath);
2103 2065 if (prev_path) {
2104 2066 free(prev_path);
2105 2067 }
2106 2068 prev_path = newpath;
2107 2069 }
2108 2070
2109 2071 /*
2110 2072 * read_files_and_state(argc, argv)
2111 2073 *
2112 2074 * Read the makefiles we care about and the environment
2113 2075 * Also read the = style command line options
2114 2076 *
2115 2077 * Parameters:
2116 2078 * argc You know what this is
2117 2079 * argv You know what this is
2118 2080 *
2119 2081 * Static variables used:
2120 2082 * env_wins make -e, determines if env vars are RO
2121 2083 * ignore_default_mk make -r, determines if make.rules is read
2122 2084 * not_auto_depen dwight
2123 2085 *
2124 2086 * Global variables used:
2125 2087 * default_target_to_build Set to first proper target from file
2126 2088 * do_not_exec_rule Set to false when makfile is made
2127 2089 * dot The Name ".", used to read current dir
2128 2090 * empty_name The Name "", use as macro value
2129 2091 * keep_state Set if KEEP_STATE is in environment
2130 2092 * make_state The Name ".make.state", used to read file
2131 2093 * makefile_type Set to type of file being read
2132 2094 * makeflags The Name "MAKEFLAGS", used to set macro value
2133 2095 * not_auto dwight
2134 2096 * nse Set if NSE_ENV is in the environment
2135 2097 * read_trace_level Checked to se if the reader should trace
2136 2098 * report_dependencies If -P is on we do not read .make.state
2137 2099 * trace_reader Set if reader should trace
2138 2100 * virtual_root The Name "VIRTUAL_ROOT", used to check value
2139 2101 */
2140 2102 static void
2141 2103 read_files_and_state(int argc, char **argv)
2142 2104 {
2143 2105 wchar_t buffer[1000];
2144 2106 wchar_t buffer_posix[1000];
2145 2107 register char ch;
2146 2108 register char *cp;
2147 2109 Property def_make_macro = NULL;
2148 2110 Name def_make_name;
2149 2111 Name default_makefile;
2150 2112 String_rec dest;
2151 2113 wchar_t destbuffer[STRING_BUFFER_LENGTH];
2152 2114 register int i;
2153 2115 register int j;
2154 2116 Name keep_state_name;
2155 2117 int length;
2156 2118 Name Makefile;
2157 2119 register Property macro;
2158 2120 struct stat make_state_stat;
2159 2121 Name makefile_name;
2160 2122 register int makefile_next = 0;
2161 2123 register Boolean makefile_read = false;
2162 2124 String_rec makeflags_string;
2163 2125 String_rec makeflags_string_posix;
2164 2126 String_rec * makeflags_string_current;
2165 2127 Name makeflags_value_saved;
2166 2128 register Name name;
2167 2129 Name new_make_value;
2168 2130 Boolean save_do_not_exec_rule;
2169 2131 Name sdotMakefile;
2170 2132 Name sdotmakefile_name;
2171 2133 static wchar_t state_file_str;
2172 2134 static char state_file_str_mb[MAXPATHLEN];
2173 2135 static struct _Name state_filename;
2174 2136 Boolean temp;
2175 2137 char tmp_char;
2176 2138 wchar_t *tmp_wcs_buffer;
2177 2139 register Name value;
2178 2140 ASCII_Dyn_Array makeflags_and_macro;
2179 2141 Boolean is_xpg4;
2180 2142
2181 2143 /*
2182 2144 * Remember current mode. It may be changed after reading makefile
2183 2145 * and we will have to correct MAKEFLAGS variable.
2184 2146 */
2185 2147 is_xpg4 = posix;
2186 2148
2187 2149 MBSTOWCS(wcs_buffer, NOCATGETS("KEEP_STATE"));
2188 2150 keep_state_name = GETNAME(wcs_buffer, FIND_LENGTH);
2189 2151 MBSTOWCS(wcs_buffer, NOCATGETS("Makefile"));
2190 2152 Makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2191 2153 MBSTOWCS(wcs_buffer, NOCATGETS("makefile"));
2192 2154 makefile_name = GETNAME(wcs_buffer, FIND_LENGTH);
2193 2155 MBSTOWCS(wcs_buffer, NOCATGETS("s.makefile"));
2194 2156 sdotmakefile_name = GETNAME(wcs_buffer, FIND_LENGTH);
2195 2157 MBSTOWCS(wcs_buffer, NOCATGETS("s.Makefile"));
2196 2158 sdotMakefile = GETNAME(wcs_buffer, FIND_LENGTH);
2197 2159
2198 2160 /*
2199 2161 * Set flag if NSE is active
2200 2162 */
2201 2163 #ifdef NSE
2202 2164 if (getenv(NOCATGETS("NSE_ENV")) != NULL) {
2203 2165 nse = true;
2204 2166 }
2205 2167 #endif
2206 2168
2207 2169 /*
2208 2170 * initialize global dependency entry for .NOT_AUTO
2209 2171 */
2210 2172 not_auto_depen->next = NULL;
↓ open down ↓ |
231 lines elided |
↑ open up ↑ |
2211 2173 not_auto_depen->name = not_auto;
2212 2174 not_auto_depen->automatic = not_auto_depen->stale = false;
2213 2175
2214 2176 /*
2215 2177 * Read internal definitions and rules.
2216 2178 */
2217 2179 if (read_trace_level > 1) {
2218 2180 trace_reader = true;
2219 2181 }
2220 2182 if (!ignore_default_mk) {
2221 -#if defined(SUN5_0) || defined(HP_UX) || defined(linux)
2222 2183 if (svr4) {
2223 2184 MBSTOWCS(wcs_buffer, NOCATGETS("svr4.make.rules"));
2224 2185 default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2225 2186 } else {
2226 2187 MBSTOWCS(wcs_buffer, NOCATGETS("make.rules"));
2227 2188 default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2228 2189 }
2229 -#else
2230 - MBSTOWCS(wcs_buffer, NOCATGETS("default.mk"));
2231 - default_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2232 -#endif
2233 2190 default_makefile->stat.is_file = true;
2234 2191
2235 2192 (void) read_makefile(default_makefile,
2236 2193 true,
2237 2194 false,
2238 2195 true);
2239 2196 }
2240 2197
2241 2198 /*
2242 2199 * If the user did not redefine the MAKE macro in the
2243 2200 * default makefile (make.rules), then we'd like to
2244 2201 * change the macro value of MAKE to be some form
2245 2202 * of argv[0] for recursive MAKE builds.
2246 2203 */
2247 2204 MBSTOWCS(wcs_buffer, NOCATGETS("MAKE"));
2248 2205 def_make_name = GETNAME(wcs_buffer, wslen(wcs_buffer));
2249 2206 def_make_macro = get_prop(def_make_name->prop, macro_prop);
2250 2207 if ((def_make_macro != NULL) &&
2251 2208 (IS_EQUAL(def_make_macro->body.macro.value->string_mb,
2252 2209 NOCATGETS("make")))) {
2253 2210 MBSTOWCS(wcs_buffer, argv_zero_string);
2254 2211 new_make_value = GETNAME(wcs_buffer, wslen(wcs_buffer));
2255 2212 (void) SETVAR(def_make_name,
2256 2213 new_make_value,
2257 2214 false);
2258 2215 }
2259 2216
2260 2217 default_target_to_build = NULL;
2261 2218 trace_reader = false;
2262 2219
2263 2220 /*
2264 2221 * Read environment args. Let file args which follow override unless
2265 2222 * -e option seen. If -e option is not mentioned.
2266 2223 */
2267 2224 read_environment(env_wins);
2268 2225 if (getvar(virtual_root)->hash.length == 0) {
2269 2226 maybe_append_prop(virtual_root, macro_prop)
2270 2227 ->body.macro.exported = true;
2271 2228 MBSTOWCS(wcs_buffer, "/");
2272 2229 (void) SETVAR(virtual_root,
2273 2230 GETNAME(wcs_buffer, FIND_LENGTH),
2274 2231 false);
2275 2232 }
2276 2233
2277 2234 /*
2278 2235 * We now scan mf_argv and argv to see if we need to set
2279 2236 * any of the DMake-added options/variables in MAKEFLAGS.
2280 2237 */
2281 2238
2282 2239 makeflags_and_macro.start = 0;
2283 2240 makeflags_and_macro.size = 0;
2284 2241 enter_argv_values(mf_argc, mf_argv, &makeflags_and_macro);
2285 2242 enter_argv_values(argc, argv, &makeflags_and_macro);
2286 2243
2287 2244 /*
2288 2245 * Set MFLAGS and MAKEFLAGS
2289 2246 *
2290 2247 * Before reading makefile we do not know exactly which mode
2291 2248 * (posix or not) is used. So prepare two MAKEFLAGS strings
2292 2249 * for both posix and solaris modes because they are different.
2293 2250 */
2294 2251 INIT_STRING_FROM_STACK(makeflags_string, buffer);
2295 2252 INIT_STRING_FROM_STACK(makeflags_string_posix, buffer_posix);
2296 2253 append_char((int) hyphen_char, &makeflags_string);
2297 2254 append_char((int) hyphen_char, &makeflags_string_posix);
2298 2255
2299 2256 switch (read_trace_level) {
2300 2257 case 2:
2301 2258 append_char('D', &makeflags_string);
2302 2259 append_char('D', &makeflags_string_posix);
2303 2260 case 1:
2304 2261 append_char('D', &makeflags_string);
2305 2262 append_char('D', &makeflags_string_posix);
2306 2263 }
2307 2264 switch (debug_level) {
2308 2265 case 2:
2309 2266 append_char('d', &makeflags_string);
2310 2267 append_char('d', &makeflags_string_posix);
2311 2268 case 1:
2312 2269 append_char('d', &makeflags_string);
2313 2270 append_char('d', &makeflags_string_posix);
2314 2271 }
2315 2272 #ifdef NSE
2316 2273 if (nse) {
2317 2274 append_char('E', &makeflags_string);
2318 2275 }
2319 2276 #endif
2320 2277 if (env_wins) {
2321 2278 append_char('e', &makeflags_string);
2322 2279 append_char('e', &makeflags_string_posix);
2323 2280 }
2324 2281 if (ignore_errors_all) {
2325 2282 append_char('i', &makeflags_string);
2326 2283 append_char('i', &makeflags_string_posix);
2327 2284 }
2328 2285 if (continue_after_error) {
2329 2286 if (stop_after_error_ever_seen) {
2330 2287 append_char('S', &makeflags_string_posix);
2331 2288 append_char((int) space_char, &makeflags_string_posix);
2332 2289 append_char((int) hyphen_char, &makeflags_string_posix);
2333 2290 }
2334 2291 append_char('k', &makeflags_string);
2335 2292 append_char('k', &makeflags_string_posix);
2336 2293 } else {
2337 2294 if (stop_after_error_ever_seen
2338 2295 && continue_after_error_ever_seen) {
2339 2296 append_char('k', &makeflags_string_posix);
2340 2297 append_char((int) space_char, &makeflags_string_posix);
2341 2298 append_char((int) hyphen_char, &makeflags_string_posix);
2342 2299 append_char('S', &makeflags_string_posix);
2343 2300 }
2344 2301 }
2345 2302 if (do_not_exec_rule) {
2346 2303 append_char('n', &makeflags_string);
2347 2304 append_char('n', &makeflags_string_posix);
2348 2305 }
2349 2306 switch (report_dependencies_level) {
2350 2307 case 4:
2351 2308 append_char('P', &makeflags_string);
2352 2309 append_char('P', &makeflags_string_posix);
2353 2310 case 3:
2354 2311 append_char('P', &makeflags_string);
2355 2312 append_char('P', &makeflags_string_posix);
2356 2313 case 2:
2357 2314 append_char('P', &makeflags_string);
2358 2315 append_char('P', &makeflags_string_posix);
2359 2316 case 1:
2360 2317 append_char('P', &makeflags_string);
2361 2318 append_char('P', &makeflags_string_posix);
2362 2319 }
2363 2320 if (trace_status) {
2364 2321 append_char('p', &makeflags_string);
2365 2322 append_char('p', &makeflags_string_posix);
2366 2323 }
2367 2324 if (quest) {
2368 2325 append_char('q', &makeflags_string);
2369 2326 append_char('q', &makeflags_string_posix);
2370 2327 }
2371 2328 if (silent_all) {
2372 2329 append_char('s', &makeflags_string);
2373 2330 append_char('s', &makeflags_string_posix);
2374 2331 }
2375 2332 if (touch) {
2376 2333 append_char('t', &makeflags_string);
2377 2334 append_char('t', &makeflags_string_posix);
2378 2335 }
2379 2336 if (build_unconditional) {
2380 2337 append_char('u', &makeflags_string);
2381 2338 append_char('u', &makeflags_string_posix);
2382 2339 }
2383 2340 if (report_cwd) {
2384 2341 append_char('w', &makeflags_string);
2385 2342 append_char('w', &makeflags_string_posix);
2386 2343 }
2387 2344 #ifndef PARALLEL
2388 2345 /* -c dmake_rcfile */
2389 2346 if (dmake_rcfile_specified) {
2390 2347 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_RCFILE"));
2391 2348 dmake_rcfile = GETNAME(wcs_buffer, FIND_LENGTH);
2392 2349 append_makeflags_string(dmake_rcfile, &makeflags_string);
2393 2350 append_makeflags_string(dmake_rcfile, &makeflags_string_posix);
2394 2351 }
2395 2352 /* -g dmake_group */
2396 2353 if (dmake_group_specified) {
2397 2354 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_GROUP"));
2398 2355 dmake_group = GETNAME(wcs_buffer, FIND_LENGTH);
2399 2356 append_makeflags_string(dmake_group, &makeflags_string);
2400 2357 append_makeflags_string(dmake_group, &makeflags_string_posix);
2401 2358 }
2402 2359 /* -j dmake_max_jobs */
2403 2360 if (dmake_max_jobs_specified) {
2404 2361 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MAX_JOBS"));
2405 2362 dmake_max_jobs = GETNAME(wcs_buffer, FIND_LENGTH);
2406 2363 append_makeflags_string(dmake_max_jobs, &makeflags_string);
2407 2364 append_makeflags_string(dmake_max_jobs, &makeflags_string_posix);
2408 2365 }
2409 2366 /* -m dmake_mode */
2410 2367 if (dmake_mode_specified) {
2411 2368 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
2412 2369 dmake_mode = GETNAME(wcs_buffer, FIND_LENGTH);
2413 2370 append_makeflags_string(dmake_mode, &makeflags_string);
2414 2371 append_makeflags_string(dmake_mode, &makeflags_string_posix);
2415 2372 }
2416 2373 /* -x dmake_compat_mode */
2417 2374 // if (dmake_compat_mode_specified) {
2418 2375 // MBSTOWCS(wcs_buffer, NOCATGETS("SUN_MAKE_COMPAT_MODE"));
2419 2376 // dmake_compat_mode = GETNAME(wcs_buffer, FIND_LENGTH);
2420 2377 // append_makeflags_string(dmake_compat_mode, &makeflags_string);
2421 2378 // append_makeflags_string(dmake_compat_mode, &makeflags_string_posix);
2422 2379 // }
2423 2380 /* -x dmake_output_mode */
2424 2381 if (dmake_output_mode_specified) {
2425 2382 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_OUTPUT_MODE"));
2426 2383 dmake_output_mode = GETNAME(wcs_buffer, FIND_LENGTH);
2427 2384 append_makeflags_string(dmake_output_mode, &makeflags_string);
2428 2385 append_makeflags_string(dmake_output_mode, &makeflags_string_posix);
2429 2386 }
2430 2387 /* -o dmake_odir */
2431 2388 if (dmake_odir_specified) {
2432 2389 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_ODIR"));
2433 2390 dmake_odir = GETNAME(wcs_buffer, FIND_LENGTH);
2434 2391 append_makeflags_string(dmake_odir, &makeflags_string);
2435 2392 append_makeflags_string(dmake_odir, &makeflags_string_posix);
2436 2393 }
2437 2394 /* -M pmake_machinesfile */
2438 2395 if (pmake_machinesfile_specified) {
2439 2396 MBSTOWCS(wcs_buffer, NOCATGETS("PMAKE_MACHINESFILE"));
2440 2397 pmake_machinesfile = GETNAME(wcs_buffer, FIND_LENGTH);
2441 2398 append_makeflags_string(pmake_machinesfile, &makeflags_string);
2442 2399 append_makeflags_string(pmake_machinesfile, &makeflags_string_posix);
2443 2400 }
2444 2401 /* -R */
2445 2402 if (pmake_cap_r_specified) {
2446 2403 append_char((int) space_char, &makeflags_string);
2447 2404 append_char((int) hyphen_char, &makeflags_string);
2448 2405 append_char('R', &makeflags_string);
2449 2406 append_char((int) space_char, &makeflags_string_posix);
2450 2407 append_char((int) hyphen_char, &makeflags_string_posix);
2451 2408 append_char('R', &makeflags_string_posix);
2452 2409 }
2453 2410 #endif
2454 2411
2455 2412 /*
2456 2413 * Make sure MAKEFLAGS is exported
2457 2414 */
2458 2415 maybe_append_prop(makeflags, macro_prop)->
2459 2416 body.macro.exported = true;
2460 2417
2461 2418 if (makeflags_string.buffer.start[1] != (int) nul_char) {
2462 2419 if (makeflags_string.buffer.start[1] != (int) space_char) {
2463 2420 MBSTOWCS(wcs_buffer, NOCATGETS("MFLAGS"));
2464 2421 (void) SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
2465 2422 GETNAME(makeflags_string.buffer.start,
2466 2423 FIND_LENGTH),
2467 2424 false);
2468 2425 } else {
2469 2426 MBSTOWCS(wcs_buffer, NOCATGETS("MFLAGS"));
2470 2427 (void) SETVAR(GETNAME(wcs_buffer, FIND_LENGTH),
2471 2428 GETNAME(makeflags_string.buffer.start + 2,
2472 2429 FIND_LENGTH),
2473 2430 false);
2474 2431 }
2475 2432 }
2476 2433
2477 2434 /*
2478 2435 * Add command line macro to POSIX makeflags_string
2479 2436 */
2480 2437 if (makeflags_and_macro.start) {
2481 2438 tmp_char = (char) space_char;
2482 2439 cp = makeflags_and_macro.start;
2483 2440 do {
2484 2441 append_char(tmp_char, &makeflags_string_posix);
2485 2442 } while ( tmp_char = *cp++ );
2486 2443 retmem_mb(makeflags_and_macro.start);
2487 2444 }
2488 2445
2489 2446 /*
2490 2447 * Now set the value of MAKEFLAGS macro in accordance
2491 2448 * with current mode.
2492 2449 */
2493 2450 macro = maybe_append_prop(makeflags, macro_prop);
2494 2451 temp = (Boolean) macro->body.macro.read_only;
2495 2452 macro->body.macro.read_only = false;
2496 2453 if(posix || gnu_style) {
2497 2454 makeflags_string_current = &makeflags_string_posix;
2498 2455 } else {
2499 2456 makeflags_string_current = &makeflags_string;
2500 2457 }
2501 2458 if (makeflags_string_current->buffer.start[1] == (int) nul_char) {
2502 2459 makeflags_value_saved =
2503 2460 GETNAME( makeflags_string_current->buffer.start + 1
2504 2461 , FIND_LENGTH
2505 2462 );
2506 2463 } else {
2507 2464 if (makeflags_string_current->buffer.start[1] != (int) space_char) {
2508 2465 makeflags_value_saved =
2509 2466 GETNAME( makeflags_string_current->buffer.start
2510 2467 , FIND_LENGTH
2511 2468 );
2512 2469 } else {
2513 2470 makeflags_value_saved =
2514 2471 GETNAME( makeflags_string_current->buffer.start + 2
2515 2472 , FIND_LENGTH
2516 2473 );
2517 2474 }
2518 2475 }
2519 2476 (void) SETVAR( makeflags
2520 2477 , makeflags_value_saved
2521 2478 , false
2522 2479 );
2523 2480 macro->body.macro.read_only = temp;
2524 2481
2525 2482 /*
2526 2483 * Read command line "-f" arguments and ignore -c, g, j, K, M, m, O and o args.
2527 2484 */
2528 2485 save_do_not_exec_rule = do_not_exec_rule;
2529 2486 do_not_exec_rule = false;
2530 2487 if (read_trace_level > 0) {
2531 2488 trace_reader = true;
2532 2489 }
2533 2490
2534 2491 for (i = 1; i < argc; i++) {
2535 2492 if (argv[i] &&
2536 2493 (argv[i][0] == (int) hyphen_char) &&
2537 2494 (argv[i][1] == 'f') &&
2538 2495 (argv[i][2] == (int) nul_char)) {
2539 2496 argv[i] = NULL; /* Remove -f */
2540 2497 if (i >= argc - 1) {
2541 2498 fatal(catgets(catd, 1, 190, "No filename argument after -f flag"));
2542 2499 }
2543 2500 MBSTOWCS(wcs_buffer, argv[++i]);
2544 2501 primary_makefile = GETNAME(wcs_buffer, FIND_LENGTH);
2545 2502 (void) read_makefile(primary_makefile, true, true, true);
2546 2503 argv[i] = NULL; /* Remove filename */
2547 2504 makefile_read = true;
2548 2505 } else if (argv[i] &&
2549 2506 (argv[i][0] == (int) hyphen_char) &&
2550 2507 (argv[i][1] == 'c' ||
2551 2508 argv[i][1] == 'g' ||
2552 2509 argv[i][1] == 'j' ||
2553 2510 argv[i][1] == 'K' ||
2554 2511 argv[i][1] == 'M' ||
2555 2512 argv[i][1] == 'm' ||
2556 2513 argv[i][1] == 'O' ||
2557 2514 argv[i][1] == 'o') &&
2558 2515 (argv[i][2] == (int) nul_char)) {
2559 2516 argv[i] = NULL;
2560 2517 argv[++i] = NULL;
2561 2518 }
2562 2519 }
2563 2520
2564 2521 /*
2565 2522 * If no command line "-f" args then look for "makefile", and then for
2566 2523 * "Makefile" if "makefile" isn't found.
2567 2524 */
2568 2525 if (!makefile_read) {
2569 2526 (void) read_dir(dot,
2570 2527 (wchar_t *) NULL,
2571 2528 (Property) NULL,
2572 2529 (wchar_t *) NULL);
2573 2530 if (!posix) {
2574 2531 if (makefile_name->stat.is_file) {
2575 2532 if (Makefile->stat.is_file) {
2576 2533 warning(catgets(catd, 1, 310, "Both `makefile' and `Makefile' exist"));
2577 2534 }
2578 2535 primary_makefile = makefile_name;
2579 2536 makefile_read = read_makefile(makefile_name,
2580 2537 false,
2581 2538 false,
2582 2539 true);
2583 2540 }
2584 2541 if (!makefile_read &&
2585 2542 Makefile->stat.is_file) {
2586 2543 primary_makefile = Makefile;
2587 2544 makefile_read = read_makefile(Makefile,
2588 2545 false,
2589 2546 false,
2590 2547 true);
2591 2548 }
2592 2549 } else {
2593 2550
2594 2551 enum sccs_stat save_m_has_sccs = NO_SCCS;
2595 2552 enum sccs_stat save_M_has_sccs = NO_SCCS;
2596 2553
2597 2554 if (makefile_name->stat.is_file) {
2598 2555 if (Makefile->stat.is_file) {
2599 2556 warning(catgets(catd, 1, 191, "Both `makefile' and `Makefile' exist"));
2600 2557 }
2601 2558 }
2602 2559 if (makefile_name->stat.is_file) {
2603 2560 if (makefile_name->stat.has_sccs == NO_SCCS) {
2604 2561 primary_makefile = makefile_name;
2605 2562 makefile_read = read_makefile(makefile_name,
2606 2563 false,
2607 2564 false,
2608 2565 true);
2609 2566 } else {
2610 2567 save_m_has_sccs = makefile_name->stat.has_sccs;
2611 2568 makefile_name->stat.has_sccs = NO_SCCS;
2612 2569 primary_makefile = makefile_name;
2613 2570 makefile_read = read_makefile(makefile_name,
2614 2571 false,
2615 2572 false,
2616 2573 true);
2617 2574 }
2618 2575 }
2619 2576 if (!makefile_read &&
2620 2577 Makefile->stat.is_file) {
2621 2578 if (Makefile->stat.has_sccs == NO_SCCS) {
2622 2579 primary_makefile = Makefile;
2623 2580 makefile_read = read_makefile(Makefile,
2624 2581 false,
2625 2582 false,
2626 2583 true);
2627 2584 } else {
2628 2585 save_M_has_sccs = Makefile->stat.has_sccs;
2629 2586 Makefile->stat.has_sccs = NO_SCCS;
2630 2587 primary_makefile = Makefile;
2631 2588 makefile_read = read_makefile(Makefile,
2632 2589 false,
2633 2590 false,
2634 2591 true);
2635 2592 }
2636 2593 }
2637 2594 if (!makefile_read &&
2638 2595 makefile_name->stat.is_file) {
2639 2596 makefile_name->stat.has_sccs = save_m_has_sccs;
2640 2597 primary_makefile = makefile_name;
2641 2598 makefile_read = read_makefile(makefile_name,
2642 2599 false,
2643 2600 false,
2644 2601 true);
2645 2602 }
2646 2603 if (!makefile_read &&
2647 2604 Makefile->stat.is_file) {
2648 2605 Makefile->stat.has_sccs = save_M_has_sccs;
2649 2606 primary_makefile = Makefile;
2650 2607 makefile_read = read_makefile(Makefile,
2651 2608 false,
2652 2609 false,
2653 2610 true);
2654 2611 }
2655 2612 }
2656 2613 }
2657 2614 do_not_exec_rule = save_do_not_exec_rule;
2658 2615 allrules_read = makefile_read;
2659 2616 trace_reader = false;
2660 2617
2661 2618 /*
2662 2619 * Now get current value of MAKEFLAGS and compare it with
2663 2620 * the saved value we set before reading makefile.
2664 2621 * If they are different then MAKEFLAGS is subsequently set by
2665 2622 * makefile, just leave it there. Otherwise, if make mode
2666 2623 * is changed by using .POSIX target in makefile we need
2667 2624 * to correct MAKEFLAGS value.
2668 2625 */
2669 2626 Name mf_val = getvar(makeflags);
2670 2627 if( (posix != is_xpg4)
2671 2628 && (!strcmp(mf_val->string_mb, makeflags_value_saved->string_mb)))
2672 2629 {
2673 2630 if (makeflags_string_posix.buffer.start[1] == (int) nul_char) {
2674 2631 (void) SETVAR(makeflags,
2675 2632 GETNAME(makeflags_string_posix.buffer.start + 1,
2676 2633 FIND_LENGTH),
2677 2634 false);
2678 2635 } else {
2679 2636 if (makeflags_string_posix.buffer.start[1] != (int) space_char) {
2680 2637 (void) SETVAR(makeflags,
2681 2638 GETNAME(makeflags_string_posix.buffer.start,
2682 2639 FIND_LENGTH),
2683 2640 false);
2684 2641 } else {
2685 2642 (void) SETVAR(makeflags,
2686 2643 GETNAME(makeflags_string_posix.buffer.start + 2,
2687 2644 FIND_LENGTH),
2688 2645 false);
2689 2646 }
2690 2647 }
2691 2648 }
2692 2649
2693 2650 if (makeflags_string.free_after_use) {
2694 2651 retmem(makeflags_string.buffer.start);
2695 2652 }
2696 2653 if (makeflags_string_posix.free_after_use) {
2697 2654 retmem(makeflags_string_posix.buffer.start);
2698 2655 }
2699 2656 makeflags_string.buffer.start = NULL;
2700 2657 makeflags_string_posix.buffer.start = NULL;
2701 2658
2702 2659 if (posix) {
2703 2660 /*
2704 2661 * If the user did not redefine the ARFLAGS macro in the
2705 2662 * default makefile (make.rules), then we'd like to
2706 2663 * change the macro value of ARFLAGS to be in accordance
2707 2664 * with "POSIX" requirements.
2708 2665 */
2709 2666 MBSTOWCS(wcs_buffer, NOCATGETS("ARFLAGS"));
2710 2667 name = GETNAME(wcs_buffer, wslen(wcs_buffer));
2711 2668 macro = get_prop(name->prop, macro_prop);
2712 2669 if ((macro != NULL) && /* Maybe (macro == NULL) || ? */
2713 2670 (IS_EQUAL(macro->body.macro.value->string_mb,
2714 2671 NOCATGETS("rv")))) {
2715 2672 MBSTOWCS(wcs_buffer, NOCATGETS("-rv"));
2716 2673 value = GETNAME(wcs_buffer, wslen(wcs_buffer));
2717 2674 (void) SETVAR(name,
2718 2675 value,
2719 2676 false);
2720 2677 }
2721 2678 }
2722 2679
2723 2680 if (!posix && !svr4) {
2724 2681 set_sgs_support();
2725 2682 }
2726 2683
2727 2684
2728 2685 /*
2729 2686 * Make sure KEEP_STATE is in the environment if KEEP_STATE is on.
2730 2687 */
2731 2688 macro = get_prop(keep_state_name->prop, macro_prop);
2732 2689 if ((macro != NULL) &&
2733 2690 macro->body.macro.exported) {
2734 2691 keep_state = true;
2735 2692 }
2736 2693 if (keep_state) {
2737 2694 if (macro == NULL) {
2738 2695 macro = maybe_append_prop(keep_state_name,
2739 2696 macro_prop);
2740 2697 }
2741 2698 macro->body.macro.exported = true;
2742 2699 (void) SETVAR(keep_state_name,
2743 2700 empty_name,
2744 2701 false);
2745 2702
2746 2703 /*
2747 2704 * Read state file
2748 2705 */
2749 2706
2750 2707 /* Before we read state, let's make sure we have
2751 2708 ** right state file.
2752 2709 */
2753 2710 /* just in case macro references are used in make_state file
2754 2711 ** name, we better expand them at this stage using expand_value.
2755 2712 */
2756 2713 INIT_STRING_FROM_STACK(dest, destbuffer);
2757 2714 expand_value(make_state, &dest, false);
2758 2715
2759 2716 make_state = GETNAME(dest.buffer.start, FIND_LENGTH);
2760 2717
2761 2718 if(!stat(make_state->string_mb, &make_state_stat)) {
2762 2719 if(!(make_state_stat.st_mode & S_IFREG) ) {
2763 2720 /* copy the make_state structure to the other
2764 2721 ** and then let make_state point to the new
2765 2722 ** one.
2766 2723 */
2767 2724 memcpy(&state_filename, make_state,sizeof(state_filename));
2768 2725 state_filename.string_mb = state_file_str_mb;
2769 2726 /* Just a kludge to avoid two slashes back to back */
2770 2727 if((make_state->hash.length == 1)&&
2771 2728 (make_state->string_mb[0] == '/')) {
2772 2729 make_state->hash.length = 0;
2773 2730 make_state->string_mb[0] = '\0';
2774 2731 }
2775 2732 sprintf(state_file_str_mb,NOCATGETS("%s%s"),
2776 2733 make_state->string_mb,NOCATGETS("/.make.state"));
2777 2734 make_state = &state_filename;
2778 2735 /* adjust the length to reflect the appended string */
2779 2736 make_state->hash.length += 12;
2780 2737 }
2781 2738 } else { /* the file doesn't exist or no permission */
2782 2739 char tmp_path[MAXPATHLEN];
2783 2740 char *slashp;
2784 2741
2785 2742 if (slashp = strrchr(make_state->string_mb, '/')) {
2786 2743 strncpy(tmp_path, make_state->string_mb,
2787 2744 (slashp - make_state->string_mb));
2788 2745 tmp_path[slashp - make_state->string_mb]=0;
2789 2746 if(strlen(tmp_path)) {
2790 2747 if(stat(tmp_path, &make_state_stat)) {
2791 2748 warning(catgets(catd, 1, 192, "directory %s for .KEEP_STATE_FILE does not exist"),tmp_path);
2792 2749 }
2793 2750 if (access(tmp_path, F_OK) != 0) {
2794 2751 warning(catgets(catd, 1, 193, "can't access dir %s"),tmp_path);
2795 2752 }
2796 2753 }
2797 2754 }
2798 2755 }
2799 2756 if (report_dependencies_level != 1) {
2800 2757 Makefile_type makefile_type_temp = makefile_type;
2801 2758 makefile_type = reading_statefile;
2802 2759 if (read_trace_level > 1) {
2803 2760 trace_reader = true;
2804 2761 }
2805 2762 (void) read_simple_file(make_state,
2806 2763 false,
2807 2764 false,
2808 2765 false,
2809 2766 false,
2810 2767 false,
2811 2768 true);
2812 2769 trace_reader = false;
2813 2770 makefile_type = makefile_type_temp;
2814 2771 }
2815 2772 }
2816 2773 }
2817 2774
2818 2775 /*
2819 2776 * Scan the argv for options and "=" type args and make them readonly.
2820 2777 */
2821 2778 static void
2822 2779 enter_argv_values(int argc, char *argv[], ASCII_Dyn_Array *makeflags_and_macro)
2823 2780 {
2824 2781 register char *cp;
2825 2782 register int i;
2826 2783 int length;
2827 2784 register Name name;
2828 2785 int opt_separator = argc;
2829 2786 char tmp_char;
2830 2787 wchar_t *tmp_wcs_buffer;
2831 2788 register Name value;
2832 2789 Boolean append = false;
2833 2790 Property macro;
2834 2791 struct stat statbuf;
2835 2792
2836 2793
2837 2794 /* Read argv options and "=" type args and make them readonly. */
2838 2795 makefile_type = reading_nothing;
2839 2796 for (i = 1; i < argc; ++i) {
2840 2797 append = false;
2841 2798 if (argv[i] == NULL) {
2842 2799 continue;
2843 2800 } else if (((argv[i][0] == '-') && (argv[i][1] == '-')) ||
2844 2801 ((argv[i][0] == (int) ' ') &&
2845 2802 (argv[i][1] == (int) '-') &&
2846 2803 (argv[i][2] == (int) ' ') &&
2847 2804 (argv[i][3] == (int) '-'))) {
2848 2805 argv[i] = NULL;
2849 2806 opt_separator = i;
2850 2807 continue;
2851 2808 } else if ((i < opt_separator) && (argv[i][0] == (int) hyphen_char)) {
2852 2809 switch (parse_command_option(argv[i][1])) {
2853 2810 case 1: /* -f seen */
2854 2811 ++i;
2855 2812 continue;
2856 2813 case 2: /* -c seen */
2857 2814 if (argv[i+1] == NULL) {
2858 2815 fatal(catgets(catd, 1, 194, "No dmake rcfile argument after -c flag"));
2859 2816 }
2860 2817 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_RCFILE"));
2861 2818 name = GETNAME(wcs_buffer, FIND_LENGTH);
2862 2819 break;
2863 2820 case 4: /* -g seen */
2864 2821 if (argv[i+1] == NULL) {
2865 2822 fatal(catgets(catd, 1, 195, "No dmake group argument after -g flag"));
2866 2823 }
2867 2824 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_GROUP"));
2868 2825 name = GETNAME(wcs_buffer, FIND_LENGTH);
2869 2826 break;
2870 2827 case 8: /* -j seen */
2871 2828 if (argv[i+1] == NULL) {
2872 2829 fatal(catgets(catd, 1, 196, "No dmake max jobs argument after -j flag"));
2873 2830 }
2874 2831 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MAX_JOBS"));
2875 2832 name = GETNAME(wcs_buffer, FIND_LENGTH);
2876 2833 break;
2877 2834 case 16: /* -M seen */
2878 2835 if (argv[i+1] == NULL) {
2879 2836 fatal(catgets(catd, 1, 323, "No pmake machinesfile argument after -M flag"));
2880 2837 }
2881 2838 MBSTOWCS(wcs_buffer, NOCATGETS("PMAKE_MACHINESFILE"));
2882 2839 name = GETNAME(wcs_buffer, FIND_LENGTH);
2883 2840 break;
2884 2841 case 32: /* -m seen */
2885 2842 if (argv[i+1] == NULL) {
2886 2843 fatal(catgets(catd, 1, 197, "No dmake mode argument after -m flag"));
2887 2844 }
2888 2845 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_MODE"));
2889 2846 name = GETNAME(wcs_buffer, FIND_LENGTH);
2890 2847 break;
2891 2848 case 128: /* -O seen */
2892 2849 if (argv[i+1] == NULL) {
2893 2850 fatal(catgets(catd, 1, 287, "No file descriptor argument after -O flag"));
2894 2851 }
2895 2852 mtool_msgs_fd = atoi(argv[i+1]);
2896 2853 /* find out if mtool_msgs_fd is a valid file descriptor */
2897 2854 if (fstat(mtool_msgs_fd, &statbuf) < 0) {
2898 2855 fatal(catgets(catd, 1, 355, "Invalid file descriptor %d after -O flag"), mtool_msgs_fd);
2899 2856 }
2900 2857 argv[i] = NULL;
2901 2858 argv[i+1] = NULL;
2902 2859 continue;
2903 2860 case 256: /* -K seen */
2904 2861 if (argv[i+1] == NULL) {
2905 2862 fatal(catgets(catd, 1, 288, "No makestate filename argument after -K flag"));
2906 2863 }
2907 2864 MBSTOWCS(wcs_buffer, argv[i+1]);
2908 2865 make_state = GETNAME(wcs_buffer, FIND_LENGTH);
2909 2866 keep_state = true;
2910 2867 argv[i] = NULL;
2911 2868 argv[i+1] = NULL;
2912 2869 continue;
2913 2870 case 512: /* -o seen */
2914 2871 if (argv[i+1] == NULL) {
2915 2872 fatal(catgets(catd, 1, 312, "No dmake output dir argument after -o flag"));
2916 2873 }
2917 2874 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_ODIR"));
2918 2875 name = GETNAME(wcs_buffer, FIND_LENGTH);
2919 2876 break;
2920 2877 case 1024: /* -x seen */
2921 2878 if (argv[i+1] == NULL) {
2922 2879 fatal(catgets(catd, 1, 351, "No argument after -x flag"));
2923 2880 }
2924 2881 length = strlen( NOCATGETS("SUN_MAKE_COMPAT_MODE="));
2925 2882 if (strncmp(argv[i+1], NOCATGETS("SUN_MAKE_COMPAT_MODE="), length) == 0) {
2926 2883 argv[i+1] = &argv[i+1][length];
2927 2884 MBSTOWCS(wcs_buffer, NOCATGETS("SUN_MAKE_COMPAT_MODE"));
2928 2885 name = GETNAME(wcs_buffer, FIND_LENGTH);
2929 2886 dmake_compat_mode_specified = dmake_add_mode_specified;
2930 2887 break;
2931 2888 }
2932 2889 length = strlen( NOCATGETS("DMAKE_OUTPUT_MODE="));
2933 2890 if (strncmp(argv[i+1], NOCATGETS("DMAKE_OUTPUT_MODE="), length) == 0) {
2934 2891 argv[i+1] = &argv[i+1][length];
2935 2892 MBSTOWCS(wcs_buffer, NOCATGETS("DMAKE_OUTPUT_MODE"));
2936 2893 name = GETNAME(wcs_buffer, FIND_LENGTH);
2937 2894 dmake_output_mode_specified = dmake_add_mode_specified;
2938 2895 } else {
2939 2896 warning(catgets(catd, 1, 354, "Unknown argument `%s' after -x flag (ignored)"),
2940 2897 argv[i+1]);
2941 2898 argv[i] = argv[i + 1] = NULL;
2942 2899 continue;
2943 2900 }
2944 2901 break;
2945 2902 default: /* Shouldn't reach here */
2946 2903 argv[i] = NULL;
2947 2904 continue;
2948 2905 }
2949 2906 argv[i] = NULL;
2950 2907 if (i == (argc - 1)) {
2951 2908 break;
2952 2909 }
2953 2910 if ((length = strlen(argv[i+1])) >= MAXPATHLEN) {
2954 2911 tmp_wcs_buffer = ALLOC_WC(length + 1);
2955 2912 (void) mbstowcs(tmp_wcs_buffer, argv[i+1], length + 1);
2956 2913 value = GETNAME(tmp_wcs_buffer, FIND_LENGTH);
2957 2914 retmem(tmp_wcs_buffer);
2958 2915 } else {
2959 2916 MBSTOWCS(wcs_buffer, argv[i+1]);
2960 2917 value = GETNAME(wcs_buffer, FIND_LENGTH);
2961 2918 }
2962 2919 argv[i+1] = NULL;
2963 2920 } else if ((cp = strchr(argv[i], (int) equal_char)) != NULL) {
2964 2921 /*
2965 2922 * Combine all macro in dynamic array
2966 2923 */
2967 2924 if(*(cp-1) == (int) plus_char)
2968 2925 {
2969 2926 if(isspace(*(cp-2))) {
2970 2927 append = true;
2971 2928 cp--;
2972 2929 }
2973 2930 }
2974 2931 if(!append)
2975 2932 append_or_replace_macro_in_dyn_array(makeflags_and_macro, argv[i]);
2976 2933
2977 2934 while (isspace(*(cp-1))) {
2978 2935 cp--;
2979 2936 }
2980 2937 tmp_char = *cp;
2981 2938 *cp = (int) nul_char;
2982 2939 MBSTOWCS(wcs_buffer, argv[i]);
2983 2940 *cp = tmp_char;
2984 2941 name = GETNAME(wcs_buffer, wslen(wcs_buffer));
2985 2942 while (*cp != (int) equal_char) {
2986 2943 cp++;
2987 2944 }
2988 2945 cp++;
2989 2946 while (isspace(*cp) && (*cp != (int) nul_char)) {
2990 2947 cp++;
2991 2948 }
2992 2949 if ((length = strlen(cp)) >= MAXPATHLEN) {
2993 2950 tmp_wcs_buffer = ALLOC_WC(length + 1);
2994 2951 (void) mbstowcs(tmp_wcs_buffer, cp, length + 1);
2995 2952 value = GETNAME(tmp_wcs_buffer, FIND_LENGTH);
2996 2953 retmem(tmp_wcs_buffer);
2997 2954 } else {
2998 2955 MBSTOWCS(wcs_buffer, cp);
2999 2956 value = GETNAME(wcs_buffer, FIND_LENGTH);
3000 2957 }
3001 2958 argv[i] = NULL;
3002 2959 } else {
3003 2960 /* Illegal MAKEFLAGS argument */
3004 2961 continue;
3005 2962 }
3006 2963 if(append) {
3007 2964 setvar_append(name, value);
3008 2965 append = false;
3009 2966 } else {
3010 2967 macro = maybe_append_prop(name, macro_prop);
3011 2968 macro->body.macro.exported = true;
3012 2969 SETVAR(name, value, false)->body.macro.read_only = true;
3013 2970 }
3014 2971 }
3015 2972 }
3016 2973
3017 2974 /*
3018 2975 * Append the DMake option and value to the MAKEFLAGS string.
3019 2976 */
3020 2977 static void
3021 2978 append_makeflags_string(Name name, register String makeflags_string)
3022 2979 {
3023 2980 const char *option;
3024 2981
3025 2982 if (strcmp(name->string_mb, NOCATGETS("DMAKE_GROUP")) == 0) {
3026 2983 option = NOCATGETS(" -g ");
3027 2984 } else if (strcmp(name->string_mb, NOCATGETS("DMAKE_MAX_JOBS")) == 0) {
3028 2985 option = NOCATGETS(" -j ");
3029 2986 } else if (strcmp(name->string_mb, NOCATGETS("DMAKE_MODE")) == 0) {
3030 2987 option = NOCATGETS(" -m ");
3031 2988 } else if (strcmp(name->string_mb, NOCATGETS("DMAKE_ODIR")) == 0) {
3032 2989 option = NOCATGETS(" -o ");
3033 2990 } else if (strcmp(name->string_mb, NOCATGETS("DMAKE_RCFILE")) == 0) {
3034 2991 option = NOCATGETS(" -c ");
3035 2992 } else if (strcmp(name->string_mb, NOCATGETS("PMAKE_MACHINESFILE")) == 0) {
3036 2993 option = NOCATGETS(" -M ");
3037 2994 } else if (strcmp(name->string_mb, NOCATGETS("DMAKE_OUTPUT_MODE")) == 0) {
3038 2995 option = NOCATGETS(" -x DMAKE_OUTPUT_MODE=");
3039 2996 } else if (strcmp(name->string_mb, NOCATGETS("SUN_MAKE_COMPAT_MODE")) == 0) {
3040 2997 option = NOCATGETS(" -x SUN_MAKE_COMPAT_MODE=");
3041 2998 } else {
3042 2999 fatal(catgets(catd, 1, 289, "Internal error: name not recognized in append_makeflags_string()"));
3043 3000 }
3044 3001 Property prop = maybe_append_prop(name, macro_prop);
3045 3002 if( prop == 0 || prop->body.macro.value == 0 ||
3046 3003 prop->body.macro.value->string_mb == 0 ) {
3047 3004 return;
3048 3005 }
3049 3006 char mbs_value[MAXPATHLEN + 100];
3050 3007 strcpy(mbs_value, option);
3051 3008 strcat(mbs_value, prop->body.macro.value->string_mb);
3052 3009 MBSTOWCS(wcs_buffer, mbs_value);
3053 3010 append_string(wcs_buffer, makeflags_string, FIND_LENGTH);
3054 3011 }
3055 3012
3056 3013 /*
3057 3014 * read_environment(read_only)
3058 3015 *
3059 3016 * This routine reads the process environment when make starts and enters
3060 3017 * it as make macros. The environment variable SHELL is ignored.
3061 3018 *
3062 3019 * Parameters:
3063 3020 * read_only Should we make env vars read only?
3064 3021 *
3065 3022 * Global variables used:
3066 3023 * report_pwd Set if this make was started by other make
3067 3024 */
3068 3025 static void
3069 3026 read_environment(Boolean read_only)
3070 3027 {
3071 3028 register char **environment;
3072 3029 int length;
3073 3030 wchar_t *tmp_wcs_buffer;
3074 3031 Boolean alloced_tmp_wcs_buffer = false;
3075 3032 register wchar_t *name;
3076 3033 register wchar_t *value;
3077 3034 register Name macro;
3078 3035 Property val;
3079 3036 Boolean read_only_saved;
3080 3037
3081 3038 reading_environment = true;
3082 3039 environment = environ;
3083 3040 for (; *environment; environment++) {
3084 3041 read_only_saved = read_only;
3085 3042 if ((length = strlen(*environment)) >= MAXPATHLEN) {
3086 3043 tmp_wcs_buffer = ALLOC_WC(length + 1);
3087 3044 alloced_tmp_wcs_buffer = true;
3088 3045 (void) mbstowcs(tmp_wcs_buffer, *environment, length + 1);
3089 3046 name = tmp_wcs_buffer;
3090 3047 } else {
3091 3048 MBSTOWCS(wcs_buffer, *environment);
3092 3049 name = wcs_buffer;
3093 3050 }
3094 3051 value = (wchar_t *) wschr(name, (int) equal_char);
3095 3052
3096 3053 /*
3097 3054 * Looks like there's a bug in the system, but sometimes
3098 3055 * you can get blank lines in *environment.
3099 3056 */
3100 3057 if (!value) {
3101 3058 continue;
3102 3059 }
3103 3060 MBSTOWCS(wcs_buffer2, NOCATGETS("SHELL="));
3104 3061 if (IS_WEQUALN(name, wcs_buffer2, wslen(wcs_buffer2))) {
3105 3062 continue;
3106 3063 }
3107 3064 MBSTOWCS(wcs_buffer2, NOCATGETS("MAKEFLAGS="));
3108 3065 if (IS_WEQUALN(name, wcs_buffer2, wslen(wcs_buffer2))) {
3109 3066 report_pwd = true;
3110 3067 /*
3111 3068 * In POSIX mode we do not want MAKEFLAGS to be readonly.
3112 3069 * If the MAKEFLAGS macro is subsequently set by the makefile,
3113 3070 * it replaces the MAKEFLAGS variable currently found in the
3114 3071 * environment.
3115 3072 * See Assertion 50 in section 6.2.5.3 of standard P1003.3.2/D8.
3116 3073 */
3117 3074 if(posix) {
3118 3075 read_only_saved = false;
3119 3076 }
3120 3077 }
3121 3078
3122 3079 /*
3123 3080 * We ignore SUNPRO_DEPENDENCIES and NSE_DEP. Those
3124 3081 * environment variables are set by make and read by
3125 3082 * cpp which then writes info to .make.dependency.xxx and
3126 3083 * .nse_depinfo. When make is invoked by another make
3127 3084 * (recursive make), we don't want to read this because
3128 3085 * then the child make will end up writing to the parent
3129 3086 * directory's .make.state and .nse_depinfo and clobbering
3130 3087 * them.
3131 3088 */
3132 3089 MBSTOWCS(wcs_buffer2, NOCATGETS("SUNPRO_DEPENDENCIES"));
3133 3090 if (IS_WEQUALN(name, wcs_buffer2, wslen(wcs_buffer2))) {
3134 3091 continue;
3135 3092 }
3136 3093 #ifdef NSE
3137 3094 MBSTOWCS(wcs_buffer2, NOCATGETS("NSE_DEP"));
3138 3095 if (IS_WEQUALN(name, wcs_buffer2, wslen(wcs_buffer2))) {
3139 3096 continue;
3140 3097 }
3141 3098 #endif
3142 3099
3143 3100 macro = GETNAME(name, value - name);
3144 3101 maybe_append_prop(macro, macro_prop)->body.macro.exported =
3145 3102 true;
3146 3103 if ((value == NULL) || ((value + 1)[0] == (int) nul_char)) {
3147 3104 val = setvar_daemon(macro,
3148 3105 (Name) NULL,
3149 3106 false, no_daemon, false, debug_level);
3150 3107 } else {
3151 3108 val = setvar_daemon(macro,
3152 3109 GETNAME(value + 1, FIND_LENGTH),
3153 3110 false, no_daemon, false, debug_level);
3154 3111 }
3155 3112 #ifdef NSE
3156 3113 /*
3157 3114 * Must be after the call to setvar() as it sets
3158 3115 * imported to false.
3159 3116 */
3160 3117 maybe_append_prop(macro, macro_prop)->body.macro.imported = true;
3161 3118 #endif
3162 3119 val->body.macro.read_only = read_only_saved;
3163 3120 if (alloced_tmp_wcs_buffer) {
3164 3121 retmem(tmp_wcs_buffer);
3165 3122 alloced_tmp_wcs_buffer = false;
3166 3123 }
3167 3124 }
3168 3125 reading_environment = false;
3169 3126 }
3170 3127
3171 3128 /*
3172 3129 * read_makefile(makefile, complain, must_exist, report_file)
3173 3130 *
3174 3131 * Read one makefile and check the result
3175 3132 *
3176 3133 * Return value:
3177 3134 * false is the read failed
3178 3135 *
3179 3136 * Parameters:
3180 3137 * makefile The file to read
3181 3138 * complain Passed thru to read_simple_file()
3182 3139 * must_exist Passed thru to read_simple_file()
3183 3140 * report_file Passed thru to read_simple_file()
3184 3141 *
3185 3142 * Global variables used:
3186 3143 * makefile_type Set to indicate we are reading main file
3187 3144 * recursion_level Initialized
3188 3145 */
3189 3146 static Boolean
3190 3147 read_makefile(register Name makefile, Boolean complain, Boolean must_exist, Boolean report_file)
3191 3148 {
3192 3149 Boolean b;
3193 3150
3194 3151 makefile_type = reading_makefile;
3195 3152 recursion_level = 0;
3196 3153 #ifdef NSE
3197 3154 wscpy(current_makefile, makefile->string);
3198 3155 #endif
3199 3156 reading_dependencies = true;
3200 3157 b = read_simple_file(makefile, true, true, complain,
3201 3158 must_exist, report_file, false);
3202 3159 reading_dependencies = false;
3203 3160 return b;
3204 3161 }
3205 3162
3206 3163 /*
3207 3164 * make_targets(argc, argv, parallel_flag)
3208 3165 *
3209 3166 * Call doname on the specified targets
3210 3167 *
3211 3168 * Parameters:
3212 3169 * argc You know what this is
3213 3170 * argv You know what this is
3214 3171 * parallel_flag True if building in parallel
3215 3172 *
3216 3173 * Global variables used:
3217 3174 * build_failed_seen Used to generated message after failed -k
3218 3175 * commands_done Used to generate message "Up to date"
3219 3176 * default_target_to_build First proper target in makefile
3220 3177 * init The Name ".INIT", use to run command
3221 3178 * parallel Global parallel building flag
3222 3179 * quest make -q, suppresses messages
3223 3180 * recursion_level Initialized, used for tracing
3224 3181 * report_dependencies make -P, regroves whole process
3225 3182 */
3226 3183 static void
3227 3184 make_targets(int argc, char **argv, Boolean parallel_flag)
3228 3185 {
3229 3186 int i;
3230 3187 char *cp;
3231 3188 Doname result;
3232 3189 register Boolean target_to_make_found = false;
3233 3190
3234 3191 (void) doname(init, true, true);
3235 3192 recursion_level = 1;
3236 3193 parallel = parallel_flag;
3237 3194 /*
3238 3195 * make remaining args
3239 3196 */
3240 3197 #ifdef TEAMWARE_MAKE_CMN
3241 3198 /*
3242 3199 if ((report_dependencies_level == 0) && parallel) {
3243 3200 */
3244 3201 if (parallel) {
3245 3202 /*
3246 3203 * If building targets in parallel, start all of the
3247 3204 * remaining args to build in parallel.
3248 3205 */
3249 3206 for (i = 1; i < argc; i++) {
3250 3207 if ((cp = argv[i]) != NULL) {
3251 3208 commands_done = false;
3252 3209 if ((cp[0] == (int) period_char) &&
3253 3210 (cp[1] == (int) slash_char)) {
3254 3211 cp += 2;
3255 3212 }
3256 3213 if((cp[0] == (int) ' ') &&
3257 3214 (cp[1] == (int) '-') &&
3258 3215 (cp[2] == (int) ' ') &&
3259 3216 (cp[3] == (int) '-')) {
3260 3217 argv[i] = NULL;
3261 3218 continue;
3262 3219 }
3263 3220 MBSTOWCS(wcs_buffer, cp);
3264 3221 //default_target_to_build = GETNAME(wcs_buffer,
3265 3222 // FIND_LENGTH);
3266 3223 default_target_to_build = normalize_name(wcs_buffer,
3267 3224 wslen(wcs_buffer));
3268 3225 if (default_target_to_build == wait_name) {
3269 3226 if (parallel_process_cnt > 0) {
3270 3227 finish_running();
3271 3228 }
3272 3229 continue;
3273 3230 }
3274 3231 top_level_target = get_wstring(default_target_to_build->string_mb);
3275 3232 /*
3276 3233 * If we can't execute the current target in
3277 3234 * parallel, hold off the target processing
3278 3235 * to preserve the order of the targets as they appeared
3279 3236 * in command line.
3280 3237 */
3281 3238 if (!parallel_ok(default_target_to_build, false)
3282 3239 && parallel_process_cnt > 0) {
3283 3240 finish_running();
3284 3241 }
3285 3242 result = doname_check(default_target_to_build,
3286 3243 true,
3287 3244 false,
3288 3245 false);
3289 3246 gather_recursive_deps();
3290 3247 if (/* !commands_done && */
3291 3248 (result == build_ok) &&
3292 3249 !quest &&
3293 3250 (report_dependencies_level == 0) /* &&
3294 3251 (exists(default_target_to_build) > file_doesnt_exist) */) {
3295 3252 if (posix) {
3296 3253 if (!commands_done) {
3297 3254 (void) printf(catgets(catd, 1, 293, "`%s' is updated.\n"),
3298 3255 default_target_to_build->string_mb);
3299 3256 } else {
3300 3257 if (no_action_was_taken) {
3301 3258 (void) printf(catgets(catd, 1, 294, "`%s': no action was taken.\n"),
3302 3259 default_target_to_build->string_mb);
3303 3260 }
3304 3261 }
3305 3262 } else {
3306 3263 default_target_to_build->stat.time = file_no_time;
3307 3264 if (!commands_done &&
3308 3265 (exists(default_target_to_build) > file_doesnt_exist)) {
3309 3266 (void) printf(catgets(catd, 1, 295, "`%s' is up to date.\n"),
3310 3267 default_target_to_build->string_mb);
3311 3268 }
3312 3269 }
3313 3270 }
3314 3271 }
3315 3272 }
3316 3273 /* Now wait for all of the targets to finish running */
3317 3274 finish_running();
3318 3275 // setjmp(jmpbuffer);
3319 3276
3320 3277 }
3321 3278 #endif
3322 3279 for (i = 1; i < argc; i++) {
3323 3280 if ((cp = argv[i]) != NULL) {
3324 3281 target_to_make_found = true;
3325 3282 if ((cp[0] == (int) period_char) &&
3326 3283 (cp[1] == (int) slash_char)) {
3327 3284 cp += 2;
3328 3285 }
3329 3286 if((cp[0] == (int) ' ') &&
3330 3287 (cp[1] == (int) '-') &&
3331 3288 (cp[2] == (int) ' ') &&
3332 3289 (cp[3] == (int) '-')) {
3333 3290 argv[i] = NULL;
3334 3291 continue;
3335 3292 }
3336 3293 MBSTOWCS(wcs_buffer, cp);
3337 3294 default_target_to_build = normalize_name(wcs_buffer, wslen(wcs_buffer));
3338 3295 top_level_target = get_wstring(default_target_to_build->string_mb);
3339 3296 report_recursion(default_target_to_build);
3340 3297 commands_done = false;
3341 3298 if (parallel) {
3342 3299 result = (Doname) default_target_to_build->state;
3343 3300 } else {
3344 3301 result = doname_check(default_target_to_build,
3345 3302 true,
3346 3303 false,
3347 3304 false);
3348 3305 }
3349 3306 gather_recursive_deps();
3350 3307 if (build_failed_seen) {
3351 3308 build_failed_ever_seen = true;
3352 3309 warning(catgets(catd, 1, 200, "Target `%s' not remade because of errors"),
3353 3310 default_target_to_build->string_mb);
3354 3311 }
3355 3312 build_failed_seen = false;
3356 3313 if (report_dependencies_level > 0) {
3357 3314 print_dependencies(default_target_to_build,
3358 3315 get_prop(default_target_to_build->prop,
3359 3316 line_prop));
3360 3317 }
3361 3318 default_target_to_build->stat.time =
3362 3319 file_no_time;
3363 3320 if (default_target_to_build->colon_splits > 0) {
3364 3321 default_target_to_build->state =
3365 3322 build_dont_know;
3366 3323 }
3367 3324 if (!parallel &&
3368 3325 /* !commands_done && */
3369 3326 (result == build_ok) &&
3370 3327 !quest &&
3371 3328 (report_dependencies_level == 0) /* &&
3372 3329 (exists(default_target_to_build) > file_doesnt_exist) */) {
3373 3330 if (posix) {
3374 3331 if (!commands_done) {
3375 3332 (void) printf(catgets(catd, 1, 296, "`%s' is updated.\n"),
3376 3333 default_target_to_build->string_mb);
3377 3334 } else {
3378 3335 if (no_action_was_taken) {
3379 3336 (void) printf(catgets(catd, 1, 297, "`%s': no action was taken.\n"),
3380 3337 default_target_to_build->string_mb);
3381 3338 }
3382 3339 }
3383 3340 } else {
3384 3341 if (!commands_done &&
3385 3342 (exists(default_target_to_build) > file_doesnt_exist)) {
3386 3343 (void) printf(catgets(catd, 1, 298, "`%s' is up to date.\n"),
3387 3344 default_target_to_build->string_mb);
3388 3345 }
3389 3346 }
3390 3347 }
3391 3348 }
3392 3349 }
3393 3350
3394 3351 /*
3395 3352 * If no file arguments have been encountered,
3396 3353 * make the first name encountered that doesnt start with a dot
3397 3354 */
3398 3355 if (!target_to_make_found) {
3399 3356 if (default_target_to_build == NULL) {
3400 3357 fatal(catgets(catd, 1, 202, "No arguments to build"));
3401 3358 }
3402 3359 commands_done = false;
3403 3360 top_level_target = get_wstring(default_target_to_build->string_mb);
3404 3361 report_recursion(default_target_to_build);
3405 3362
3406 3363
3407 3364 if (getenv(NOCATGETS("SPRO_EXPAND_ERRORS"))){
3408 3365 (void) printf(NOCATGETS("::(%s)\n"),
3409 3366 default_target_to_build->string_mb);
3410 3367 }
3411 3368
3412 3369
3413 3370 #ifdef TEAMWARE_MAKE_CMN
3414 3371 result = doname_parallel(default_target_to_build, true, false);
3415 3372 #else
3416 3373 result = doname_check(default_target_to_build, true,
3417 3374 false, false);
3418 3375 #endif
3419 3376 gather_recursive_deps();
3420 3377 if (build_failed_seen) {
3421 3378 build_failed_ever_seen = true;
3422 3379 warning(catgets(catd, 1, 203, "Target `%s' not remade because of errors"),
3423 3380 default_target_to_build->string_mb);
3424 3381 }
3425 3382 build_failed_seen = false;
3426 3383 if (report_dependencies_level > 0) {
3427 3384 print_dependencies(default_target_to_build,
3428 3385 get_prop(default_target_to_build->
3429 3386 prop,
3430 3387 line_prop));
3431 3388 }
3432 3389 default_target_to_build->stat.time = file_no_time;
3433 3390 if (default_target_to_build->colon_splits > 0) {
3434 3391 default_target_to_build->state = build_dont_know;
3435 3392 }
3436 3393 if (/* !commands_done && */
3437 3394 (result == build_ok) &&
3438 3395 !quest &&
3439 3396 (report_dependencies_level == 0) /* &&
3440 3397 (exists(default_target_to_build) > file_doesnt_exist) */) {
3441 3398 if (posix) {
3442 3399 if (!commands_done) {
3443 3400 (void) printf(catgets(catd, 1, 299, "`%s' is updated.\n"),
3444 3401 default_target_to_build->string_mb);
3445 3402 } else {
3446 3403 if (no_action_was_taken) {
3447 3404 (void) printf(catgets(catd, 1, 300, "`%s': no action was taken.\n"),
3448 3405 default_target_to_build->string_mb);
3449 3406 }
3450 3407 }
3451 3408 } else {
3452 3409 if (!commands_done &&
3453 3410 (exists(default_target_to_build) > file_doesnt_exist)) {
3454 3411 (void) printf(catgets(catd, 1, 301, "`%s' is up to date.\n"),
3455 3412 default_target_to_build->string_mb);
3456 3413 }
3457 3414 }
3458 3415 }
3459 3416 }
3460 3417 }
3461 3418
3462 3419 /*
3463 3420 * report_recursion(target)
3464 3421 *
3465 3422 * If this is a recursive make and the parent make has KEEP_STATE on
3466 3423 * this routine reports the dependency to the parent make
3467 3424 *
3468 3425 * Parameters:
3469 3426 * target Target to report
3470 3427 *
3471 3428 * Global variables used:
3472 3429 * makefiles_used List of makefiles read
3473 3430 * recursive_name The Name ".RECURSIVE", printed
3474 3431 * report_dependency dwight
3475 3432 */
3476 3433 static void
3477 3434 report_recursion(register Name target)
3478 3435 {
3479 3436 register FILE *report_file = get_report_file();
3480 3437
3481 3438 if ((report_file == NULL) || (report_file == (FILE*)-1)) {
3482 3439 return;
3483 3440 }
3484 3441 if (primary_makefile == NULL) {
3485 3442 /*
3486 3443 * This can happen when there is no makefile and
3487 3444 * only implicit rules are being used.
3488 3445 */
3489 3446 #ifdef NSE
3490 3447 nse_no_makefile(target);
3491 3448 #endif
3492 3449 return;
3493 3450 }
3494 3451 (void) fprintf(report_file,
3495 3452 "%s: %s ",
3496 3453 get_target_being_reported_for(),
3497 3454 recursive_name->string_mb);
3498 3455 report_dependency(get_current_path());
3499 3456 report_dependency(target->string_mb);
3500 3457 report_dependency(primary_makefile->string_mb);
3501 3458 (void) fprintf(report_file, "\n");
3502 3459 }
3503 3460
3504 3461 /* Next function "append_or_replace_macro_in_dyn_array" must be in "misc.cc". */
3505 3462 /* NIKMOL */
3506 3463 extern void
3507 3464 append_or_replace_macro_in_dyn_array(ASCII_Dyn_Array *Ar, char *macro)
3508 3465 {
3509 3466 register char *cp0; /* work pointer in macro */
3510 3467 register char *cp1; /* work pointer in array */
3511 3468 register char *cp2; /* work pointer in array */
3512 3469 register char *cp3; /* work pointer in array */
3513 3470 register char *name; /* macro name */
3514 3471 register char *value; /* macro value */
3515 3472 register int len_array;
3516 3473 register int len_macro;
3517 3474
3518 3475 char * esc_value = NULL;
3519 3476 int esc_len;
3520 3477
3521 3478 if (!(len_macro = strlen(macro))) return;
3522 3479 name = macro;
3523 3480 while (isspace(*(name))) {
3524 3481 name++;
3525 3482 }
3526 3483 if (!(value = strchr(name, (int) equal_char))) {
3527 3484 /* no '=' in macro */
3528 3485 goto ERROR_MACRO;
3529 3486 }
3530 3487 cp0 = value;
3531 3488 value++;
3532 3489 while (isspace(*(value))) {
3533 3490 value++;
3534 3491 }
3535 3492 while (isspace(*(cp0-1))) {
3536 3493 cp0--;
3537 3494 }
3538 3495 if (cp0 <= name) goto ERROR_MACRO; /* no name */
3539 3496 if (!(Ar->size)) goto ALLOC_ARRAY;
3540 3497 cp1 = Ar->start;
3541 3498
3542 3499 LOOK_FOR_NAME:
3543 3500 if (!(cp1 = strchr(cp1, name[0]))) goto APPEND_MACRO;
3544 3501 if (!(cp2 = strchr(cp1, (int) equal_char))) goto APPEND_MACRO;
3545 3502 if (strncmp(cp1, name, (size_t)(cp0-name))) {
3546 3503 /* another name */
3547 3504 cp1++;
3548 3505 goto LOOK_FOR_NAME;
3549 3506 }
3550 3507 if (cp1 != Ar->start) {
3551 3508 if (!isspace(*(cp1-1))) {
3552 3509 /* another name */
3553 3510 cp1++;
3554 3511 goto LOOK_FOR_NAME;
3555 3512 }
3556 3513 }
3557 3514 for (cp3 = cp1 + (cp0-name); cp3 < cp2; cp3++) {
3558 3515 if (isspace(*cp3)) continue;
3559 3516 /* else: another name */
3560 3517 cp1++;
3561 3518 goto LOOK_FOR_NAME;
3562 3519 }
3563 3520 /* Look for the next macro name in array */
3564 3521 cp3 = cp2+1;
3565 3522 if (*cp3 != (int) doublequote_char) {
3566 3523 /* internal error */
3567 3524 goto ERROR_MACRO;
3568 3525 }
3569 3526 if (!(cp3 = strchr(cp3+1, (int) doublequote_char))) {
3570 3527 /* internal error */
3571 3528 goto ERROR_MACRO;
3572 3529 }
3573 3530 cp3++;
3574 3531 while (isspace(*cp3)) {
3575 3532 cp3++;
3576 3533 }
3577 3534
3578 3535 cp2 = cp1; /* remove old macro */
3579 3536 if ((*cp3) && (cp3 < Ar->start + Ar->size)) {
3580 3537 for (; cp3 < Ar->start + Ar->size; cp3++) {
3581 3538 *cp2++ = *cp3;
3582 3539 }
3583 3540 }
3584 3541 for (; cp2 < Ar->start + Ar->size; cp2++) {
3585 3542 *cp2 = 0;
3586 3543 }
3587 3544 if (*cp1) {
3588 3545 /* check next name */
3589 3546 goto LOOK_FOR_NAME;
3590 3547 }
3591 3548 goto APPEND_MACRO;
3592 3549
3593 3550 ALLOC_ARRAY:
3594 3551 if (Ar->size) {
3595 3552 cp1 = Ar->start;
3596 3553 } else {
3597 3554 cp1 = 0;
3598 3555 }
3599 3556 Ar->size += 128;
3600 3557 Ar->start = getmem(Ar->size);
3601 3558 for (len_array=0; len_array < Ar->size; len_array++) {
3602 3559 Ar->start[len_array] = 0;
3603 3560 }
3604 3561 if (cp1) {
3605 3562 strcpy(Ar->start, cp1);
3606 3563 retmem((wchar_t *) cp1);
3607 3564 }
3608 3565
3609 3566 APPEND_MACRO:
3610 3567 len_array = strlen(Ar->start);
3611 3568 esc_value = (char*)malloc(strlen(value)*2 + 1);
3612 3569 quote_str(value, esc_value);
3613 3570 esc_len = strlen(esc_value) - strlen(value);
3614 3571 if (len_array + len_macro + esc_len + 5 >= Ar->size) goto ALLOC_ARRAY;
3615 3572 strcat(Ar->start, " ");
3616 3573 strncat(Ar->start, name, cp0-name);
3617 3574 strcat(Ar->start, "=");
3618 3575 strncat(Ar->start, esc_value, strlen(esc_value));
3619 3576 free(esc_value);
3620 3577 return;
3621 3578 ERROR_MACRO:
3622 3579 /* Macro without '=' or with invalid left/right part */
3623 3580 return;
3624 3581 }
3625 3582
3626 3583 #ifdef TEAMWARE_MAKE_CMN
3627 3584 /*
3628 3585 * This function, if registered w/ avo_cli_get_license(), will be called
3629 3586 * if the application is about to exit because:
3630 3587 * 1) there has been certain unrecoverable error(s) that cause the
3631 3588 * application to exit immediately.
3632 3589 * 2) the user has lost a license while the application is running.
3633 3590 */
3634 3591 extern "C" void
3635 3592 dmake_exit_callback(void)
3636 3593 {
3637 3594 fatal(catgets(catd, 1, 306, "can not get a license, exiting..."));
3638 3595 exit(1);
3639 3596 }
3640 3597
3641 3598 /*
3642 3599 * This function, if registered w/ avo_cli_get_license(), will be called
3643 3600 * if the application can not get a license.
3644 3601 */
3645 3602 extern "C" void
3646 3603 dmake_message_callback(char *err_msg)
3647 3604 {
3648 3605 static Boolean first = true;
3649 3606
3650 3607 if (!first) {
3651 3608 return;
3652 3609 }
3653 3610 first = false;
3654 3611 if ((!list_all_targets) &&
3655 3612 (report_dependencies_level == 0) &&
3656 3613 (dmake_mode_type != serial_mode)) {
3657 3614 warning(catgets(catd, 1, 313, "can not get a TeamWare license, defaulting to serial mode..."));
3658 3615 }
3659 3616 }
3660 3617 #endif
3661 3618
3662 3619 #ifdef DISTRIBUTED
3663 3620 /*
3664 3621 * Returns whether -c is set or not.
3665 3622 */
3666 3623 Boolean
3667 3624 get_dmake_rcfile_specified(void)
3668 3625 {
3669 3626 return(dmake_rcfile_specified);
3670 3627 }
3671 3628
3672 3629 /*
3673 3630 * Returns whether -g is set or not.
3674 3631 */
3675 3632 Boolean
3676 3633 get_dmake_group_specified(void)
3677 3634 {
3678 3635 return(dmake_group_specified);
3679 3636 }
3680 3637
3681 3638 /*
3682 3639 * Returns whether -j is set or not.
3683 3640 */
3684 3641 Boolean
3685 3642 get_dmake_max_jobs_specified(void)
3686 3643 {
3687 3644 return(dmake_max_jobs_specified);
3688 3645 }
3689 3646
3690 3647 /*
3691 3648 * Returns whether -m is set or not.
3692 3649 */
3693 3650 Boolean
3694 3651 get_dmake_mode_specified(void)
3695 3652 {
3696 3653 return(dmake_mode_specified);
3697 3654 }
3698 3655
3699 3656 /*
3700 3657 * Returns whether -o is set or not.
3701 3658 */
3702 3659 Boolean
3703 3660 get_dmake_odir_specified(void)
3704 3661 {
3705 3662 return(dmake_odir_specified);
3706 3663 }
3707 3664
3708 3665 #endif
3709 3666
3710 3667 static void
3711 3668 report_dir_enter_leave(Boolean entering)
3712 3669 {
3713 3670 char rcwd[MAXPATHLEN];
3714 3671 static char * mlev = NULL;
3715 3672 char * make_level_str = NULL;
3716 3673 int make_level_val = 0;
3717 3674
3718 3675 make_level_str = getenv(NOCATGETS("MAKELEVEL"));
3719 3676 if(make_level_str) {
3720 3677 make_level_val = atoi(make_level_str);
3721 3678 }
3722 3679 if(mlev == NULL) {
3723 3680 mlev = (char*) malloc(MAXPATHLEN);
3724 3681 }
3725 3682 if(entering) {
3726 3683 sprintf(mlev, NOCATGETS("MAKELEVEL=%d"), make_level_val + 1);
3727 3684 } else {
3728 3685 make_level_val--;
3729 3686 sprintf(mlev, NOCATGETS("MAKELEVEL=%d"), make_level_val);
3730 3687 }
3731 3688 putenv(mlev);
3732 3689
3733 3690 if(report_cwd) {
3734 3691 if(make_level_val <= 0) {
3735 3692 if(entering) {
3736 3693 #ifdef TEAMWARE_MAKE_CMN
3737 3694 sprintf( rcwd
3738 3695 , catgets(catd, 1, 329, "dmake: Entering directory `%s'\n")
3739 3696 , get_current_path());
3740 3697 #else
3741 3698 sprintf( rcwd
3742 3699 , catgets(catd, 1, 330, "make: Entering directory `%s'\n")
3743 3700 , get_current_path());
3744 3701 #endif
3745 3702 } else {
3746 3703 #ifdef TEAMWARE_MAKE_CMN
3747 3704 sprintf( rcwd
3748 3705 , catgets(catd, 1, 331, "dmake: Leaving directory `%s'\n")
3749 3706 , get_current_path());
3750 3707 #else
3751 3708 sprintf( rcwd
3752 3709 , catgets(catd, 1, 332, "make: Leaving directory `%s'\n")
3753 3710 , get_current_path());
3754 3711 #endif
3755 3712 }
3756 3713 } else {
3757 3714 if(entering) {
3758 3715 #ifdef TEAMWARE_MAKE_CMN
3759 3716 sprintf( rcwd
3760 3717 , catgets(catd, 1, 333, "dmake[%d]: Entering directory `%s'\n")
3761 3718 , make_level_val, get_current_path());
3762 3719 #else
3763 3720 sprintf( rcwd
3764 3721 , catgets(catd, 1, 334, "make[%d]: Entering directory `%s'\n")
3765 3722 , make_level_val, get_current_path());
3766 3723 #endif
3767 3724 } else {
3768 3725 #ifdef TEAMWARE_MAKE_CMN
3769 3726 sprintf( rcwd
3770 3727 , catgets(catd, 1, 335, "dmake[%d]: Leaving directory `%s'\n")
3771 3728 , make_level_val, get_current_path());
3772 3729 #else
3773 3730 sprintf( rcwd
3774 3731 , catgets(catd, 1, 336, "make[%d]: Leaving directory `%s'\n")
3775 3732 , make_level_val, get_current_path());
3776 3733 #endif
3777 3734 }
3778 3735 }
3779 3736 printf(NOCATGETS("%s"), rcwd);
3780 3737 }
3781 3738 }
↓ open down ↓ |
1539 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX