Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make PR/11800: Chris Demetriou: Add -W flag to exit ...



details:   https://anonhg.NetBSD.org/src/rev/53e41269bef9
branches:  trunk
changeset: 502013:53e41269bef9
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 10 15:54:00 2001 +0000

description:
PR/11800: Chris Demetriou: Add -W flag to exit on parse warnings.
While I am here, s/make:.*"/%s:\1", progname/

diffstat:

 usr.bin/make/job.c   |  16 +++++++------
 usr.bin/make/main.c  |  59 +++++++++++++++++++++++++++++++--------------------
 usr.bin/make/make.1  |   6 +++-
 usr.bin/make/make.h  |   7 +++++-
 usr.bin/make/parse.c |  22 ++++++++++++++-----
 5 files changed, 71 insertions(+), 39 deletions(-)

diffs (truncated from 376 to 300 lines):

diff -r b7998ed03f2a -r 53e41269bef9 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Wed Jan 10 15:50:20 2001 +0000
+++ b/usr.bin/make/job.c        Wed Jan 10 15:54:00 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.45 2001/01/01 15:47:38 sommerfeld Exp $      */
+/*     $NetBSD: job.c,v 1.46 2001/01/10 15:54:00 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.45 2001/01/01 15:47:38 sommerfeld Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.46 2001/01/10 15:54:00 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.45 2001/01/01 15:47:38 sommerfeld Exp $");
+__RCSID("$NetBSD: job.c,v 1.46 2001/01/10 15:54:00 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1186,17 +1186,19 @@
             * given, we stop in our tracks, otherwise we just don't update
             * this node's parents so they never get examined.
             */
-           static const char msg[] = "make: don't know how to make";
+           static const char msg[] = ": don't know how to make";
 
            if (gn->type & OP_OPTIONAL) {
-               (void) fprintf(stdout, "%s %s(ignored)\n", msg, gn->name);
+               (void) fprintf(stdout, "%s%s %s(ignored)\n", progname,
+                   msg, gn->name);
                (void) fflush(stdout);
            } else if (keepgoing) {
-               (void) fprintf(stdout, "%s %s(continuing)\n", msg, gn->name);
+               (void) fprintf(stdout, "%s%s %s(continuing)\n", progname,
+                   msg, gn->name);
                (void) fflush(stdout);
                return FALSE;
            } else {
-               (*abortProc)("%s %s. Stop", msg, gn->name);
+               (*abortProc)("%s%s %s. Stop", progname, msg, gn->name);
                return FALSE;
            }
        }
diff -r b7998ed03f2a -r 53e41269bef9 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Wed Jan 10 15:50:20 2001 +0000
+++ b/usr.bin/make/main.c       Wed Jan 10 15:54:00 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.62 2001/01/07 06:16:02 sjg Exp $    */
+/*     $NetBSD: main.c,v 1.63 2001/01/10 15:54:00 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,7 +39,7 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: main.c,v 1.62 2001/01/07 06:16:02 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.63 2001/01/10 15:54:00 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -51,7 +51,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.62 2001/01/07 06:16:02 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.63 2001/01/10 15:54:00 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -137,6 +137,7 @@
 Boolean                        beSilent;       /* -s flag */
 Boolean                        oldVars;        /* variable substitution style */
 Boolean                        checkEnvFirst;  /* -e flag */
+Boolean                        parseWarnFatal; /* -W flag */
 Boolean                        jobServer;      /* -J flag */
 static Boolean         jobsRunning;    /* TRUE if the jobs might be running */
 static const char *    tracefile;
@@ -148,10 +149,12 @@
 
 static char *curdir;                   /* startup directory */
 static char *objdir;                   /* where we chdir'ed to */
-static char *progname;                 /* the program name */
+char *progname;                                /* the program name */
 
 Boolean forceJobs = FALSE;
 
