From owner-freebsd-bugs Fri May 22 05:44:54 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id FAA13386 for freebsd-bugs-outgoing; Fri, 22 May 1998 05:44:54 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA13377 for ; Fri, 22 May 1998 05:44:52 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id FAA23557; Fri, 22 May 1998 05:40:01 -0700 (PDT) Received: from www.in-design.com (www.in-design.com [206.210.93.16]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id FAA12075 for ; Fri, 22 May 1998 05:36:12 -0700 (PDT) (envelope-from nsmart@www.in-design.com) Received: (from nsmart@localhost) by www.in-design.com (8.8.7/8.8.5) id IAA09770; Fri, 22 May 1998 08:36:04 -0400 (EDT) Message-Id: <199805221236.IAA09770@www.in-design.com> Date: Fri, 22 May 1998 08:36:04 -0400 (EDT) From: njs3@doc.ic.ac.uk Reply-To: njs3@doc.ic.ac.uk To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/6720: [PATCH] make(1) cannot terminate gracefully under user request Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 6720 >Category: bin >Synopsis: [PATCH] make(1) cannot terminate gracefully under user request >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: doc-bug >Submitter-Id: current-users >Arrival-Date: Fri May 22 05:40:01 PDT 1998 >Last-Modified: >Originator: Niall Smart, njs3@doc.ic.ac.uk >Organization: >Release: FreeBSD 2.2.5-RELEASE i386 >Environment: >Description: Complex makefiles may wish to report an error to the user under certain circumstances, e.g. if the user has not specified a variable on the command line, this cannot currently be achieved elegantly. The supplied patch adds an ".error" directive which immediately terminates processing of the makefile and prints a supplied error message >How-To-Repeat: >Fix: *** parse.c~ Fri May 22 12:35:07 1998 --- parse.c Tue May 19 12:24:45 1998 *************** *** 251,256 **** --- 249,255 ---- 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,1557 **** --- 1551,1585 ---- 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,1739 **** --- 1762,1768 ---- } + /*- *--------------------------------------------------------------------- * Parse_FromString -- *************** *** 2385,2390 **** --- 2414,2422 ---- 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++) { *** make.1~ Fri May 22 12:35:10 1998 --- make.1 Tue May 19 13:08:18 1998 *************** *** 551,585 **** to be replaced in .Ar new_string .El ! .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS ! Makefile inclusion, conditional structures 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 ! 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 .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 Un-define the specified global variable. Only global variables may be un-defined. .It Xo .Ic \&.if .Oo \&! Oc Ns Ar expression --- 551,590 ---- to be replaced in .Ar new_string .El ! .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. The following directives are supported: ! .Bl -tag -width Ds ! .It Ic \&.include Ar ! .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. ! .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 >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message