Print this page
make: unifdef for NSE (undefined)
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:
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 72 if (target_variants) {
73 73 depvar_print_results();
74 74 }
75 75
76 76 if (!makefiles_printed) {
77 77 /*
78 78 * Search the makefile list for the primary makefile,
79 79 * then print it and its inclusions. After that go back
80 80 * and print the default.mk file and its inclusions.
81 81 */
82 82 for (dp = makefiles_used; dp != NULL; dp = dp->next) {
83 83 if (dp->name == primary_makefile) {
84 84 break;
85 85 }
86 86 }
87 87 if (dp) {
88 88 print_deplist(dp);
89 89 for (dp = makefiles_used; dp != NULL; dp = dp->next) {
90 90 if (dp->name == primary_makefile) {
91 91 break;
92 92 }
93 93 (void)printf(" %s", dp->name->string_mb);
94 94 }
95 95 }
96 96 (void) printf("\n");
97 97 makefiles_printed = true;
98 98 }
99 99 print_deps(target, line);
100 100 /*
101 101 print_more_deps(target, init);
102 102 print_more_deps(target, done);
103 103 */
104 104 if (target_variants) {
105 105 print_forest(target);
106 106 }
107 107 }
108 108
109 109 /*
110 110 * print_more_deps(target, name)
111 111 *
112 112 * Print some special dependencies.
113 113 * These are the dependencies for the .INIT and .DONE targets.
114 114 *
115 115 * Parameters:
116 116 * target Target built during make run
117 117 * name Special target to print dependencies for
118 118 *
119 119 * Global variables used:
120 120 */
121 121 static void
122 122 print_more_deps(Name target, Name name)
123 123 {
124 124 Property line;
125 125 register Dependency dependencies;
126 126
127 127 line = get_prop(name->prop, line_prop);
128 128 if (line != NULL && line->body.line.dependencies != NULL) {
129 129 (void) printf("%s:\t", target->string_mb);
130 130 print_deplist(line->body.line.dependencies);
131 131 (void) printf("\n");
132 132 for (dependencies= line->body.line.dependencies;
133 133 dependencies != NULL;
134 134 dependencies= dependencies->next) {
135 135 print_deps(dependencies->name,
136 136 get_prop(dependencies->name->prop, line_prop));
137 137 }
138 138 }
139 139 }
140 140
141 141 /*
142 142 * print_deps(target, line, go_recursive)
143 143 *
144 144 * Print a regular dependency list. Append to this information which
145 145 * indicates whether or not the target is recursive.
146 146 *
147 147 * Parameters:
148 148 * target target to print dependencies for
149 149 * line We get the dependency list from here
150 150 * go_recursive Should we show all dependencies recursively?
151 151 *
152 152 * Global variables used:
153 153 * recursive_name The Name ".RECURSIVE", printed
154 154 */
155 155 static void
156 156 print_deps(register Name target, register Property line)
157 157 {
158 158 register Dependency dep;
159 159
↓ open down ↓ |
159 lines elided |
↑ open up ↑ |
160 160 if ((target->dependency_printed) ||
161 161 (target == force)) {
162 162 return;
163 163 }
164 164 target->dependency_printed = true;
165 165
166 166 /* only print entries that are actually derived and are not leaf
167 167 * files and are not the result of sccs get.
168 168 */
169 169 if (should_print_dep(line)) {
170 -#ifdef NSE
171 - nse_check_no_deps_no_rule(target, line, line);
172 -#endif
173 170 if ((report_dependencies_level == 2) ||
174 171 (report_dependencies_level == 4)) {
175 172 if (is_out_of_date(line)) {
176 173 (void) printf("1 ");
177 174 } else {
178 175 (void) printf("0 ");
179 176 }
180 177 }
181 178 print_filename(target);
182 179 (void) printf(":\t");
183 180 print_deplist(line->body.line.dependencies);
184 181 print_rec_info(target);
185 182 (void) printf("\n");
186 183 for (dep = line->body.line.dependencies;
187 184 dep != NULL;
188 185 dep = dep->next) {
189 186 print_deps(dep->name,
190 187 get_prop(dep->name->prop, line_prop));
191 188 }
192 189 }
193 190 }
194 191
195 192 static Boolean
196 193 is_out_of_date(Property line)
197 194 {
198 195 Dependency dep;
199 196 Property line2;
200 197
201 198 if (line == NULL) {
202 199 return false;
203 200 }
204 201 if (line->body.line.is_out_of_date) {
205 202 return true;
206 203 }
207 204 for (dep = line->body.line.dependencies;
208 205 dep != NULL;
209 206 dep = dep->next) {
210 207 line2 = get_prop(dep->name->prop, line_prop);
211 208 if (is_out_of_date(line2)) {
212 209 line->body.line.is_out_of_date = true;
213 210 return true;
214 211 }
215 212 }
216 213 return false;
217 214 }
218 215
219 216 /*
220 217 * Given a dependency print it and all its siblings.
221 218 */
222 219 static void
223 220 print_deplist(Dependency head)
224 221 {
225 222 Dependency dp;
226 223
227 224 for (dp = head; dp != NULL; dp = dp->next) {
228 225 if ((report_dependencies_level != 2) ||
229 226 ((!dp->automatic) ||
230 227 (dp->name->is_double_colon))) {
231 228 if (dp->name != force) {
232 229 putwchar(' ');
233 230 print_filename(dp->name);
234 231 }
235 232 }
236 233 }
237 234 }
238 235
239 236 /*
240 237 * Print the name of a file for the -P option.
241 238 * If the file is a directory put on a trailing slash.
242 239 */
243 240 static void
244 241 print_filename(Name name)
245 242 {
246 243 (void) printf("%s", name->string_mb);
247 244 /*
248 245 if (name->stat.is_dir) {
249 246 putwchar('/');
250 247 }
251 248 */
252 249 }
253 250
254 251 /*
255 252 * should_print_dep(line)
256 253 *
257 254 * Test if we should print the dependencies of this target.
258 255 * The line must exist and either have children dependencies
259 256 * or have a command that is not an SCCS command.
260 257 *
261 258 * Return value:
262 259 * true if the dependencies should be printed
263 260 *
264 261 * Parameters:
265 262 * line We get the dependency list from here
266 263 *
267 264 * Global variables used:
268 265 */
269 266 static Boolean
270 267 should_print_dep(Property line)
271 268 {
272 269 if (line == NULL) {
273 270 return false;
274 271 }
275 272 if (line->body.line.dependencies != NULL) {
276 273 return true;
277 274 }
278 275 if (line->body.line.sccs_command) {
279 276 return false;
280 277 }
281 278 return true;
282 279 }
283 280
284 281 /*
285 282 * Print out the root nodes of all the dependency trees
286 283 * in this makefile.
287 284 */
288 285 static void
289 286 print_forest(Name target)
290 287 {
291 288 Name_set::iterator np, e;
292 289 Property line;
293 290
294 291 for (np = hashtab.begin(), e = hashtab.end(); np != e; np++) {
295 292 if (np->is_target && !np->has_parent && np != target) {
296 293 (void) doname_check(np, true, false, false);
297 294 line = get_prop(np->prop, line_prop);
298 295 printf("-\n");
299 296 print_deps(np, line);
300 297 }
301 298 }
302 299 }
303 300
304 301
305 302 /*
306 303 * This is a set of routines for dumping the internal make state
307 304 * Used for the -p option
308 305 */
309 306 void
310 307 print_value(register Name value, Daemon daemon)
311 308
312 309
313 310 {
314 311 Chain cp;
315 312
316 313 if (value == NULL)
317 314 (void)printf("=\n");
318 315 else
319 316 switch (daemon) {
320 317 case no_daemon:
321 318 (void)printf("= %s\n", value->string_mb);
322 319 break;
323 320 case chain_daemon:
324 321 for (cp= (Chain) value; cp != NULL; cp= cp->next)
325 322 (void)printf(cp->next == NULL ? "%s" : "%s ",
326 323 cp->name->string_mb);
327 324 (void)printf("\n");
328 325 break;
329 326 };
330 327 }
331 328
332 329 static void
333 330 print_rule(register Name target)
334 331 {
335 332 register Cmd_line rule;
336 333 register Property line;
337 334
338 335 if (((line= get_prop(target->prop, line_prop)) == NULL) ||
339 336 ((line->body.line.command_template == NULL) &&
340 337 (line->body.line.dependencies == NULL)))
341 338 return;
342 339 print_dependencies(target, line);
343 340 for (rule= line->body.line.command_template; rule != NULL; rule= rule->next)
344 341 (void)printf("\t%s\n", rule->command_line->string_mb);
345 342 }
346 343
347 344
348 345 /*
349 346 * If target is recursive, print the following to standard out:
350 347 * .RECURSIVE subdir targ Makefile
351 348 */
352 349 static void
353 350 print_rec_info(Name target)
354 351 {
355 352 Recursive_make rp;
356 353 wchar_t *colon;
357 354
358 355 report_recursive_init();
359 356
360 357 rp = find_recursive_target(target);
361 358
362 359 if (rp) {
363 360 /*
364 361 * if found, print starting with the space after the ':'
365 362 */
366 363 colon = (wchar_t *) wschr(rp->oldline, (int) colon_char);
367 364 (void) printf("%s", colon + 1);
368 365 }
369 366 }
370 367
↓ open down ↓ |
188 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX