Print this page
make: use the more modern wchar routines, not widec.h
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
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 170 if ((report_dependencies_level == 2) ||
171 171 (report_dependencies_level == 4)) {
172 172 if (is_out_of_date(line)) {
173 173 (void) printf("1 ");
174 174 } else {
175 175 (void) printf("0 ");
176 176 }
177 177 }
178 178 print_filename(target);
179 179 (void) printf(":\t");
180 180 print_deplist(line->body.line.dependencies);
181 181 print_rec_info(target);
182 182 (void) printf("\n");
183 183 for (dep = line->body.line.dependencies;
184 184 dep != NULL;
185 185 dep = dep->next) {
186 186 print_deps(dep->name,
187 187 get_prop(dep->name->prop, line_prop));
188 188 }
189 189 }
190 190 }
191 191
192 192 static Boolean
193 193 is_out_of_date(Property line)
194 194 {
195 195 Dependency dep;
196 196 Property line2;
197 197
198 198 if (line == NULL) {
199 199 return false;
200 200 }
201 201 if (line->body.line.is_out_of_date) {
202 202 return true;
203 203 }
204 204 for (dep = line->body.line.dependencies;
205 205 dep != NULL;
206 206 dep = dep->next) {
207 207 line2 = get_prop(dep->name->prop, line_prop);
208 208 if (is_out_of_date(line2)) {
209 209 line->body.line.is_out_of_date = true;
210 210 return true;
211 211 }
212 212 }
213 213 return false;
214 214 }
215 215
216 216 /*
217 217 * Given a dependency print it and all its siblings.
218 218 */
219 219 static void
220 220 print_deplist(Dependency head)
221 221 {
222 222 Dependency dp;
223 223
224 224 for (dp = head; dp != NULL; dp = dp->next) {
225 225 if ((report_dependencies_level != 2) ||
226 226 ((!dp->automatic) ||
227 227 (dp->name->is_double_colon))) {
228 228 if (dp->name != force) {
229 229 putwchar(' ');
230 230 print_filename(dp->name);
231 231 }
232 232 }
233 233 }
234 234 }
235 235
236 236 /*
237 237 * Print the name of a file for the -P option.
238 238 * If the file is a directory put on a trailing slash.
239 239 */
240 240 static void
241 241 print_filename(Name name)
242 242 {
243 243 (void) printf("%s", name->string_mb);
244 244 /*
245 245 if (name->stat.is_dir) {
246 246 putwchar('/');
247 247 }
248 248 */
249 249 }
250 250
251 251 /*
252 252 * should_print_dep(line)
253 253 *
254 254 * Test if we should print the dependencies of this target.
255 255 * The line must exist and either have children dependencies
256 256 * or have a command that is not an SCCS command.
257 257 *
258 258 * Return value:
259 259 * true if the dependencies should be printed
260 260 *
261 261 * Parameters:
262 262 * line We get the dependency list from here
263 263 *
264 264 * Global variables used:
265 265 */
266 266 static Boolean
267 267 should_print_dep(Property line)
268 268 {
269 269 if (line == NULL) {
270 270 return false;
271 271 }
272 272 if (line->body.line.dependencies != NULL) {
273 273 return true;
274 274 }
275 275 if (line->body.line.sccs_command) {
276 276 return false;
277 277 }
278 278 return true;
279 279 }
280 280
281 281 /*
282 282 * Print out the root nodes of all the dependency trees
283 283 * in this makefile.
284 284 */
285 285 static void
286 286 print_forest(Name target)
287 287 {
288 288 Name_set::iterator np, e;
289 289 Property line;
290 290
291 291 for (np = hashtab.begin(), e = hashtab.end(); np != e; np++) {
292 292 if (np->is_target && !np->has_parent && np != target) {
293 293 (void) doname_check(np, true, false, false);
294 294 line = get_prop(np->prop, line_prop);
295 295 printf("-\n");
296 296 print_deps(np, line);
297 297 }
298 298 }
299 299 }
300 300
301 301
302 302 /*
303 303 * This is a set of routines for dumping the internal make state
304 304 * Used for the -p option
305 305 */
306 306 void
307 307 print_value(register Name value, Daemon daemon)
308 308
309 309
310 310 {
311 311 Chain cp;
312 312
313 313 if (value == NULL)
314 314 (void)printf("=\n");
315 315 else
316 316 switch (daemon) {
317 317 case no_daemon:
318 318 (void)printf("= %s\n", value->string_mb);
319 319 break;
320 320 case chain_daemon:
321 321 for (cp= (Chain) value; cp != NULL; cp= cp->next)
322 322 (void)printf(cp->next == NULL ? "%s" : "%s ",
323 323 cp->name->string_mb);
324 324 (void)printf("\n");
325 325 break;
326 326 };
327 327 }
328 328
329 329 static void
330 330 print_rule(register Name target)
331 331 {
332 332 register Cmd_line rule;
333 333 register Property line;
334 334
335 335 if (((line= get_prop(target->prop, line_prop)) == NULL) ||
336 336 ((line->body.line.command_template == NULL) &&
337 337 (line->body.line.dependencies == NULL)))
338 338 return;
339 339 print_dependencies(target, line);
340 340 for (rule= line->body.line.command_template; rule != NULL; rule= rule->next)
341 341 (void)printf("\t%s\n", rule->command_line->string_mb);
342 342 }
343 343
344 344
345 345 /*
346 346 * If target is recursive, print the following to standard out:
347 347 * .RECURSIVE subdir targ Makefile
348 348 */
349 349 static void
350 350 print_rec_info(Name target)
351 351 {
352 352 Recursive_make rp;
↓ open down ↓ |
352 lines elided |
↑ open up ↑ |
353 353 wchar_t *colon;
354 354
355 355 report_recursive_init();
356 356
357 357 rp = find_recursive_target(target);
358 358
359 359 if (rp) {
360 360 /*
361 361 * if found, print starting with the space after the ':'
362 362 */
363 - colon = (wchar_t *) wschr(rp->oldline, (int) colon_char);
363 + colon = (wchar_t *) wcschr(rp->oldline, (int) colon_char);
364 364 (void) printf("%s", colon + 1);
365 365 }
366 366 }
367 367
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX