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