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