Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make add .INCLUDEDFROM{FILE,DIR}



details:   https://anonhg.NetBSD.org/src/rev/4475476e9e67
branches:  trunk
changeset: 792620:4475476e9e67
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 10 16:12:52 2014 +0000

description:
add .INCLUDEDFROM{FILE,DIR}

diffstat:

 usr.bin/make/make.1  |   6 ++++-
 usr.bin/make/parse.c |  63 ++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 56 insertions(+), 13 deletions(-)

diffs (173 lines):

diff -r 1a79b6627858 -r 4475476e9e67 usr.bin/make/make.1
--- a/usr.bin/make/make.1       Fri Jan 10 15:54:59 2014 +0000
+++ b/usr.bin/make/make.1       Fri Jan 10 16:12:52 2014 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.226 2013/11/07 18:50:46 dholland Exp $
+.\"    $NetBSD: make.1,v 1.227 2014/01/10 16:12:52 christos Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -638,6 +638,10 @@
 source); also known as
 .Ql Va \&\*[Lt] .
 It is not defined in explicit rules.
+.It Va .INCLUDEDFROMDIR
+The directory of the file this Makefile was included from.
+.It Va .INCLUDEDFROMFILE
+The filename of the file this Makefile was included from.
 .It Va .MEMBER
 The name of the archive member.
 .It Va .OODATE
diff -r 1a79b6627858 -r 4475476e9e67 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Fri Jan 10 15:54:59 2014 +0000
+++ b/usr.bin/make/parse.c      Fri Jan 10 16:12:52 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $     */
+/*     $NetBSD: parse.c,v 1.193 2014/01/10 16:12:52 christos Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.193 2014/01/10 16:12:52 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c    8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.192 2013/10/18 20:47:06 christos Exp $");
+__RCSID("$NetBSD: parse.c,v 1.193 2014/01/10 16:12:52 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -361,6 +361,7 @@
 static void ParseHasCommands(void *);
 static void ParseDoInclude(char *);
 static void ParseSetParseFile(const char *);
+static void ParseSetIncludedFile(void);
 #ifdef SYSVINCLUDE
 static void ParseTraditionalInclude(char *);
 #endif
@@ -845,7 +846,8 @@
            (void)Lst_AtEnd(cgn->parents, pgn);
     pgn->unmade += 1;
     if (DEBUG(PARSE)) {
-       fprintf(debug_file, "# ParseLinkSrc: added child %s - %s\n", pgn->name, cgn->name);
+       fprintf(debug_file, "# %s: added child %s - %s\n", __func__,
+           pgn->name, cgn->name);
        Targ_PrintNode(pgn, 0);
        Targ_PrintNode(cgn, 0);
     }
@@ -1020,8 +1022,8 @@
            (void)Lst_AtEnd(predecessor->order_succ, gn);
            (void)Lst_AtEnd(gn->order_pred, predecessor);
            if (DEBUG(PARSE)) {
-               fprintf(debug_file, "# ParseDoSrc: added Order dependency %s - %s\n",
-                       predecessor->name, gn->name);
+               fprintf(debug_file, "# %s: added Order dependency %s - %s\n",
+                   __func__, predecessor->name, gn->name);
                Targ_PrintNode(predecessor, 0);
                Targ_PrintNode(gn, 0);
            }
@@ -2164,6 +2166,7 @@
     /* load it */
     lf = loadfile(fullname, fd);
 
+    ParseSetIncludedFile();
     /* Start reading from this file next */
     Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf);
     curFile->lf = lf;
@@ -2223,6 +2226,41 @@
 
 /*-
  *---------------------------------------------------------------------
+ * ParseSetIncludedFile  --
+ *     Set the .INCLUDEDFROMFILE variable to the contents of .PARSEFILE
+ *     and the .INCLUDEDFROMDIR variable to the contents of .PARSEDIR
+ *
+ * Results:
+ *     None
+ *
+ * Side Effects:
+ *     The .INCLUDEDFROMFILE variable is overwritten by the contents
+ *     of .PARSEFILE and the .INCLUDEDFROMDIR variable is overwriten
+ *     but the contents of .PARSEDIR
+ *---------------------------------------------------------------------
+ */
+static void
+ParseSetIncludedFile(void)
+{
+    char *pf, *fp = NULL;
+    char *pd, *dp = NULL;
+
+    pf = Var_Value(".PARSEFILE", VAR_GLOBAL, &fp);
+    Var_Set(".INCLUDEDFROMFILE", pf, VAR_GLOBAL, 0);
+    pd = Var_Value(".PARSEDIR", VAR_GLOBAL, &dp);
+    Var_Set(".INCLUDEDFROMDIR", pd, VAR_GLOBAL, 0);
+
+    if (DEBUG(PARSE))
+       fprintf(debug_file, "%s: ${.INCLUDEDFROMDIR} = `%s' "
+           "${.INCLUDEDFROMFILE} = `%s'\n", __func__, pd, pf);
+
+    if (fp)
+       free(fp);
+    if (dp)
+       free(dp);
+}
+/*-
+ *---------------------------------------------------------------------
  * ParseSetParseFile  --
  *     Set the .PARSEDIR and .PARSEFILE variables to the dirname and
  *     basename of the given filename
@@ -2256,8 +2294,8 @@
        Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL, 0);
     }
     if (DEBUG(PARSE))
-       fprintf(debug_file, "ParseSetParseFile: ${.PARSEDIR} = `%s' "
-           "${.PARSEFILE} = `%s'\n", pd, pf);
+       fprintf(debug_file, "%s: ${.PARSEDIR} = `%s' ${.PARSEFILE} = `%s'\n",
+           __func__, pd, pf);
     free(dirname);
 }
 
@@ -2319,8 +2357,8 @@
        ParseTrackInput(name);
 
     if (DEBUG(PARSE))
-       fprintf(debug_file, "Parse_SetInput: file %s, line %d, fd %d, nextbuf %p, arg %p\n",
-               name, line, fd, nextbuf, arg);
+       fprintf(debug_file, "%s: file %s, line %d, fd %d, nextbuf %p, arg %p\n",
+           __func__, name, line, fd, nextbuf, arg);
 
     if (fd == -1 && nextbuf == NULL)
        /* sanity */
@@ -2392,7 +2430,7 @@
     char         *all_files;
 
     if (DEBUG(PARSE)) {
-           fprintf(debug_file, "ParseTraditionalInclude: %s\n", file);
+           fprintf(debug_file, "%s: %s\n", __func__, file);
     }
 
     /*
@@ -2451,7 +2489,7 @@
     char         *value;
 
     if (DEBUG(PARSE)) {
-           fprintf(debug_file, "ParseGmakeExport: %s\n", variable);
+           fprintf(debug_file, "%s: %s\n", __func__, variable);
     }
 
     /*
@@ -2531,6 +2569,7 @@
        /* We've run out of input */
        Var_Delete(".PARSEDIR", VAR_GLOBAL);
        Var_Delete(".PARSEFILE", VAR_GLOBAL);
+       Var_Delete(".INCLUDED_FROM", VAR_GLOBAL);
        return DONE;
     }
 



Home | Main Index | Thread Index | Old Index