summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/make/make.145
-rw-r--r--usr.bin/make/parse.c36
2 files changed, 60 insertions, 21 deletions
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 1b997ab..89a1e3f 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
-.\" $Id: make.1,v 1.10 1997/03/09 15:50:58 wosch Exp $
+.\" $Id: make.1,v 1.11 1997/07/24 06:58:07 charnier Exp $
.\"
.Dd March 19, 1994
.Dt MAKE 1
@@ -551,35 +551,40 @@ is the substring of
to be replaced in
.Ar new_string
.El
-.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
-Makefile inclusion, conditional structures and for loops reminiscent
+.Sh DIRECTIVES, CONDITIONALS AND FOR LOOPS
+Directives, conditionals and for loops reminiscent
of the C programming language are provided in
.Nm make .
All such structures are identified by a line beginning with a single
dot
.Pq Ql \&.
-character.
-Files are included with either
-.Ql .include <file>
-or
-.Ql .include \*qfile\*q .
-Variables between the angle brackets or double quotes are expanded
-to form the file name.
-If angle brackets are used, the included makefile is expected to be in
-the system makefile directory.
-If double quotes are used, the including makefile's directory and any
-directories specified using the
+character. The following directives are supported:
+.Bl -tag -width Ds
+.It Ic \&.include Ar <file>
+.It Ic \&.include Ar \*qfile\*q
+Include the specified makefile. Variables between the angle brackets
+or double quotes are expanded to form the file name. If angle brackets
+are used, the included makefile is expected to be in the system
+makefile directory. If double quotes are used, the including
+makefile's directory and any directories specified using the
.Fl I
option are searched before the system
makefile directory.
-.Pp
-Conditional expressions are also preceded by a single dot as the first
-character of a line.
-The possible conditionals are as follows:
-.Bl -tag -width Ds
-.It Ic .undef Ar variable
+.It Ic \&.undef Ar variable
Un-define the specified global variable.
Only global variables may be un-defined.
+.It Ic \&.error Ar message
+Terminate processing of the makefile immediately. The filename of the
+makefile, the line on which the error was encountered and the specified
+message are printed to standard output and
+.Nm make
+terminates with exit code 1. Variables in the message are expanded.
+.El
+.Pp
+Conditionals are used to determine which parts of the Makefile
+to process. They are used similarly to the conditionals supported
+by the C pre-processor. The following conditionals are supported:
+.Bl -tag -width Ds
.It Xo
.Ic \&.if
.Oo \&! Oc Ns Ar expression
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 448aa96..388fa07 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -41,7 +41,7 @@
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#endif
static const char rcsid[] =
- "$Id$";
+ "$Id: parse.c,v 1.18 1997/07/24 06:58:08 charnier Exp $";
#endif /* not lint */
/*-
@@ -251,6 +251,7 @@ static int ParseReadc __P((void));
static void ParseUnreadc __P((int));
static void ParseHasCommands __P((ClientData));
static void ParseDoInclude __P((char *));
+static void ParseDoError __P((char *));
#ifdef SYSVINCLUDE
static void ParseTraditionalInclude __P((char *));
#endif
@@ -1552,6 +1553,35 @@ Parse_AddIncludeDir (dir)
Dir_AddDir (parseIncPath, dir);
}
+/*---------------------------------------------------------------------
+ * ParseDoError --
+ * Handle error directive
+ *
+ * The input is the line minus the ".error". We substitute variables,
+ * print the message and exit(1) or just print a warning if the ".error"
+ * directive is malformed.
+ *
+ *---------------------------------------------------------------------
+ */
+static void
+ParseDoError(errmsg)
+ char *errmsg; /* error message */
+{
+ if (!isspace(*errmsg)) {
+ Parse_Error(PARSE_WARNING, "invalid syntax: .error%s", errmsg);
+ return;
+ }
+
+ while (isspace(*errmsg))
+ errmsg++;
+
+ errmsg = Var_Subst(NULL, errmsg, VAR_GLOBAL, FALSE);
+
+ /* use fprintf/exit instead of Parse_Error to terminate immediately */
+ fprintf(stderr, "\"%s\", line %d: %s\n", fname, lineno, errmsg);
+ exit(1);
+}
+
/*-
*---------------------------------------------------------------------
* ParseDoInclude --
@@ -1734,6 +1764,7 @@ ParseDoInclude (file)
}
+
/*-
*---------------------------------------------------------------------
* Parse_FromString --
@@ -2385,6 +2416,9 @@ Parse_File(name, stream)
if (strncmp (cp, "include", 7) == 0) {
ParseDoInclude (cp + 7);
goto nextLine;
+ } else if (strncmp (cp, "error", 5) == 0) {
+ ParseDoError(cp + 5);
+ goto nextLine;
} else if (strncmp(cp, "undef", 5) == 0) {
char *cp2;
for (cp += 5; isspace((unsigned char) *cp); cp++) {
OpenPOWER on IntegriCloud