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 .USEBEFORE Attribute



details:   https://anonhg.NetBSD.org/src/rev/8ef3d6009944
branches:  trunk
changeset: 512032:8ef3d6009944
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jul 03 18:08:50 2001 +0000

description:
add .USEBEFORE Attribute

diffstat:

 usr.bin/make/job.c   |   8 ++++----
 usr.bin/make/make.1  |   8 +++++++-
 usr.bin/make/make.c  |  45 ++++++++++++++++++++++++++++-----------------
 usr.bin/make/make.h  |   3 ++-
 usr.bin/make/parse.c |   7 ++++---
 usr.bin/make/targ.c  |   8 ++++----
 6 files changed, 49 insertions(+), 30 deletions(-)

diffs (264 lines):

diff -r fbdfb7d8b5c2 -r 8ef3d6009944 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Tue Jul 03 17:36:01 2001 +0000
+++ b/usr.bin/make/job.c        Tue Jul 03 18:08:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.51 2001/06/12 23:36:17 sjg Exp $     */
+/*     $NetBSD: job.c,v 1.52 2001/07/03 18:08:50 christos Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: job.c,v 1.51 2001/06/12 23:36:17 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.52 2001/07/03 18:08:50 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.51 2001/06/12 23:36:17 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.52 2001/07/03 18:08:50 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1122,7 +1122,7 @@
     int                  streamID;     /* ID of stream opened to do the touch */
     struct utimbuf times;      /* Times for utime() call */
 
