Print this page
make: unifdef for SUNOS4_AND_AFTER (defined)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/bin/nse_printdep.cc
+++ new/usr/src/cmd/make/bin/nse_printdep.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 2003 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 /*
27 27 * Included files
28 28 */
29 29 #include <mk/defs.h>
30 30 #include <mksh/misc.h> /* get_prop() */
31 31
32 32 /*
33 33 * File table of contents
34 34 */
35 35 void print_dependencies(register Name target, register Property line);
36 36 static void print_deps(register Name target, register Property line);
37 37 static void print_more_deps(Name target, Name name);
38 38 static void print_filename(Name name);
39 39 static Boolean should_print_dep(Property line);
40 40 static void print_forest(Name target);
41 41 static void print_deplist(Dependency head);
42 42 void print_value(register Name value, Daemon daemon);
43 43 static void print_rule(register Name target);
44 44 static void print_rec_info(Name target);
45 45 static Boolean is_out_of_date(Property line);
46 46 extern void depvar_print_results (void);
47 47 extern int printf (const char *, ...);
48 48 extern int _flsbuf (unsigned int, FILE *);
49 49
50 50 /*
51 51 * print_dependencies(target, line)
52 52 *
53 53 * Print all the dependencies of a target. First print all the Makefiles.
54 54 * Then print all the dependencies. Finally, print all the .INIT
55 55 * dependencies.
56 56 *
57 57 * Parameters:
58 58 * target The target we print dependencies for
59 59 * line We get the dependency list from here
60 60 *
61 61 * Global variables used:
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
62 62 * done The Name ".DONE"
63 63 * init The Name ".INIT"
64 64 * makefiles_used List of all makefiles read
65 65 */
66 66 void
67 67 print_dependencies(register Name target, register Property line)
68 68 {
69 69 Dependency dp;
70 70 static Boolean makefiles_printed = false;
71 71
72 -#ifdef SUNOS4_AND_AFTER
73 72 if (target_variants) {
74 -#else
75 - if (is_true(flag.target_variants)) {
76 -#endif
77 73 depvar_print_results();
78 74 }
79 75
80 76 if (!makefiles_printed) {
81 77 /*
82 78 * Search the makefile list for the primary makefile,
83 79 * then print it and its inclusions. After that go back
84 80 * and print the default.mk file and its inclusions.
85 81 */
86 82 for (dp = makefiles_used; dp != NULL; dp = dp->next) {
87 83 if (dp->name == primary_makefile) {
88 84 break;
89 85 }
90 86 }
91 87 if (dp) {
92 88 print_deplist(dp);
93 89 for (dp = makefiles_used; dp != NULL; dp = dp->next) {
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
94 90 if (dp->name == primary_makefile) {
95 91 break;
96 92 }
97 93 (void)printf(" %s", dp->name->string_mb);
98 94 }
99 95 }
100 96 (void) printf("\n");
101 97 makefiles_printed = true;
102 98 }
103 99 print_deps(target, line);
104 -#ifdef SUNOS4_AND_AFTER
105 100 /*
106 101 print_more_deps(target, init);
107 102 print_more_deps(target, done);
108 103 */
109 104 if (target_variants) {
110 -#else
111 - print_more_deps(target, cached_names.init);
112 - print_more_deps(target, cached_names.done);
113 - if (is_true(flag.target_variants)) {
114 -#endif
115 105 print_forest(target);
116 106 }
117 107 }
118 108
119 109 /*
120 110 * print_more_deps(target, name)
121 111 *
122 112 * Print some special dependencies.
123 113 * These are the dependencies for the .INIT and .DONE targets.
124 114 *
125 115 * Parameters:
126 116 * target Target built during make run
127 117 * name Special target to print dependencies for
128 118 *
129 119 * Global variables used:
130 120 */
131 121 static void
132 122 print_more_deps(Name target, Name name)
133 123 {
134 124 Property line;
135 125 register Dependency dependencies;
136 126
137 127 line = get_prop(name->prop, line_prop);
138 128 if (line != NULL && line->body.line.dependencies != NULL) {
139 129 (void) printf("%s:\t", target->string_mb);
140 130 print_deplist(line->body.line.dependencies);
141 131 (void) printf("\n");
142 132 for (dependencies= line->body.line.dependencies;
143 133 dependencies != NULL;
144 134 dependencies= dependencies->next) {
145 135 print_deps(dependencies->name,
146 136 get_prop(dependencies->name->prop, line_prop));
147 137 }
148 138 }
149 139 }
150 140
151 141 /*
152 142 * print_deps(target, line, go_recursive)
153 143 *
154 144 * Print a regular dependency list. Append to this information which
155 145 * indicates whether or not the target is recursive.
156 146 *
157 147 * Parameters:
158 148 * target target to print dependencies for
159 149 * line We get the dependency list from here
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
160 150 * go_recursive Should we show all dependencies recursively?
161 151 *
162 152 * Global variables used:
163 153 * recursive_name The Name ".RECURSIVE", printed
164 154 */
165 155 static void
166 156 print_deps(register Name target, register Property line)
167 157 {
168 158 register Dependency dep;
169 159
170 -#ifdef SUNOS4_AND_AFTER
171 160 if ((target->dependency_printed) ||
172 161 (target == force)) {
173 -#else
174 - if (is_true(target->dependency_printed)) {
175 -#endif
176 162 return;
177 163 }
178 164 target->dependency_printed = true;
179 165
180 166 /* only print entries that are actually derived and are not leaf
181 167 * files and are not the result of sccs get.
182 168 */
183 169 if (should_print_dep(line)) {
184 170 #ifdef NSE
185 171 nse_check_no_deps_no_rule(target, line, line);
186 172 #endif
187 173 if ((report_dependencies_level == 2) ||
188 174 (report_dependencies_level == 4)) {
189 175 if (is_out_of_date(line)) {
190 176 (void) printf("1 ");
191 177 } else {
192 178 (void) printf("0 ");
193 179 }
194 180 }
195 181 print_filename(target);
196 182 (void) printf(":\t");
197 183 print_deplist(line->body.line.dependencies);
198 184 print_rec_info(target);
199 185 (void) printf("\n");
200 186 for (dep = line->body.line.dependencies;
201 187 dep != NULL;
202 188 dep = dep->next) {
203 189 print_deps(dep->name,
204 190 get_prop(dep->name->prop, line_prop));
205 191 }
206 192 }
207 193 }
208 194
209 195 static Boolean
210 196 is_out_of_date(Property line)
211 197 {
212 198 Dependency dep;
213 199 Property line2;
214 200
215 201 if (line == NULL) {
216 202 return false;
217 203 }
218 204 if (line->body.line.is_out_of_date) {
219 205 return true;
220 206 }
221 207 for (dep = line->body.line.dependencies;
222 208 dep != NULL;
223 209 dep = dep->next) {
224 210 line2 = get_prop(dep->name->prop, line_prop);
225 211 if (is_out_of_date(line2)) {
226 212 line->body.line.is_out_of_date = true;
227 213 return true;
228 214 }
229 215 }
230 216 return false;
231 217 }
232 218
233 219 /*
234 220 * Given a dependency print it and all its siblings.
235 221 */
236 222 static void
237 223 print_deplist(Dependency head)
238 224 {
239 225 Dependency dp;
240 226
241 227 for (dp = head; dp != NULL; dp = dp->next) {
242 228 if ((report_dependencies_level != 2) ||
243 229 ((!dp->automatic) ||
244 230 (dp->name->is_double_colon))) {
245 231 if (dp->name != force) {
246 232 putwchar(' ');
247 233 print_filename(dp->name);
248 234 }
249 235 }
250 236 }
251 237 }
252 238
253 239 /*
254 240 * Print the name of a file for the -P option.
255 241 * If the file is a directory put on a trailing slash.
256 242 */
257 243 static void
258 244 print_filename(Name name)
259 245 {
260 246 (void) printf("%s", name->string_mb);
261 247 /*
262 248 if (name->stat.is_dir) {
263 249 putwchar('/');
264 250 }
265 251 */
266 252 }
267 253
268 254 /*
269 255 * should_print_dep(line)
270 256 *
271 257 * Test if we should print the dependencies of this target.
272 258 * The line must exist and either have children dependencies
273 259 * or have a command that is not an SCCS command.
274 260 *
275 261 * Return value:
276 262 * true if the dependencies should be printed
277 263 *
278 264 * Parameters:
279 265 * line We get the dependency list from here
280 266 *
281 267 * Global variables used:
↓ open down ↓ |
96 lines elided |
↑ open up ↑ |
282 268 */
283 269 static Boolean
284 270 should_print_dep(Property line)
285 271 {
286 272 if (line == NULL) {
287 273 return false;
288 274 }
289 275 if (line->body.line.dependencies != NULL) {
290 276 return true;
291 277 }
292 -#ifdef SUNOS4_AND_AFTER
293 278 if (line->body.line.sccs_command) {
294 -#else
295 - if (is_true(line->body.line.sccs_command)) {
296 -#endif
297 279 return false;
298 280 }
299 281 return true;
300 282 }
301 283
302 284 /*
303 285 * Print out the root nodes of all the dependency trees
304 286 * in this makefile.
305 287 */
306 288 static void
307 289 print_forest(Name target)
308 290 {
309 291 Name_set::iterator np, e;
310 292 Property line;
311 293
312 294 for (np = hashtab.begin(), e = hashtab.end(); np != e; np++) {
313 -#ifdef SUNOS4_AND_AFTER
314 295 if (np->is_target && !np->has_parent && np != target) {
315 -#else
316 - if (is_true(np->is_target) &&
317 - is_false(np->has_parent) &&
318 - np != target) {
319 -#endif
320 296 (void) doname_check(np, true, false, false);
321 297 line = get_prop(np->prop, line_prop);
322 298 printf("-\n");
323 299 print_deps(np, line);
324 300 }
325 301 }
326 302 }
327 303
328 -#ifndef SUNOS4_AND_AFTER
329 -printdesc()
330 -{
331 - Name_set::iterator p, e;
332 - register Property prop;
333 - register Dependency dep;
334 - register Cmd_line rule;
335 - Percent percent, percent_depe;
336 -
337 - /* Default target */
338 - if (default_target_to_build != NULL) {
339 - print_rule(default_target_to_build);
340 - default_target_to_build->dependency_printed= true;
341 - };
342 - (void)printf("\n");
343 -
344 - /* .AR_REPLACE */
345 - if (ar_replace_rule != NULL) {
346 - (void)printf("%s:\n", cached_names.ar_replace->string_mb);
347 - for (rule= ar_replace_rule; rule != NULL; rule= rule->next)
348 - (void)printf("\t%s\n", rule->command_line->string_mb);
349 - };
350 -
351 - /* .DEFAULT */
352 - if (default_rule != NULL) {
353 - (void)printf("%s:\n", cached_names.default_rule->string_mb);
354 - for (rule= default_rule; rule != NULL; rule= rule->next)
355 - (void)printf("\t%s\n", rule->command_line->string_mb);
356 - };
357 -
358 - /* .IGNORE */
359 - if (is_true(flag.ignore_errors))
360 - (void)printf("%s:\n", cached_names.ignore->string_mb);
361 -
362 - /* .KEEP_STATE: */
363 - if (is_true(flag.keep_state))
364 - (void)printf("%s:\n\n", cached_names.dot_keep_state->string_mb);
365 -
366 - /* .PRECIOUS */
367 - (void)printf("%s: ", cached_names.precious->string_mb);
368 - for (p = hashtab.begin(), e = hashtab.end(); p != e; p++)
369 - if (is_true(p->stat.is_precious | all_precious))
370 - (void)printf("%s ", p->string_mb);
371 - (void)printf("\n");
372 -
373 - /* .SCCS_GET */
374 - if (sccs_get_rule != NULL) {
375 - (void)printf("%s:\n", cached_names.sccs_get->string_mb);
376 - for (rule= sccs_get_rule; rule != NULL; rule= rule->next)
377 - (void)printf("\t%s\n", rule->command_line->string_mb);
378 - };
379 -
380 - /* .SILENT */
381 - if (is_true(flag.silent))
382 - (void)printf("%s:\n", cached_names.silent->string_mb);
383 -
384 - /* .SUFFIXES: */
385 - (void)printf("%s: ", cached_names.suffixes->string_mb);
386 - for (dep= suffixes; dep != NULL; dep= dep->next) {
387 - (void)printf("%s ", dep->name->string_mb);
388 - build_suffix_list(dep->name);
389 - };
390 - (void)printf("\n\n");
391 -
392 - /* % rules */
393 - for (percent= percent_list; percent != NULL; percent= percent->next) {
394 - (void) printf("%s:", percent->name->string_mb);
395 -
396 - for (percent_depe= percent->dependencies; percent_depe != NULL; percent_depe = percent_depe->next)
397 - (void) printf(" %s", percent_depe->name->string_mb);
398 -
399 - (void) printf("\n");
400 -
401 - for (rule= percent->command_template; rule != NULL; rule= rule->next)
402 - (void)printf("\t%s\n", rule->command_line->string_mb);
403 - };
404 -
405 - /* Suffix rules */
406 - for (p = hashtab.begin(), e = hashtab.end(); p != e; p++)
407 - if (is_false(p->dependency_printed) && (p->string[0] == PERIOD)) {
408 - print_rule(p);
409 - p->dependency_printed= true;
410 - };
411 -
412 - /* Macro assignments */
413 - for (p = hashtab.begin(), e = hashtab.end(); p != e; p++)
414 - if (((prop= get_prop(p->prop, macro_prop)) != NULL) &&
415 - (prop->body.macro.value != NULL)) {
416 - (void)printf("%s", p->string_mb);
417 - print_value(prop->body.macro.value,
418 - prop->body.macro.daemon);
419 - };
420 - (void)printf("\n");
421 -
422 - /* Delays */
423 - for (p = hashtab.begin(), e = hashtab.end(); p != e; p++)
424 - for (prop= get_prop(p->prop, conditional_prop);
425 - prop != NULL;
426 - prop= get_prop(prop->next, conditional_prop)) {
427 - (void)printf("%s := %s",
428 - p->string_mb,
429 - prop->body.conditional.name->string_mb);
430 - print_value(prop->body.conditional.value, no_daemon);
431 - };
432 - (void)printf("\n");
433 -
434 - /* All other dependencies */
435 - for (p = hashtab.begin(), e = hashtab.end(); p != e; p++)
436 - if (is_false(p->dependency_printed) && (p->colons != no_colon))
437 - print_rule(p);
438 - (void)printf("\n");
439 - exit(0);
440 -}
441 -#endif
442 304
443 305 /*
444 306 * This is a set of routines for dumping the internal make state
445 307 * Used for the -p option
446 308 */
447 309 void
448 310 print_value(register Name value, Daemon daemon)
449 311
450 -#ifdef SUNOS4_AND_AFTER
451 312
452 -#else
453 -
454 -#endif
455 313 {
456 314 Chain cp;
457 315
458 316 if (value == NULL)
459 317 (void)printf("=\n");
460 318 else
461 319 switch (daemon) {
462 320 case no_daemon:
463 321 (void)printf("= %s\n", value->string_mb);
464 322 break;
465 323 case chain_daemon:
466 324 for (cp= (Chain) value; cp != NULL; cp= cp->next)
467 325 (void)printf(cp->next == NULL ? "%s" : "%s ",
468 326 cp->name->string_mb);
469 327 (void)printf("\n");
470 328 break;
471 329 };
472 330 }
473 331
474 332 static void
475 333 print_rule(register Name target)
476 334 {
477 335 register Cmd_line rule;
478 336 register Property line;
479 337
480 338 if (((line= get_prop(target->prop, line_prop)) == NULL) ||
481 339 ((line->body.line.command_template == NULL) &&
482 340 (line->body.line.dependencies == NULL)))
483 341 return;
484 342 print_dependencies(target, line);
485 343 for (rule= line->body.line.command_template; rule != NULL; rule= rule->next)
486 344 (void)printf("\t%s\n", rule->command_line->string_mb);
487 345 }
488 346
489 347
490 348 /*
491 349 * If target is recursive, print the following to standard out:
492 350 * .RECURSIVE subdir targ Makefile
493 351 */
494 352 static void
495 353 print_rec_info(Name target)
496 354 {
497 355 Recursive_make rp;
498 356 wchar_t *colon;
499 357
500 358 report_recursive_init();
501 359
502 360 rp = find_recursive_target(target);
503 361
504 362 if (rp) {
505 363 /*
506 364 * if found, print starting with the space after the ':'
507 365 */
508 366 colon = (wchar_t *) wschr(rp->oldline, (int) colon_char);
509 367 (void) printf("%s", colon + 1);
510 368 }
511 369 }
512 370
↓ open down ↓ |
48 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX