Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / usr.bin / make / targ.c
blobed710b4bd10543062aafcebcb5155a7e6b22f9c5
1 /* $NetBSD: targ.c,v 1.54 2008/12/13 15:19:29 dsl Exp $ */
3 /*
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
36 * Copyright (c) 1989 by Berkeley Softworks
37 * All rights reserved.
39 * This code is derived from software contributed to Berkeley by
40 * Adam de Boor.
42 * Redistribution and use in source and binary forms, with or without
43 * modification, are permitted provided that the following conditions
44 * are met:
45 * 1. Redistributions of source code must retain the above copyright
46 * notice, this list of conditions and the following disclaimer.
47 * 2. Redistributions in binary form must reproduce the above copyright
48 * notice, this list of conditions and the following disclaimer in the
49 * documentation and/or other materials provided with the distribution.
50 * 3. All advertising materials mentioning features or use of this software
51 * must display the following acknowledgement:
52 * This product includes software developed by the University of
53 * California, Berkeley and its contributors.
54 * 4. Neither the name of the University nor the names of its contributors
55 * may be used to endorse or promote products derived from this software
56 * without specific prior written permission.
58 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE.
71 #ifndef MAKE_NATIVE
72 static char rcsid[] = "$NetBSD: targ.c,v 1.54 2008/12/13 15:19:29 dsl Exp $";
73 #else
74 #include <sys/cdefs.h>
75 #ifndef lint
76 #if 0
77 static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94";
78 #else
79 __RCSID("$NetBSD: targ.c,v 1.54 2008/12/13 15:19:29 dsl Exp $");
80 #endif
81 #endif /* not lint */
82 #endif
84 /*-
85 * targ.c --
86 * Functions for maintaining the Lst allTargets. Target nodes are
87 * kept in two structures: a Lst, maintained by the list library, and a
88 * hash table, maintained by the hash library.
90 * Interface:
91 * Targ_Init Initialization procedure.
93 * Targ_End Cleanup the module
95 * Targ_List Return the list of all targets so far.
97 * Targ_NewGN Create a new GNode for the passed target
98 * (string). The node is *not* placed in the
99 * hash table, though all its fields are
100 * initialized.
102 * Targ_FindNode Find the node for a given target, creating
103 * and storing it if it doesn't exist and the
104 * flags are right (TARG_CREATE)
106 * Targ_FindList Given a list of names, find nodes for all
107 * of them. If a name doesn't exist and the
108 * TARG_NOCREATE flag was given, an error message
109 * is printed. Else, if a name doesn't exist,
110 * its node is created.
112 * Targ_Ignore Return TRUE if errors should be ignored when
113 * creating the given target.
115 * Targ_Silent Return TRUE if we should be silent when
116 * creating the given target.
118 * Targ_Precious Return TRUE if the target is precious and
119 * should not be removed if we are interrupted.
121 * Targ_Propagate Propagate information between related
122 * nodes. Should be called after the
123 * makefiles are parsed but before any
124 * action is taken.
126 * Debugging:
127 * Targ_PrintGraph Print out the entire graphm all variables
128 * and statistics for the directory cache. Should
129 * print something for suffixes, too, but...
132 #include <stdio.h>
133 #include <time.h>
135 #include "make.h"
136 #include "hash.h"
137 #include "dir.h"
139 static Lst allTargets; /* the list of all targets found so far */
140 #ifdef CLEANUP
141 static Lst allGNs; /* List of all the GNodes */
142 #endif
143 static Hash_Table targets; /* a hash table of same */
145 #define HTSIZE 191 /* initial size of hash table */
147 static int TargPrintOnlySrc(void *, void *);
148 static int TargPrintName(void *, void *);
149 #ifdef CLEANUP
150 static void TargFreeGN(void *);
151 #endif
152 static int TargPropagateCohort(void *, void *);
153 static int TargPropagateNode(void *, void *);
156 *-----------------------------------------------------------------------
157 * Targ_Init --
158 * Initialize this module
160 * Results:
161 * None
163 * Side Effects:
164 * The allTargets list and the targets hash table are initialized
165 *-----------------------------------------------------------------------
167 void
168 Targ_Init(void)
170 allTargets = Lst_Init(FALSE);
171 Hash_InitTable(&targets, HTSIZE);
175 *-----------------------------------------------------------------------
176 * Targ_End --
177 * Finalize this module
179 * Results:
180 * None
182 * Side Effects:
183 * All lists and gnodes are cleared
184 *-----------------------------------------------------------------------
186 void
187 Targ_End(void)
189 #ifdef CLEANUP
190 Lst_Destroy(allTargets, NULL);
191 if (allGNs)
192 Lst_Destroy(allGNs, TargFreeGN);
193 Hash_DeleteTable(&targets);
194 #endif
198 *-----------------------------------------------------------------------
199 * Targ_List --
200 * Return the list of all targets
202 * Results:
203 * The list of all targets.
205 * Side Effects:
206 * None
207 *-----------------------------------------------------------------------
210 Targ_List(void)
212 return allTargets;
216 *-----------------------------------------------------------------------
217 * Targ_NewGN --
218 * Create and initialize a new graph node
220 * Input:
221 * name the name to stick in the new node
223 * Results:
224 * An initialized graph node with the name field filled with a copy
225 * of the passed name
227 * Side Effects:
228 * The gnode is added to the list of all gnodes.
229 *-----------------------------------------------------------------------
231 GNode *
232 Targ_NewGN(const char *name)
234 GNode *gn;
236 gn = bmake_malloc(sizeof(GNode));
237 gn->name = bmake_strdup(name);
238 gn->uname = NULL;
239 gn->path = NULL;
240 if (name[0] == '-' && name[1] == 'l') {
241 gn->type = OP_LIB;
242 } else {
243 gn->type = 0;
245 gn->unmade = 0;
246 gn->unmade_cohorts = 0;
247 gn->cohort_num[0] = 0;
248 gn->centurion = NULL;
249 gn->made = UNMADE;
250 gn->flags = 0;
251 gn->checked = 0;
252 gn->mtime = gn->cmtime = 0;
253 gn->iParents = Lst_Init(FALSE);
254 gn->cohorts = Lst_Init(FALSE);
255 gn->parents = Lst_Init(FALSE);
256 gn->children = Lst_Init(FALSE);
257 gn->order_pred = Lst_Init(FALSE);
258 gn->order_succ = Lst_Init(FALSE);
259 Hash_InitTable(&gn->context, 0);
260 gn->commands = Lst_Init(FALSE);
261 gn->suffix = NULL;
262 gn->lineno = 0;
263 gn->fname = NULL;
265 #ifdef CLEANUP
266 if (allGNs == NULL)
267 allGNs = Lst_Init(FALSE);
268 Lst_AtEnd(allGNs, gn);
269 #endif
271 return (gn);
274 #ifdef CLEANUP
276 *-----------------------------------------------------------------------
277 * TargFreeGN --
278 * Destroy a GNode
280 * Results:
281 * None.
283 * Side Effects:
284 * None.
285 *-----------------------------------------------------------------------
287 static void
288 TargFreeGN(void *gnp)
290 GNode *gn = (GNode *)gnp;
293 free(gn->name);
294 if (gn->uname)
295 free(gn->uname);
296 if (gn->path)
297 free(gn->path);
298 /* gn->fname points to name allocated when file was opened, don't free */
300 Lst_Destroy(gn->iParents, NULL);
301 Lst_Destroy(gn->cohorts, NULL);
302 Lst_Destroy(gn->parents, NULL);
303 Lst_Destroy(gn->children, NULL);
304 Lst_Destroy(gn->order_succ, NULL);
305 Lst_Destroy(gn->order_pred, NULL);
306 Hash_DeleteTable(&gn->context);
307 Lst_Destroy(gn->commands, NULL);
308 free(gn);
310 #endif
314 *-----------------------------------------------------------------------
315 * Targ_FindNode --
316 * Find a node in the list using the given name for matching
318 * Input:
319 * name the name to find
320 * flags flags governing events when target not
321 * found
323 * Results:
324 * The node in the list if it was. If it wasn't, return NULL of
325 * flags was TARG_NOCREATE or the newly created and initialized node
326 * if it was TARG_CREATE
328 * Side Effects:
329 * Sometimes a node is created and added to the list
330 *-----------------------------------------------------------------------
332 GNode *
333 Targ_FindNode(const char *name, int flags)
335 GNode *gn; /* node in that element */
336 Hash_Entry *he; /* New or used hash entry for node */
337 Boolean isNew; /* Set TRUE if Hash_CreateEntry had to create */
338 /* an entry for the node */
340 if (!(flags & (TARG_CREATE | TARG_NOHASH))) {
341 he = Hash_FindEntry(&targets, name);
342 if (he == NULL)
343 return NULL;
344 return (GNode *)Hash_GetValue(he);
347 if (!(flags & TARG_NOHASH)) {
348 he = Hash_CreateEntry(&targets, name, &isNew);
349 if (!isNew)
350 return (GNode *)Hash_GetValue(he);
353 gn = Targ_NewGN(name);
354 if (!(flags & TARG_NOHASH))
355 Hash_SetValue(he, gn);
356 Var_Append(".ALLTARGETS", name, VAR_GLOBAL);
357 (void)Lst_AtEnd(allTargets, gn);
358 if (doing_depend)
359 gn->flags |= FROM_DEPEND;
360 return gn;
364 *-----------------------------------------------------------------------
365 * Targ_FindList --
366 * Make a complete list of GNodes from the given list of names
368 * Input:
369 * name list of names to find
370 * flags flags used if no node is found for a given name
372 * Results:
373 * A complete list of graph nodes corresponding to all instances of all
374 * the names in names.
376 * Side Effects:
377 * If flags is TARG_CREATE, nodes will be created for all names in
378 * names which do not yet have graph nodes. If flags is TARG_NOCREATE,
379 * an error message will be printed for each name which can't be found.
380 * -----------------------------------------------------------------------
383 Targ_FindList(Lst names, int flags)
385 Lst nodes; /* result list */
386 LstNode ln; /* name list element */
387 GNode *gn; /* node in tLn */
388 char *name;
390 nodes = Lst_Init(FALSE);
392 if (Lst_Open(names) == FAILURE) {
393 return (nodes);
395 while ((ln = Lst_Next(names)) != NULL) {
396 name = (char *)Lst_Datum(ln);
397 gn = Targ_FindNode(name, flags);
398 if (gn != NULL) {
400 * Note: Lst_AtEnd must come before the Lst_Concat so the nodes
401 * are added to the list in the order in which they were
402 * encountered in the makefile.
404 (void)Lst_AtEnd(nodes, gn);
405 } else if (flags == TARG_NOCREATE) {
406 Error("\"%s\" -- target unknown.", name);
409 Lst_Close(names);
410 return (nodes);
414 *-----------------------------------------------------------------------
415 * Targ_Ignore --
416 * Return true if should ignore errors when creating gn
418 * Input:
419 * gn node to check for
421 * Results:
422 * TRUE if should ignore errors
424 * Side Effects:
425 * None
426 *-----------------------------------------------------------------------
428 Boolean
429 Targ_Ignore(GNode *gn)
431 if (ignoreErrors || gn->type & OP_IGNORE) {
432 return (TRUE);
433 } else {
434 return (FALSE);
439 *-----------------------------------------------------------------------
440 * Targ_Silent --
441 * Return true if be silent when creating gn
443 * Input:
444 * gn node to check for
446 * Results:
447 * TRUE if should be silent
449 * Side Effects:
450 * None
451 *-----------------------------------------------------------------------
453 Boolean
454 Targ_Silent(GNode *gn)
456 if (beSilent || gn->type & OP_SILENT) {
457 return (TRUE);
458 } else {
459 return (FALSE);
464 *-----------------------------------------------------------------------
465 * Targ_Precious --
466 * See if the given target is precious
468 * Input:
469 * gn the node to check
471 * Results:
472 * TRUE if it is precious. FALSE otherwise
474 * Side Effects:
475 * None
476 *-----------------------------------------------------------------------
478 Boolean
479 Targ_Precious(GNode *gn)
481 if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) {
482 return (TRUE);
483 } else {
484 return (FALSE);
488 /******************* DEBUG INFO PRINTING ****************/
490 static GNode *mainTarg; /* the main target, as set by Targ_SetMain */
492 *-----------------------------------------------------------------------
493 * Targ_SetMain --
494 * Set our idea of the main target we'll be creating. Used for
495 * debugging output.
497 * Input:
498 * gn The main target we'll create
500 * Results:
501 * None.
503 * Side Effects:
504 * "mainTarg" is set to the main target's node.
505 *-----------------------------------------------------------------------
507 void
508 Targ_SetMain(GNode *gn)
510 mainTarg = gn;
513 static int
514 TargPrintName(void *gnp, void *pflags __unused)
516 GNode *gn = (GNode *)gnp;
518 fprintf(debug_file, "%s%s ", gn->name, gn->cohort_num);
520 return 0;
525 Targ_PrintCmd(void *cmd, void *dummy)
527 fprintf(debug_file, "\t%s\n", (char *)cmd);
528 return (dummy ? 0 : 0);
532 *-----------------------------------------------------------------------
533 * Targ_FmtTime --
534 * Format a modification time in some reasonable way and return it.
536 * Results:
537 * The time reformatted.
539 * Side Effects:
540 * The time is placed in a static area, so it is overwritten
541 * with each call.
543 *-----------------------------------------------------------------------
545 char *
546 Targ_FmtTime(time_t tm)
548 struct tm *parts;
549 static char buf[128];
551 parts = localtime(&tm);
552 (void)strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts);
553 return(buf);
557 *-----------------------------------------------------------------------
558 * Targ_PrintType --
559 * Print out a type field giving only those attributes the user can
560 * set.
562 * Results:
564 * Side Effects:
566 *-----------------------------------------------------------------------
568 void
569 Targ_PrintType(int type)
571 int tbit;
573 #define PRINTBIT(attr) case CONCAT(OP_,attr): fprintf(debug_file, "." #attr " "); break
574 #define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG))fprintf(debug_file, "." #attr " "); break
576 type &= ~OP_OPMASK;
578 while (type) {
579 tbit = 1 << (ffs(type) - 1);
580 type &= ~tbit;
582 switch(tbit) {
583 PRINTBIT(OPTIONAL);
584 PRINTBIT(USE);
585 PRINTBIT(EXEC);
586 PRINTBIT(IGNORE);
587 PRINTBIT(PRECIOUS);
588 PRINTBIT(SILENT);
589 PRINTBIT(MAKE);
590 PRINTBIT(JOIN);
591 PRINTBIT(INVISIBLE);
592 PRINTBIT(NOTMAIN);
593 PRINTDBIT(LIB);
594 /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
595 case OP_MEMBER: if (DEBUG(TARG))fprintf(debug_file, ".MEMBER "); break;
596 PRINTDBIT(ARCHV);
597 PRINTDBIT(MADE);
598 PRINTDBIT(PHONY);
603 static const char *
604 made_name(enum enum_made made)
606 switch (made) {
607 case UNMADE: return "unmade";
608 case DEFERRED: return "deferred";
609 case REQUESTED: return "requested";
610 case BEINGMADE: return "being made";
611 case MADE: return "made";
612 case UPTODATE: return "up-to-date";
613 case ERROR: return "error when made";
614 case ABORTED: return "aborted";
615 default: return "unknown enum_made value";
620 *-----------------------------------------------------------------------
621 * TargPrintNode --
622 * print the contents of a node
623 *-----------------------------------------------------------------------
626 Targ_PrintNode(void *gnp, void *passp)
628 GNode *gn = (GNode *)gnp;
629 int pass = passp ? *(int *)passp : 0;
631 fprintf(debug_file, "# %s%s, flags %x, type %x, made %d\n",
632 gn->name, gn->cohort_num, gn->flags, gn->type, gn->made);
633 if (gn->flags == 0)
634 return 0;
636 if (!OP_NOP(gn->type)) {
637 fprintf(debug_file, "#\n");
638 if (gn == mainTarg) {
639 fprintf(debug_file, "# *** MAIN TARGET ***\n");
641 if (pass >= 2) {
642 if (gn->unmade) {
643 fprintf(debug_file, "# %d unmade children\n", gn->unmade);
644 } else {
645 fprintf(debug_file, "# No unmade children\n");
647 if (! (gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC))) {
648 if (gn->mtime != 0) {
649 fprintf(debug_file, "# last modified %s: %s\n",
650 Targ_FmtTime(gn->mtime),
651 made_name(gn->made));
652 } else if (gn->made != UNMADE) {
653 fprintf(debug_file, "# non-existent (maybe): %s\n",
654 made_name(gn->made));
655 } else {
656 fprintf(debug_file, "# unmade\n");
659 if (!Lst_IsEmpty (gn->iParents)) {
660 fprintf(debug_file, "# implicit parents: ");
661 Lst_ForEach(gn->iParents, TargPrintName, NULL);
662 fprintf(debug_file, "\n");
664 } else {
665 if (gn->unmade)
666 fprintf(debug_file, "# %d unmade children\n", gn->unmade);
668 if (!Lst_IsEmpty (gn->parents)) {
669 fprintf(debug_file, "# parents: ");
670 Lst_ForEach(gn->parents, TargPrintName, NULL);
671 fprintf(debug_file, "\n");
673 if (!Lst_IsEmpty (gn->order_pred)) {
674 fprintf(debug_file, "# order_pred: ");
675 Lst_ForEach(gn->order_pred, TargPrintName, NULL);
676 fprintf(debug_file, "\n");
678 if (!Lst_IsEmpty (gn->order_succ)) {
679 fprintf(debug_file, "# order_succ: ");
680 Lst_ForEach(gn->order_succ, TargPrintName, NULL);
681 fprintf(debug_file, "\n");
684 fprintf(debug_file, "%-16s", gn->name);
685 switch (gn->type & OP_OPMASK) {
686 case OP_DEPENDS:
687 fprintf(debug_file, ": "); break;
688 case OP_FORCE:
689 fprintf(debug_file, "! "); break;
690 case OP_DOUBLEDEP:
691 fprintf(debug_file, ":: "); break;
693 Targ_PrintType(gn->type);
694 Lst_ForEach(gn->children, TargPrintName, NULL);
695 fprintf(debug_file, "\n");
696 Lst_ForEach(gn->commands, Targ_PrintCmd, NULL);
697 fprintf(debug_file, "\n\n");
698 if (gn->type & OP_DOUBLEDEP) {
699 Lst_ForEach(gn->cohorts, Targ_PrintNode, &pass);
702 return (0);
706 *-----------------------------------------------------------------------
707 * TargPrintOnlySrc --
708 * Print only those targets that are just a source.
710 * Results:
711 * 0.
713 * Side Effects:
714 * The name of each file is printed preceded by #\t
716 *-----------------------------------------------------------------------
718 static int
719 TargPrintOnlySrc(void *gnp, void *dummy __unused)
721 GNode *gn = (GNode *)gnp;
722 if (!OP_NOP(gn->type))
723 return 0;
725 fprintf(debug_file, "#\t%s [%s] ",
726 gn->name, gn->path ? gn->path : gn->name);
727 Targ_PrintType(gn->type);
728 fprintf(debug_file, "\n");
730 return 0;
734 *-----------------------------------------------------------------------
735 * Targ_PrintGraph --
736 * print the entire graph. heh heh
738 * Input:
739 * pass Which pass this is. 1 => no processing
740 * 2 => processing done
742 * Results:
743 * none
745 * Side Effects:
746 * lots o' output
747 *-----------------------------------------------------------------------
749 void
750 Targ_PrintGraph(int pass)
752 fprintf(debug_file, "#*** Input graph:\n");
753 Lst_ForEach(allTargets, Targ_PrintNode, &pass);
754 fprintf(debug_file, "\n\n");
755 fprintf(debug_file, "#\n# Files that are only sources:\n");
756 Lst_ForEach(allTargets, TargPrintOnlySrc, NULL);
757 fprintf(debug_file, "#*** Global Variables:\n");
758 Var_Dump(VAR_GLOBAL);
759 fprintf(debug_file, "#*** Command-line Variables:\n");
760 Var_Dump(VAR_CMD);
761 fprintf(debug_file, "\n");
762 Dir_PrintDirectories();
763 fprintf(debug_file, "\n");
764 Suff_PrintAll();
768 *-----------------------------------------------------------------------
769 * TargPropagateNode --
770 * Propagate information from a single node to related nodes if
771 * appropriate.
773 * Input:
774 * gnp The node that we are processing.
776 * Results:
777 * Always returns 0, for the benefit of Lst_ForEach().
779 * Side Effects:
780 * Information is propagated from this node to cohort or child
781 * nodes.
783 * If the node was defined with "::", then TargPropagateCohort()
784 * will be called for each cohort node.
786 * If the node has recursive predecessors, then
787 * TargPropagateRecpred() will be called for each recursive
788 * predecessor.
789 *-----------------------------------------------------------------------
791 static int
792 TargPropagateNode(void *gnp, void *junk __unused)
794 GNode *gn = (GNode *)gnp;
796 if (gn->type & OP_DOUBLEDEP)
797 Lst_ForEach(gn->cohorts, TargPropagateCohort, gnp);
798 return (0);
802 *-----------------------------------------------------------------------
803 * TargPropagateCohort --
804 * Propagate some bits in the type mask from a node to
805 * a related cohort node.
807 * Input:
808 * cnp The node that we are processing.
809 * gnp Another node that has cnp as a cohort.
811 * Results:
812 * Always returns 0, for the benefit of Lst_ForEach().
814 * Side Effects:
815 * cnp's type bitmask is modified to incorporate some of the
816 * bits from gnp's type bitmask. (XXX need a better explanation.)
817 *-----------------------------------------------------------------------
819 static int
820 TargPropagateCohort(void *cgnp, void *pgnp)
822 GNode *cgn = (GNode *)cgnp;
823 GNode *pgn = (GNode *)pgnp;
825 cgn->type |= pgn->type & ~OP_OPMASK;
826 return (0);
830 *-----------------------------------------------------------------------
831 * Targ_Propagate --
832 * Propagate information between related nodes. Should be called
833 * after the makefiles are parsed but before any action is taken.
835 * Results:
836 * none
838 * Side Effects:
839 * Information is propagated between related nodes throughout the
840 * graph.
841 *-----------------------------------------------------------------------
843 void
844 Targ_Propagate(void)
846 Lst_ForEach(allTargets, TargPropagateNode, NULL);