-    if (gn->type & (OP_JOIN|OP_USE|OP_EXEC|OP_OPTIONAL|OP_PHONY)) {
+    if (gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC|OP_OPTIONAL|OP_PHONY)) {
        /*
         * .JOIN, .USE, .ZEROTIME and .OPTIONAL targets are "virtual" targets
         * and, as such, shouldn't really be created.
diff -r fbdfb7d8b5c2 -r 8ef3d6009944 usr.bin/make/make.1
--- a/usr.bin/make/make.1       Tue Jul 03 17:36:01 2001 +0000
+++ b/usr.bin/make/make.1       Tue Jul 03 18:08:50 2001 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.51 2001/06/10 02:31:00 sjg Exp $
+.\"    $NetBSD: make.1,v 1.52 2001/07/03 18:08:51 christos Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -1070,6 +1070,12 @@
 .Ic .USE
 target's commands are appended
 to them.
+.It Ic .USEBEFORE
+Exactly like
+.Ic .USE ,
+but prepend the 
+.Ic .USEBEFORE
+target commands to the target.
 .It Ic .WAIT
 If special
 .Ic .WAIT
diff -r fbdfb7d8b5c2 -r 8ef3d6009944 usr.bin/make/make.c
--- a/usr.bin/make/make.c       Tue Jul 03 17:36:01 2001 +0000
+++ b/usr.bin/make/make.c       Tue Jul 03 18:08:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.c,v 1.38 2001/06/12 23:36:17 sjg Exp $    */
+/*     $NetBSD: make.c,v 1.39 2001/07/03 18:08:51 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: make.c,v 1.38 2001/06/12 23:36:17 sjg Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.39 2001/07/03 18:08:51 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c     8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.38 2001/06/12 23:36:17 sjg Exp $");
+__RCSID("$NetBSD: make.c,v 1.39 2001/07/03 18:08:51 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -169,7 +169,7 @@
      * Certain types of targets needn't even be sought as their datedness
      * doesn't depend on their modification time...
      */
-    if ((gn->type & (OP_JOIN|OP_USE|OP_EXEC)) == 0) {
+    if ((gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC)) == 0) {
        (void) Dir_MTime (gn);
        if (DEBUG(MAKE)) {
            if (gn->mtime != 0) {
@@ -194,7 +194,7 @@
      * These weird rules are brought to you by Backward-Compatibility and
      * the strange people who wrote 'Make'.
      */
-    if (gn->type & OP_USE) {
+    if (gn->type & (OP_USE|OP_USEBEFORE)) {
        /*
         * If the node is a USE node it is *never* out of date
         * no matter *what*.
@@ -313,7 +313,7 @@
     GNode          *gn = (GNode *) gnp;
     Lst            l = (Lst) lp;
 
-    if ((gn->flags & REMAKE) == 0 && !(gn->type & OP_USE)) {
+    if ((gn->flags & REMAKE) == 0 && !(gn->type & (OP_USE|OP_USEBEFORE))) {
        (void)Lst_EnQueue (l, (ClientData)gn);
     }
     return (0);
@@ -378,13 +378,24 @@
 {
     register LstNode   ln;     /* An element in the children list */
 
-    if (cgn->type & (OP_USE|OP_TRANSFORM)) {
-       if ((cgn->type & OP_USE) || Lst_IsEmpty(pgn->commands)) {
-           /*
-            * .USE or transformation and target has no commands -- append
-            * the child's commands to the parent.
-            */
-           (void) Lst_Concat (pgn->commands, cgn->commands, LST_CONCNEW);
+    if (cgn->type & (OP_USE|OP_USEBEFORE|OP_TRANSFORM)) {
+       if ((cgn->type & (OP_USE|OP_USEBEFORE)) || Lst_IsEmpty(pgn->commands)) {
+           if (cgn->type & OP_USEBEFORE) {
+               /*
+                * .USEBEFORE --
+                *      prepend the child's commands to the parent.
+                */
+               Lst cmds = pgn->commands;
+               pgn->commands = Lst_Duplicate (cgn->commands, NOCOPY);
+               (void) Lst_Concat (pgn->commands, cmds, LST_CONCNEW);
+               Lst_Destroy (cmds, NOFREE);
+           } else {
+               /*
+                * .USE or target has no commands --
+                *      append the child's commands to the parent.
+                */
+               (void) Lst_Concat (pgn->commands, cgn->commands, LST_CONCNEW);
+           }
        }
 
        if (Lst_Open (cgn->children) == SUCCESS) {
@@ -418,7 +429,7 @@
            Lst_Close (cgn->children);
        }
 
-       pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_TRANSFORM);
+       pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_USEBEFORE|OP_TRANSFORM);
 
        /*
         * This child node is now "made", so we decrement the count of
@@ -427,7 +438,7 @@
         * children the parent has. This is used by Make_Run to decide
         * whether to queue the parent or examine its children...
         */
-       if ((cgn->type & OP_USE) &&
+       if ((cgn->type & (OP_USE|OP_USEBEFORE)) &&
            (ln = Lst_Member (pgn->children, (ClientData) cgn)) != NILLNODE) {
            Lst_Remove(pgn->children, ln);
            pgn->unmade--;
@@ -600,7 +611,7 @@
            if (pgn->flags & REMAKE) {
                pgn->unmade -= 1;
 
-               if ( ! (cgn->type & (OP_EXEC|OP_USE))) {
+               if ( ! (cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE))) {
                    if (cgn->made == MADE)
                        pgn->flags |= CHILDMADE;
                    (void)Make_TimeStamp (pgn, cgn);
@@ -700,7 +711,7 @@
        return (0);
     cgn->type |= OP_MARK;
 
-    if ((cgn->type & (OP_EXEC|OP_USE|OP_INVISIBLE)) == 0) {
+    if ((cgn->type & (OP_EXEC|OP_USE|OP_USEBEFORE|OP_INVISIBLE)) == 0) {
        char *child;
        char *p1 = NULL;
 
diff -r fbdfb7d8b5c2 -r 8ef3d6009944 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Tue Jul 03 17:36:01 2001 +0000
+++ b/usr.bin/make/make.h       Tue Jul 03 18:08:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.35 2001/06/09 05:22:47 sjg Exp $    */
+/*     $NetBSD: make.h,v 1.36 2001/07/03 18:08:51 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -215,6 +215,7 @@
                                     * children was out-of-date */
 #define        OP_MADE         0x00000800  /* Assume the node is already made; even if
                                     * it really is out of date */
+#define        OP_USEBEFORE    0x00002000  /* Like .USE, only prepend commands */
 #define OP_INVISIBLE   0x00004000  /* The node is invisible to its parents.
                                     * I.e. it doesn't show up in the parents's
                                     * local variables. */
diff -r fbdfb7d8b5c2 -r 8ef3d6009944 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Tue Jul 03 17:36:01 2001 +0000
+++ b/usr.bin/make/parse.c      Tue Jul 03 18:08:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.70 2001/06/12 23:36:18 sjg Exp $   */
+/*     $NetBSD: parse.c,v 1.71 2001/07/03 18:08:51 christos Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: parse.c,v 1.70 2001/06/12 23:36:18 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.71 2001/07/03 18:08:51 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.70 2001/06/12 23:36:18 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.71 2001/07/03 18:08:51 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -246,6 +246,7 @@
 { ".SINGLESHELL", SingleShell, 0 },
 { ".SUFFIXES",   Suffixes,     0 },
 { ".USE",        Attribute,    OP_USE },
+{ ".USEBEFORE",   Attribute,           OP_USEBEFORE },
 { ".WAIT",       Wait,         0 },
 };
 
diff -r fbdfb7d8b5c2 -r 8ef3d6009944 usr.bin/make/targ.c
--- a/usr.bin/make/targ.c       Tue Jul 03 17:36:01 2001 +0000
+++ b/usr.bin/make/targ.c       Tue Jul 03 18:08:50 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: targ.c,v 1.21 2001/01/14 05:34:06 christos Exp $       */
+/*     $NetBSD: targ.c,v 1.22 2001/07/03 18:08:51 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: targ.c,v 1.21 2001/01/14 05:34:06 christos Exp $";
+static char rcsid[] = "$NetBSD: targ.c,v 1.22 2001/07/03 18:08:51 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)targ.c     8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: targ.c,v 1.21 2001/01/14 05:34:06 christos Exp $");
+__RCSID("$NetBSD: targ.c,v 1.22 2001/07/03 18:08:51 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -588,7 +588,7 @@
            } else {
                printf("# No unmade children\n");
            }
-           if (! (gn->type & (OP_JOIN|OP_USE|OP_EXEC))) {
+           if (! (gn->type & (OP_JOIN|OP_USE|OP_USEBEFORE|OP_EXEC))) {
                if (gn->mtime != 0) {
                    printf("# last modified %s: %s\n",
                              Targ_FmtTime(gn->mtime),



Home | Main Index | Thread Index | Old Index