tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

make: who included me?



The patch below (shocking name for the variable - suggestions welcome)
was very useful in tracking down the cause of an odd situation.
For a makefile like dirdeps.mk which gets included 1000's of times,
during a build, it can be very handy to be able to report the makefile
that included it.

Index: parse.c
===================================================================
RCS file: /cvs/juniper/src/buildtools/bmake/parse.c,v
retrieving revision 1.40
diff -u -p -r1.40 parse.c
--- parse.c     22 Nov 2011 21:57:48 -0000      1.40
+++ parse.c     24 Nov 2011 04:38:19 -0000
@@ -2318,10 +2318,12 @@ Parse_SetInput(const char *name, int lin
        /* sanity */
        return;
 
-    if (curFile != NULL)
+    if (curFile != NULL) {
        /* Save exiting file info */
        Lst_AtFront(includes, curFile);
-
+       /* sometimes a makefile needs to know who included it */
+       Var_Set(".PARSEINCLUDEFROM", curFile->fname, VAR_GLOBAL, 0);
+    }
     /* Allocate and fill in new structure */
     curFile = bmake_malloc(sizeof *curFile);
 




Home | Main Index | Thread Index | Old Index