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