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