+extern Lst parseIncPath;
+
 /*-
  * MainParseArgs --
  *     Parse a given argument vector. Called from main() and from
@@ -194,15 +197,17 @@
                        break;
                case 'J':
                        if (sscanf(optarg, "%d,%d", &job_pipe[0], &job_pipe[1]) != 2) {
-                               (void)fprintf(stderr,
-                                   "make: internal error -- J option malformed (%s??)\n", optarg);
+                           (void)fprintf(stderr,
+                               "%s: internal error -- J option malformed (%s??)\n",
+                               progname, optarg);
                                usage();
                        }
                        if ((fcntl(job_pipe[0], F_GETFD, 0) < 0) ||
                            (fcntl(job_pipe[1], F_GETFD, 0) < 0)) {
 #if 0
                            (void)fprintf(stderr,
-                             "make: warning -- J descriptors were closed!\n");
+                               "%s: warning -- J descriptors were closed!\n",
+                               progname);
 #endif
                            job_pipe[0] = -1;
                            job_pipe[1] = -1;
@@ -226,8 +231,9 @@
                case 'L':
                        maxLocal = strtol(optarg, &p, 0);
                        if (*p != '\0' || maxLocal < 1) {
-                               (void) fprintf(stderr, "make: illegal argument to -L -- must be positive integer!\n");
-                               exit(1);
+                           (void) fprintf(stderr, "%s: illegal argument to -L -- must be positive integer!\n",
+                               progname);
+                           exit(1);
                        }
                        Var_Append(MAKEFLAGS, "-L", VAR_GLOBAL);
                        Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
@@ -251,6 +257,9 @@
                        Var_Append(MAKEFLAGS, "-T", VAR_GLOBAL);
                        Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL);
                        break;
+               case 'W':
+                       parseWarnFatal = TRUE;
+                       break;
                case 'd': {
                        char *modules = optarg;
 
@@ -298,8 +307,8 @@
                                        break;
                                default:
                                        (void)fprintf(stderr,
-                               "make: illegal argument to d option -- %c\n",
-                                           *modules);
+                               "%s: illegal argument to d option -- %c\n",
+                                           progname, *modules);
                                        usage();
                                }
                        Var_Append(MAKEFLAGS, "-d", VAR_GLOBAL);
@@ -321,7 +330,8 @@
                        forceJobs = TRUE;
                        maxJobs = strtol(optarg, &p, 0);
                        if (*p != '\0' || maxJobs < 1) {
-                               (void) fprintf(stderr, "make: illegal argument to -j -- must be positive integer!\n");
+                               (void) fprintf(stderr, "%s: illegal argument to -j -- must be positive integer!\n",
+                                   progname);
                                exit(1);
                        }
 #ifndef REMOTE
@@ -528,13 +538,13 @@
         */
        curdir = cdpath;
        if (getcwd(curdir, MAXPATHLEN) == NULL) {
-               (void)fprintf(stderr, "make: %s.\n", strerror(errno));
+               (void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
                exit(2);
        }
 
        if (stat(curdir, &sa) == -1) {
-           (void)fprintf(stderr, "make: %s: %s.\n",
-                         curdir, strerror(errno));
+           (void)fprintf(stderr, "%s: %s: %s.\n",
+                progname, curdir, strerror(errno));
            exit(2);
        }
 
@@ -567,8 +577,9 @@
            struct utsname utsname;
 
            if (uname(&utsname) == -1) {
-                   perror("make: uname");
-                   exit(2);
+               (void)fprintf(stderr, "%s: uname failed (%s).\n", progname,
+                   strerror(errno));
+               exit(2);
            }
            machine = utsname.machine;
 #else
@@ -778,10 +789,12 @@
                sysMkPath = Lst_Init (FALSE);
                Dir_Expand (_PATH_DEFSYSMK, sysIncPath, sysMkPath);
                if (Lst_IsEmpty(sysMkPath))
-                       Fatal("make: no system rules (%s).", _PATH_DEFSYSMK);
+                       Fatal("%s: no system rules (%s).", progname,
+                           _PATH_DEFSYSMK);
                ln = Lst_Find(sysMkPath, (ClientData)NULL, ReadMakefile);
                if (ln != NILLNODE)
-                       Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
+                       Fatal("%s: cannot open %s.", progname,
+                           (char *)Lst_Datum(ln));
        }
 
        if (!Lst_IsEmpty(makefiles)) {
@@ -789,7 +802,8 @@
 
                ln = Lst_Find(makefiles, (ClientData)NULL, ReadMakefile);
                if (ln != NILLNODE)
-                       Fatal("make: cannot open %s.", (char *)Lst_Datum(ln));
+                       Fatal("%s: cannot open %s.", progname, 
+                           (char *)Lst_Datum(ln));
        } else if (!ReadMakefile("makefile", NULL))
                (void)ReadMakefile("Makefile", NULL);
 
