Create SFFS library out of HGFS
[minix.git] / commands / make / targ.c
blobb0f63d9e759be031a74d2b4919391141254f124e
1 /* $NetBSD: targ.c,v 1.55 2009/01/23 21:26:30 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.55 2009/01/23 21:26:30 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.55 2009/01/23 21:26:30 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 <strings.h>
134 #include <time.h>
136 #include "make.h"
137 #include "hash.h"
138 #include "dir.h"
140 static Lst allTargets; /* the list of all targets found so far */
141 #ifdef CLEANUP
142 static Lst allGNs; /* List of all the GNodes */
143 #endif
144 static Hash_Table targets; /* a hash table of same */
146 #define HTSIZE 191 /* initial size of hash table */
148 static int TargPrintOnlySrc(void *, void *);
149 static int TargPrintName(void *, void *);
150 #ifdef CLEANUP
151 static void TargFreeGN(void *);
152 #endif
153 static int TargPropagateCohort(void *, void *);
154 static int TargPropagateNode(void *, void *);
157 *-----------------------------------------------------------------------
158 * Targ_Init --
159 * Initialize this module
161 * Results:
162 * None
164 * Side Effects:
165 * The allTargets list and the targets hash table are initialized
166 *-----------------------------------------------------------------------
168 void
169 Targ_Init(void)
171 allTargets = Lst_Init(FALSE);
172 Hash_InitTable(&targets, HTSIZE);
176 *-----------------------------------------------------------------------
177 * Targ_End --
178 * Finalize this module
180 * Results:
181 * None
183 * Side Effects:
184 * All lists and gnodes are cleared
185 *-----------------------------------------------------------------------
187 void
188 Targ_End(void)
190 #ifdef CLEANUP
191 Lst_Destroy(allTargets, NULL);
192 if (allGNs)
193 Lst_Destroy(allGNs, TargFreeGN);
194 Hash_DeleteTable(&targets);
195 #endif
199 *-----------------------------------------------------------------------
200 * Targ_List --
201 * Return the list of all targets
203 * Results:
204 * The list of all targets.
206 * Side Effects:
207 * None
208 *-----------------------------------------------------------------------
211 Targ_List(void)
213 return allTargets;
217 *-----------------------------------------------------------------------
218 * Targ_NewGN --
219 * Create and initialize a new graph node
221 * Input:
222 * name the name to stick in the new node
224 * Results:
225 * An initialized graph node with the name field filled with a copy
226 * of the passed name
228 * Side Effects:
229 * The gnode is added to the list of all gnodes.
230 *-----------------------------------------------------------------------
232 GNode *
233 Targ_NewGN(const char *name)
235 GNode *gn;
237 gn = bmake_malloc(sizeof(GNode));
238 gn->name = bmake_strdup(name);
239 gn->uname = NULL;
240 gn->path = NULL;
241 if (name[0] == '-' && name[1] == 'l') {
242 gn->type = OP_LIB;
243 } else {
244 gn->type = 0;
246 gn->unmade = 0;
247 gn->unmade_cohorts = 0;
248 gn->cohort_num[0] = 0;
249 gn->centurion = NULL;
250 gn->made = UNMADE;
251 gn->flags = 0;
252 gn->checked = 0;
253 gn->mtime = gn->cmtime = 0;
254 gn->iParents = Lst_Init(FALSE);
255 gn->cohorts = Lst_Init(FALSE);
256 gn->parents = Lst_Init(FALSE);
257 gn->children = Lst_Init(FALSE);
258 gn->order_pred = Lst_Init(FALSE);
259 gn->order_succ = Lst_Init(FALSE);
260 Hash_InitTable(&gn->context, 0);
261 gn->commands = Lst_Init(FALSE);
262 gn->suffix = NULL;
263 gn->lineno = 0;
264 gn->fname = NULL;
266 #ifdef CLEANUP
267 if (allGNs == NULL)
268 allGNs = Lst_Init(FALSE);
269 Lst_AtEnd(allGNs, gn);
270 #endif
272 return (gn);
275 #ifdef CLEANUP
277 *-----------------------------------------------------------------------
278 * TargFreeGN --
279 * Destroy a GNode
281 * Results:
282 * None.
284 * Side Effects:
285 * None.
286 *-----------------------------------------------------------------------
288 static void
289 TargFreeGN(void *gnp)
291 GNode *gn = (GNode *)gnp;
294 free(gn->name);
295 if (gn->uname)
296 free(gn->uname);
297 if (gn->path)
298 free(gn->path);
299 /* gn->fname points to name allocated when file was opened, don't free */
301 Lst_Destroy(gn->iParents, NULL);
302 Lst_Destroy(gn->cohorts, NULL);
303 Lst_Destroy(gn->parents, NULL);
304 Lst_Destroy(gn->children, NULL);
305 Lst_Destroy(gn->order_succ, NULL);
306 Lst_Destroy(gn->order_pred, NULL);
307 Hash_DeleteTable(&gn->context);
308 Lst_Destroy(gn->commands, NULL);
309 free(gn);
311 #endif
315 *-----------------------------------------------------------------------
316 * Targ_FindNode --
317 * Find a node in the list using the given name for matching
319 * Input:
320 * name the name to find
321 * flags flags governing events when target not
322 * found
324 * Results:
325 * The node in the list if it was. If it wasn't, return NULL of
326 * flags was TARG_NOCREATE or the newly created and initialized node
327 * if it was TARG_CREATE
329 * Side Effects:
330 * Sometimes a node is created and added to the list
331 *-----------------------------------------------------------------------
333 GNode *
334 Targ_FindNode(const char *name, int flags)
336 GNode *gn; /* node in that element */
337 Hash_Entry *he; /* New or used hash entry for node */
338 Boolean isNew; /* Set TRUE if Hash_CreateEntry had to create */
339 /* an entry for the node */
341 if (!(flags & (TARG_CREATE | TARG_NOHASH))) {
342 he = Hash_FindEntry(&targets, name);
343 if (he == NULL)
344 return NULL;
345 return (GNode *)Hash_GetValue(he);
348 if (!(flags & TARG_NOHASH)) {
349 he = Hash_CreateEntry(&targets, name, &isNew);
350 if (!isNew)
351 return (GNode *)Hash_GetValue(he);
354 gn = Targ_NewGN(name);
355 if (!(flags & TARG_NOHASH))
356 Hash_SetValue(he, gn);
357 Var_Append(".ALLTARGETS", name, VAR_GLOBAL);
358 (void)Lst_AtEnd(allTargets, gn);
359 if (doing_depend)
360 gn->flags |= FROM_DEPEND;
361 return gn;
365 *-----------------------------------------------------------------------
366 * Targ_FindList --
367 * Make a complete list of GNodes from the given list of names
369 * Input:
370 * name list of names to find
371 * flags flags used if no node is found for a given name
373 * Results:
374 * A complete list of graph nodes corresponding to all instances of all
375 * the names in names.
377 * Side Effects:
378 * If flags is TARG_CREATE, nodes will be created for all names in
379 * names which do not yet have graph nodes. If flags is TARG_NOCREATE,
380 * an error message will be printed for each name which can't be found.
381 * -----------------------------------------------------------------------
384 Targ_FindList(Lst names, int flags)
386 Lst nodes; /* result list */
387 LstNode ln; /* name list element */
388 GNode *gn; /* node in tLn */
389 char *name;
391 nodes = Lst_Init(FALSE);
393 if (Lst_Open(names) == FAILURE) {
394 return (nodes);
396 while ((ln = Lst_Next(names)) != NULL) {
397 name = (char *)Lst_Datum(ln);
398 gn = Targ_FindNode(name, flags);
399 if (gn != NULL) {
401 * Note: Lst_AtEnd must come before the Lst_Concat so the nodes
402 * are added to the list in the order in which they were
403 * encountered in the makefile.
405 (void)Lst_AtEnd(nodes, gn);
406 } else if (flags == TARG_NOCREATE) {
407 Error("\"%s\" -- target unknown.", name);
410 Lst_Close(names);
411 return (nodes);
415 *-----------------------------------------------------------------------
416 * Targ_Ignore --
417 * Return true if should ignore errors when creating gn
419 * Input:
420 * gn node to check for
422 * Results:
423 * TRUE if should ignore errors
425 * Side Effects:
426 * None
427 *-----------------------------------------------------------------------
429 Boolean
430 Targ_Ignore(GNode *gn)
432 if (ignoreErrors || gn->type & OP_IGNORE) {
433 return (TRUE);
434 } else {
435 return (FALSE);
440 *-----------------------------------------------------------------------
441 * Targ_Silent --
442 * Return true if be silent when creating gn
444 * Input:
445 * gn node to check for
447 * Results:
448 * TRUE if should be silent
450 * Side Effects:
451 * None
452 *-----------------------------------------------------------------------
454 Boolean
455 Targ_Silent(GNode *gn)
457 if (beSilent || gn->type & OP_SILENT) {
458 return (TRUE);
459 } else {
460 return (FALSE);
465 *-----------------------------------------------------------------------
466 * Targ_Precious --
467 * See if the given target is precious
469 * Input:
470 * gn the node to check
472 * Results:
473 * TRUE if it is precious. FALSE otherwise
475 * Side Effects:
476 * None
477 *-----------------------------------------------------------------------
479 Boolean
480 Targ_Precious(GNode *gn)
482 if (allPrecious || (gn->type & (OP_PRECIOUS|OP_DOUBLEDEP))) {
483 return (TRUE);
484 } else {
485 return (FALSE);
489 /******************* DEBUG INFO PRINTING ****************/
491 static GNode *mainTarg; /* the main target, as set by Targ_SetMain */
493 *-----------------------------------------------------------------------
494 * Targ_SetMain --
495 * Set our idea of the main target we'll be creating. Used for
496 * debugging output.
498 * Input:
499 * gn The main target we'll create
501 * Results:
502 * None.
504 * Side Effects:
505 * "mainTarg" is set to the main target's node.
506 *-----------------------------------------------------------------------
508 void
509 Targ_SetMain(GNode *gn)
511 mainTarg = gn;
514 static int
515 TargPrintName(void *gnp, void *pflags __unused)
517 GNode *gn = (GNode *)gnp;
519 fprintf(debug_file, "%s%s ", gn->name, gn->cohort_num);
521 return 0;
526 Targ_PrintCmd(void *cmd, void *dummy)
528 fprintf(debug_file, "\t%s\n", (char *)cmd);
529 return (dummy ? 0 : 0);
533 *-----------------------------------------------------------------------
534 * Targ_FmtTime --
535 * Format a modification time in some reasonable way and return it.
537 * Results:
538 * The time reformatted.
540 * Side Effects:
541 * The time is placed in a static area, so it is overwritten
542 * with each call.
544 *-----------------------------------------------------------------------
546 char *
547 Targ_FmtTime(time_t tm)
549 struct tm *parts;
550 static char buf[128];
552 parts = localtime(&tm);
553 (void)strftime(buf, sizeof buf, "%k:%M:%S %b %d, %Y", parts);
554 return(buf);
558 *-----------------------------------------------------------------------
559 * Targ_PrintType --
560 * Print out a type field giving only those attributes the user can
561 * set.
563 * Results:
565 * Side Effects:
567 *-----------------------------------------------------------------------
569 void
570 Targ_PrintType(int type)
572 int tbit;
574 #define PRINTBIT(attr) case CONCAT(OP_,attr): fprintf(debug_file, "." #attr " "); break
575 #define PRINTDBIT(attr) case CONCAT(OP_,attr): if (DEBUG(TARG))fprintf(debug_file, "." #attr " "); break
577 type &= ~OP_OPMASK;
579 while (type) {
580 tbit = 1 << (ffs(type) - 1);
581 type &= ~tbit;
583 switch(tbit) {
584 PRINTBIT(OPTIONAL);
585 PRINTBIT(USE);
586 PRINTBIT(EXEC);
587 PRINTBIT(IGNORE);
588 PRINTBIT(PRECIOUS);
589 PRINTBIT(SILENT);
590 PRINTBIT(MAKE);
591 PRINTBIT(JOIN);
592 PRINTBIT(INVISIBLE);
593 PRINTBIT(NOTMAIN);
594 PRINTDBIT(LIB);
595 /*XXX: MEMBER is defined, so CONCAT(OP_,MEMBER) gives OP_"%" */
596 case OP_MEMBER: if (DEBUG(TARG))fprintf(debug_file, ".MEMBER "); break;
597 PRINTDBIT(ARCHV);
598 PRINTDBIT(MADE);
599 PRINTDBIT(PHONY);
604 static const char *
605 made_name(enum enum_made made)
607 switch (made) {
608 case UNMADE: return "unmade";
609 case DEFERRED: return "deferred";
610 case REQUESTED: return "requested";
611 case BEINGMADE: return "being made";
612 case MADE: return "made";
613 case UPTODATE: return "up-to-date";
614 case ERROR: return "error when made";
615 case ABORTED: return "aborted";
616 default: return "unknown enum_made value";
621 *-----------------------------------------------------------------------
622 * TargPrintNode --
623 * print the contents of a node
624 *-----------------------------------------------------------------------
627 Targ_PrintNode(void *gnp, void *passp)
629 GNode *gn = (GNode *)gnp;
630 int pass = passp ? *(int *)passp : 0;
632 fprintf(debug_file, "# %s%s, flags %x, type %x, made %d\n",
633 gn->name, gn->cohort_num, gn->flags, gn->type, gn->made);
634 if (gn->flags == 0)
635 return 0;
637 if (!OP_NOP(gn->type)) {
638 fprintf(debug_file, "#\n");
639 if (gn == mainTarg) {
640 fprintf(debug_file, "# *** MAIN TARGET ***\n");
642 if (pass >= 2) {
643 if (gn->unmade) {
644 fprintf(debug_file, "# %d unmade children\n", gn->unmade);
645 } else {
646 fprintf(debug_file, "# No unmade children\n");
648 if (! (gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC))) {
649 if (gn->mtime != 0) {
650 fprintf(debug_file, "# last modified %s: %s\n",
651 Targ_FmtTime(gn->mtime),
652 made_name(gn->made));
653 } else if (gn->made != UNMADE) {
654 fprintf(debug_file, "# non-existent (maybe): %s\n",
655 made_name(gn->made));
656 } else {
657 fprintf(debug_file, "# unmade\n");
660 if (!Lst_IsEmpty (gn->iParents)) {
661 fprintf(debug_file, "# implicit parents: ");
662 Lst_ForEach(gn->iParents, TargPrintName, NULL);
663 fprintf(debug_file, "\n");
665 } else {
666 if (gn->unmade)
667 fprintf(debug_file, "# %d unmade children\n", gn->unmade);
669 if (!Lst_IsEmpty (gn->parents)) {
670 fprintf(debug_file, "# parents: ");
671 Lst_ForEach(gn->parents, TargPrintName, NULL);
672 fprintf(debug_file, "\n");
674 if (!Lst_IsEmpty (gn->order_pred)) {
675 fprintf(debug_file, "# order_pred: ");
676 Lst_ForEach(gn->order_pred, TargPrintName, NULL);
677 fprintf(debug_file, "\n");
679 if (!Lst_IsEmpty (gn->order_succ)) {
680 fprintf(debug_file, "# order_succ: ");
681 Lst_ForEach(gn->order_succ, TargPrintName, NULL);
682 fprintf(debug_file, "\n");
685 fprintf(debug_file, "%-16s", gn->name);
686 switch (gn->type & OP_OPMASK) {
687 case OP_DEPENDS:
688 fprintf(debug_file, ": "); break;
689 case OP_FORCE:
690 fprintf(debug_file, "! "); break;
691 case OP_DOUBLEDEP:
692 fprintf(debug_file, ":: "); break;
694 Targ_PrintType(gn->type);
695 Lst_ForEach(gn->children, TargPrintName, NULL);
696 fprintf(debug_file, "\n");
697 Lst_ForEach(gn->commands, Targ_PrintCmd, NULL);
698 fprintf(debug_file, "\n\n");
699 if (gn->type & OP_DOUBLEDEP) {
700 Lst_ForEach(gn->cohorts, Targ_PrintNode, &pass);
703 return (0);
707 *-----------------------------------------------------------------------
708 * TargPrintOnlySrc --
709 * Print only those targets that are just a source.
711 * Results:
712 * 0.
714 * Side Effects:
715 * The name of each file is printed preceded by #\t
717 *-----------------------------------------------------------------------
719 static int
720 TargPrintOnlySrc(void *gnp, void *dummy __unused)
722 GNode *gn = (GNode *)gnp;
723 if (!OP_NOP(gn->type))
724 return 0;
726 fprintf(debug_file, "#\t%s [%s] ",
727 gn->name, gn->path ? gn->path : gn->name);
728 Targ_PrintType(gn->type);
729 fprintf(debug_file, "\n");
731 return 0;
735 *-----------------------------------------------------------------------
736 * Targ_PrintGraph --
737 * print the entire graph. heh heh
739 * Input:
740 * pass Which pass this is. 1 => no processing
741 * 2 => processing done
743 * Results:
744 * none
746 * Side Effects:
747 * lots o' output
748 *-----------------------------------------------------------------------
750 void
751 Targ_PrintGraph(int pass)
753 fprintf(debug_file, "#*** Input graph:\n");
754 Lst_ForEach(allTargets, Targ_PrintNode, &pass);
755 fprintf(debug_file, "\n\n");
756 fprintf(debug_file, "#\n# Files that are only sources:\n");
757 Lst_ForEach(allTargets, TargPrintOnlySrc, NULL);
758 fprintf(debug_file, "#*** Global Variables:\n");
759 Var_Dump(VAR_GLOBAL);
760 fprintf(debug_file, "#*** Command-line Variables:\n");
761 Var_Dump(VAR_CMD);
762 fprintf(debug_file, "\n");
763 Dir_PrintDirectories();
764 fprintf(debug_file, "\n");
765 Suff_PrintAll();
769 *-----------------------------------------------------------------------
770 * TargPropagateNode --
771 * Propagate information from a single node to related nodes if
772 * appropriate.
774 * Input:
775 * gnp The node that we are processing.
777 * Results:
778 * Always returns 0, for the benefit of Lst_ForEach().
780 * Side Effects:
781 * Information is propagated from this node to cohort or child
782 * nodes.
784 * If the node was defined with "::", then TargPropagateCohort()
785 * will be called for each cohort node.
787 * If the node has recursive predecessors, then
788 * TargPropagateRecpred() will be called for each recursive
789 * predecessor.
790 *-----------------------------------------------------------------------
792 static int
793 TargPropagateNode(void *gnp, void *junk __unused)
795 GNode *gn = (GNode *)gnp;
797 if (gn->type & OP_DOUBLEDEP)
798 Lst_ForEach(gn->cohorts, TargPropagateCohort, gnp);
799 return (0);
803 *-----------------------------------------------------------------------
804 * TargPropagateCohort --
805 * Propagate some bits in the type mask from a node to
806 * a related cohort node.
808 * Input:
809 * cnp The node that we are processing.
810 * gnp Another node that has cnp as a cohort.
812 * Results:
813 * Always returns 0, for the benefit of Lst_ForEach().
815 * Side Effects:
816 * cnp's type bitmask is modified to incorporate some of the
817 * bits from gnp's type bitmask. (XXX need a better explanation.)
818 *-----------------------------------------------------------------------
820 static int
821 TargPropagateCohort(void *cgnp, void *pgnp)
823 GNode *cgn = (GNode *)cgnp;
824 GNode *pgn = (GNode *)pgnp;
826 cgn->type |= pgn->type & ~OP_OPMASK;
827 return (0);
831 *-----------------------------------------------------------------------
832 * Targ_Propagate --
833 * Propagate information between related nodes. Should be called
834 * after the makefiles are parsed but before any action is taken.
836 * Results:
837 * none
839 * Side Effects:
840 * Information is propagated between related nodes throughout the
841 * graph.
842 *-----------------------------------------------------------------------
844 void
845 Targ_Propagate(void)
847 Lst_ForEach(allTargets, TargPropagateNode, NULL);