* Reworked function.c to use separate functions instead of a huge case stmt.

* Added new functions $(error ...) and $(warning ...) and documented same.
* In windows/dos shells, only treat \ as an escape for special chars.
This commit is contained in:
Paul Smith 1999-03-26 04:04:42 +00:00
parent 8363e0496d
commit c4353af3f9
5 changed files with 1686 additions and 1272 deletions

View File

@ -1,3 +1,31 @@
1999-03-22 Paul D. Smith <psmith@gnu.org>
* make.texinfo (Functions): Add a new section documenting the new
$(error ...) and $(warning ...) functions. Also updated copyright
dates.
* NEWS: Updated for the new functions.
* function.c (func_error): Implement the new $(error ...) and
$(warning ...) functions.
(function_table): Insert new functions into the table.
(func_firstword): Don't call find_next_token() with argv[0]
itself, since that function modifies the pointer.
* function.c: Cleanups and slight changes to the new method of
calling functions.
1999-03-20 Han-Wen Nienhuys <hanwen@cs.uu.nl>
* function.c: Rewrite to use one C function per make function,
instead of a huge switch statement. Also allows some cleanup of
multi-architecture issues.
1999-03-19 Eli Zaretskii <eliz@is.elta.co.il>
1999-03-19 Rob Tulloh <rob_tulloh@dev.tivoli.com>
* job.c (construct_command_argv_internal): Don't treat _all_
backslashes as escapes, only those which really escape a special
character. This allows most normal "\" directory separators to be
treated normally.
1999-03-05 Paul D. Smith <psmith@gnu.org>
* configure.in: Check for a system strdup().
@ -17,7 +45,7 @@
1999-03-04 Paul D. Smith <psmith@gnu.org>
* amiga.c, amiga.h, ar.c, arscan.c, commands.c, commands.h,
* default.c, dep.h, dir.c, expand.c, file.c, filedef.h, functions.c,
* default.c, dep.h, dir.c, expand.c, file.c, filedef.h, function.c,
* implicit.c, job.c, job.h, main.c, make.h, misc.c, read.c, remake.c
* remote-cstms.c, remote-stub.c, rule.h, variable.c, variable.h,
* vpath.c, Makefile.ami, NMakefile.template, build.template,

8
NEWS
View File

@ -1,6 +1,6 @@
GNU make NEWS -*-indented-text-*-
History of user-visible changes.
22 Feb 1999
22 Mar 1999
Copyright (C) 1992,93,94,95,96,97,98,1999 Free Software Foundation, Inc.
See the end for copying conditions.
@ -12,6 +12,12 @@ Please send GNU make bug reports to bug-make@gnu.org.
Version 3.78
* Two new functions, $(error ...) and $(warning ...) are provided. The
former will cause make to fail and exit immediately upon expansion of
the function, with the text provided as the error message. The latter
causes the text provided to be printed as a warning message, but make
proceeds normally.
* Make defines a new variable, .LIBPATTERNS. This variable controls how
the link library dependency expansion (dependencies like ``-lfoo'') is
performed.

2822
function.c

File diff suppressed because it is too large Load Diff

31
job.c
View File

@ -2030,8 +2030,35 @@ construct_command_argv_internal (line, restp, shell, ifs, batch_filename_ptr)
}
}
else if (p[1] != '\0')
/* Copy and skip the following char. */
*ap++ = *++p;
{
#if defined(__MSDOS__) || defined(WINDOWS32)
/* Only remove backslashes before characters special
to Unixy shells. All other backslashes are copied
verbatim, since they are probably DOS-style
directory separators. This still leaves a small
window for problems, but at least it should work
for the vast majority of naive users. */
#ifdef __MSDOS__
/* A dot is only special as part of the "..."
wildcard. */
if (strncmp (p + 1, ".\\.\\.", 5) == 0)
{
*ap++ = '.';
*ap++ = '.';
p += 4;
}
else
#endif
if (p[1] != '\\' && p[1] != '\'' && !isspace (p[1])
&& (index (sh_chars_sh, p[1]) == 0))
/* back up one notch, to copy the backslash */
--p;
#endif /* __MSDOS__ || WINDOWS32 */
/* Copy and skip the following char. */
*ap++ = *++p;
}
break;
case '\'':

View File

@ -8,10 +8,10 @@
@c FSF publishers: format makebook.texi instead of using this file directly.
@set RCSID $Id$
@set EDITION 0.52
@set VERSION 3.77
@set UPDATED 20 May 1998
@set UPDATE-MONTH May 1998
@set EDITION 0.53
@set VERSION 3.78
@set UPDATED 22 March 1999
@set UPDATE-MONTH March 1999
@comment The ISBN number might need to change on next publication.
@set ISBN 1-882114-80-9 @c CHANGE THIS BEFORE PRINTING AGAIN! --psmith 16jul98
@ -37,7 +37,7 @@ and issues the commands to recompile them.
This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU Make Manual}, for @code{make}, Version @value{VERSION}.
Copyright (C) 1988, '89, '90, '91, '92, '93, '94, '95, '96, '97, '98
Copyright (C) 1988, '89, '90, '91, '92, '93, '94, '95, '96, '97, '98, '99
Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
@ -5166,6 +5166,7 @@ call, just as a variable might be substituted.
* Foreach Function:: Repeat some text with controlled variation.
* Origin Function:: Find where a variable got its value.
* Shell Function:: Substitute the output of a shell command.
* Make Control Functions:: Functions that control how make runs.
@end menu
@node Syntax of Functions, Text Functions, , Functions
@ -5907,7 +5908,7 @@ Here the redefinition takes place if @samp{$(origin bletch)} returns either
@samp{environment} or @samp{environment override}.
@xref{Text Functions, , Functions for String Substitution and Analysis}.
@node Shell Function, , Origin Function, Functions
@node Shell Function, Make Control Functions, Origin Function, Functions
@section The @code{shell} Function
@findex shell
@cindex commands, expansion
@ -5953,6 +5954,60 @@ sets @code{files} to the expansion of @samp{*.c}. Unless @code{make} is
using a very strange shell, this has the same result as
@w{@samp{$(wildcard *.c)}}.@refill
@node Make Control Functions, , Shell Function, Functions
@section Functions That Control Make
@cindex functions, for controlling make
@cindex controlling make
These functions control the way make runs. Generally, they are used to
provide information to the user of the makefile or to cause make to stop
if some sort of environmental error is detected.
@table @code
@item $(error @var{text}@dots{})
@findex error
@cindex error, stopping on
@cindex stopping make
Generates a fatal error where the message is @var{text}. Note that the
error is generated whenever this function is evaluated. So, if you put
it inside a command script or on the right side of a recursive variable
assignment, it won't be evaluated until later. The @var{text} will be
expanded before the error is generated.
For example,
@example
ifdef ERROR1
$(error error is $(ERROR1))
endif
@end example
@noindent
will generate a fatal error during the read of the makefile if the
@code{make} variable @code{ERROR1} is defined. Or,
@example
ERR = $(error found an error!)
.PHONY: err
err: ; $(ERR)
@end example
@noindent
will generate a fatal error while @code{make} is running, if the
@code{err} target is invoked.
@item $(warning @var{text}@dots{})
@findex warning
@cindex warnings, printing
@cindex printing user warnings
This function works similarly to the @code{error} function, above,
except that @code{make} doesn't exit. Instead, @var{text} is expanded
and the resulting message is displayed, but processing of the makefile
continues.
The result of the expansion of this function is the empty string.
@node Running, Implicit Rules, Functions, Top
@chapter How to Run @code{make}