@@ -957,7 +971,6 @@
        ClientData p, q;
 {
        char *fname = p;                /* makefile to read */
-       extern Lst parseIncPath;
        FILE *stream;
        size_t len = MAXPATHLEN;
        char *name, *path = emalloc(len);
@@ -1429,7 +1442,7 @@
        fmt = va_arg(ap, char *);
 #endif
 
-       (void)fprintf(stderr, "make: ");
+       (void)fprintf(stderr, "%s: ", progname);
        (void)vfprintf(stderr, fmt, ap);
        va_end(ap);
        (void)fprintf(stderr, "\n");
@@ -1528,7 +1541,7 @@
 void
 enomem()
 {
-       (void)fprintf(stderr, "make: %s.\n", strerror(errno));
+       (void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno));
        exit(2);
 }
 
diff -r b7998ed03f2a -r 53e41269bef9 usr.bin/make/make.1
--- a/usr.bin/make/make.1       Wed Jan 10 15:50:20 2001 +0000
+++ b/usr.bin/make/make.1       Wed Jan 10 15:54:00 2001 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.45 2001/01/01 15:47:38 sommerfeld Exp $
+.\"    $NetBSD: make.1,v 1.46 2001/01/10 15:54:00 christos Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -41,7 +41,7 @@
 .Nd maintain program dependencies
 .Sh SYNOPSIS
 .Nm ""
-.Op Fl BeikNnqrst
+.Op Fl BeikNnqrstW
 .Bk -words
 .Op Fl D Ar variable
 .Ek
@@ -225,6 +225,8 @@
 Multiple instances of this option may be specified;
 the variables will be printed one per line,
 with a blank line for each null or undefined variable.
+.It Fl W
+Treat any warnings during makefile parsing as errors.
 .It Ar variable=value
 Set the value of the variable
 .Ar variable
diff -r b7998ed03f2a -r 53e41269bef9 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Wed Jan 10 15:50:20 2001 +0000
+++ b/usr.bin/make/make.h       Wed Jan 10 15:54:00 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.31 2001/01/01 15:50:23 sommerfeld Exp $     */
+/*     $NetBSD: make.h,v 1.32 2001/01/10 15:54:00 christos Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -341,6 +341,9 @@
                                 * variables before the global context */
 extern Boolean jobServer;      /* a jobServer already exists */
 
+extern Boolean parseWarnFatal; /* TRUE if makefile parsing warnings are
+                                * treated as errors */
+
 extern GNode    *DEFAULT;      /* .DEFAULT rule */
 
 extern GNode    *VAR_GLOBAL;           /* Variables defined in a global context, e.g
@@ -359,6 +362,8 @@
 
 extern Lst     sysIncPath;     /* The system include path. */
 
+extern char    *progname;      /* The program name */
+
 #define        MAKEFLAGS       ".MAKEFLAGS"
 
 /*
diff -r b7998ed03f2a -r 53e41269bef9 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Wed Jan 10 15:50:20 2001 +0000



Home | Main Index | Thread Index | Old Index