This is Edition @value{EDITION}, last updated @value{UPDATED},
of @cite{The GNU Make Manual}, for GNU @code{make} version @value{VERSION}.
-Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
-1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007
+Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
+1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
@quotation
license is included in the section entitled ``GNU Free Documentation
License.''
-(a) The FSF's Back-Cover Text is: ``You are free to copy and modify
-this GNU Manual. Buying copies from GNU Press supports the FSF in
+(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
+modify this GNU manual. Buying copies from the FSF supports it in
developing GNU and promoting software freedom.''
@end quotation
@end copying
* Errors:: What happens after a recipe execution error.
* Interrupts:: What happens when a recipe is interrupted.
* Recursion:: Invoking @code{make} from makefiles.
-* Sequences:: Defining canned recipes.
+* Canned Recipes:: Defining canned recipes.
* Empty Recipes:: Defining useful, do-nothing recipes.
Recipe Syntax
of a variable.
* Override Directive:: How to set a variable in the makefile even if
the user has set it with a command argument.
-* Defining:: An alternate way to set a variable
- to a verbatim string.
+* Multi-Line:: An alternate way to set a variable
+ to a multi-line string.
* Environment:: Variable values can come from the environment.
* Target-specific:: Variable values can be defined on a per-target
basis.
@item
Defining a variable from a verbatim string containing multiple lines
-(@pxref{Defining, ,Defining Variables Verbatim}).
+(@pxref{Multi-Line, ,Defining Multi-Line Variables}).
@end itemize
@cindex comments, in makefile
a makefile is not always necessary.@refill
When you use the @samp{-t} or @samp{--touch} option
-(@pxref{Instead of Execution, ,Instead of Executing the Recipe}),
+(@pxref{Instead of Execution, ,Instead of Executing Recipes}),
you would not want to use an out-of-date makefile to decide which
targets to touch. So the @samp{-t} option has no effect on updating
makefiles; they are really updated even if @samp{-t} is specified.
define @var{immediate}
@var{deferred}
endef
+
+define @var{immediate} =
+ @var{deferred}
+endef
+
+define @var{immediate} ?=
+ @var{deferred}
+endef
+
+define @var{immediate} :=
+ @var{immediate}
+endef
+
+define @var{immediate} +=
+ @var{deferred} or @var{immediate}
+endef
@end example
For the append operator, @samp{+=}, the right-hand side is considered
* Errors:: What happens after a recipe execution error.
* Interrupts:: What happens when a recipe is interrupted.
* Recursion:: Invoking @code{make} from makefiles.
-* Sequences:: Defining canned recipes.
+* Canned Recipes:: Defining canned recipes.
* Empty Recipes:: Defining useful, do-nothing recipes.
@end menu
@cindex @code{--just-print}
@cindex @code{--dry-run}
@cindex @code{--recon}
-When @code{make} is given the flag @samp{-n} or @samp{--just-print}
-it only echoes recipes, it won't execute them. @xref{Options Summary,
-,Summary of Options}. In this case and only this case, even the
-recipe lines starting with @samp{@@} are printed. This flag is useful for
-finding out which recipes @code{make} thinks are necessary without
-actually doing them.
+When @code{make} is given the flag @samp{-n} or @samp{--just-print} it
+only echoes most recipes, without executing them. @xref{Options
+Summary, ,Summary of Options}. In this case even the recipe lines
+starting with @samp{@@} are printed. This flag is useful for finding
+out which recipes @code{make} thinks are necessary without actually
+doing them.
@cindex @code{-s}
@cindex @code{--silent}
modification-time (its contents do not matter), or must exist at all
times to prevent other sorts of trouble.
-@node Recursion, Sequences, Interrupts, Recipes
+@node Recursion, Canned Recipes, Interrupts, Recipes
@section Recursive Use of @code{make}
@cindex recursion
@cindex subdirectories, recursion for
parent @code{make} and all the sub-@code{make}s will communicate to
ensure that there are only @samp{N} jobs running at the same time
between them all. Note that any job that is marked recursive
-(@pxref{Instead of Execution, ,Instead of Executing the Recipes})
+(@pxref{Instead of Execution, ,Instead of Executing Recipes})
doesn't count against the total jobs (otherwise we could get @samp{N}
sub-@code{make}s running and have no slots left over for any real work!)
be silent, or if you use @samp{--no-print-directory} to explicitly
disable it.
-@node Sequences, Empty Recipes, Recursion, Recipes
+@node Canned Recipes, Empty Recipes, Recursion, Recipes
@section Defining Canned Recipes
@cindex canned recipes
@cindex recipes, canned
targets. The canned sequence is actually a variable, so the name must
not conflict with other variable names.
-Here is an example of defining a canned recipes:
+Here is an example of defining a canned recipe:
@example
-define run-yacc
+define run-yacc =
yacc $(firstword $^)
mv y.tab.c $@@
endef
and function calls in the canned sequence; the @samp{$} characters,
parentheses, variable names, and so on, all become part of the value of the
variable you are defining.
-@xref{Defining, ,Defining Variables Verbatim},
+@xref{Multi-Line, ,Defining Multi-Line Variables},
for a complete explanation of @code{define}.
The first command in this example runs Yacc on the first prerequisite of
For example, using this canned sequence:
@example
-define frobnicate
+define frobnicate =
@@echo "frobnicating target $@@"
frob-step-1 $< -o $@@-step-1
frob-step-2 $@@-step-1 -o $@@
does not echo @emph{any} recipe lines.
(@xref{Echoing, ,Recipe Echoing}, for a full explanation of @samp{@@}.)
-@node Empty Recipes, , Sequences, Recipes
+@node Empty Recipes, , Canned Recipes, Recipes
@section Using Empty Recipes
@cindex empty recipes
@cindex recipes, empty
of a variable.
* Override Directive:: How to set a variable in the makefile even if
the user has set it with a command argument.
-* Defining:: An alternate way to set a variable
- to a verbatim string.
+* Multi-Line:: An alternate way to set a variable
+ to a multi-line string.
* Environment:: Variable values can come from the environment.
* Target-specific:: Variable values can be defined on a per-target
basis.
The first flavor of variable is a @dfn{recursively expanded} variable.
Variables of this sort are defined by lines using @samp{=}
(@pxref{Setting, ,Setting Variables}) or by the @code{define} directive
-(@pxref{Defining, ,Defining Variables Verbatim}). The value you specify
+(@pxref{Multi-Line, ,Defining Multi-Line Variables}). The value you specify
is installed verbatim; if it contains references to other variables,
these references are expanded whenever this variable is substituted (in
the course of expanding some other string). When this happens, it is
@example
dir = foo
$(dir)_sources := $(wildcard $(dir)/*.c)
-define $(dir)_print
+define $(dir)_print =
lpr $($(dir)_sources)
endef
@end example
@item
You can specify a value in the makefile, either
with an assignment (@pxref{Setting, ,Setting Variables}) or with a
-verbatim definition (@pxref{Defining, ,Defining Variables Verbatim}).@refill
+verbatim definition (@pxref{Multi-Line, ,Defining Multi-Line Variables}).@refill
@item
Variables in the environment become @code{make} variables.
any later point, a reference like @samp{$(CFLAGS)} still uses its
value.
-@node Override Directive, Defining, Appending, Using Variables
+@node Override Directive, Multi-Line, Appending, Using Variables
@section The @code{override} Directive
@findex override
@cindex overriding with @code{override}
@noindent
@xref{Appending, ,Appending More Text to Variables}.
+Variable assignments marked with the @code{override} flag have a
+higher priority than all other assignments, except another
+@code{override}. Subsequent assignments or appends to this variable
+which are not marked @code{override} will be ignored.
+
The @code{override} directive was not invented for escalation in the war
between makefiles and command arguments. It was invented so you can alter
and add to values that the user specifies with command arguments.
This is done as you might expect:
@example
-override define foo
+override define foo =
bar
endef
@end example
See the next section for information about @code{define}.
@end iftex
@ifnottex
-@xref{Defining, ,Defining Variables Verbatim}.
+@xref{Multi-Line, ,Defining Multi-Line Variables}.
@end ifnottex
-@node Defining, Environment, Override Directive, Using Variables
-@section Defining Variables Verbatim
+@node Multi-Line, Environment, Override Directive, Using Variables
+@section Defining Multi-Line Variables
@findex define
@findex endef
+@cindex multi-line variable definition
+@cindex variables, multi-line
@cindex verbatim variable definition
@cindex defining variables verbatim
@cindex variables, defining verbatim
Another way to set the value of a variable is to use the @code{define}
directive. This directive has an unusual syntax which allows newline
-characters to be included in the value, which is convenient for defining
-both canned sequences of commands
-(@pxref{Sequences, ,Defining Canned Command Sequences}), and also
-sections of makefile syntax to use with @code{eval} (@pxref{Eval Function}).
-
-The @code{define} directive is followed on the same line by the name of the
-variable and nothing more. The value to give the variable appears on the
-following lines. The end of the value is marked by a line containing just
-the word @code{endef}. Aside from this difference in syntax, @code{define}
-works just like @samp{=}: it creates a recursively-expanded variable
-(@pxref{Flavors, ,The Two Flavors of Variables}).
-The variable name may contain function and variable references, which
-are expanded when the directive is read to find the actual variable name
+characters to be included in the value, which is convenient for
+defining both canned sequences of commands (@pxref{Canned Recipes,
+,Defining Canned Recipes}), and also sections of makefile syntax to
+use with @code{eval} (@pxref{Eval Function}).@refill
+
+The @code{define} directive is followed on the same line by the name
+of the variable being defined and an (optional) assignment operator,
+and nothing more. The value to give the variable appears on the
+following lines. The end of the value is marked by a line containing
+just the word @code{endef}. Aside from this difference in syntax,
+@code{define} works just like any other variable definition. The
+variable name may contain function and variable references, which are
+expanded when the directive is read to find the actual variable name
to use.
+You may omit the variable assignment operator if you prefer. If
+omitted, @code{make} assumes it to be @samp{=} and creates a
+recursively-expanded variable (@pxref{Flavors, ,The Two Flavors of Variables}).
+When using a @samp{+=} operator, the value is appended to the previous
+value as with any other append operation: with a single space
+separating the old and new values.
+
You may nest @code{define} directives: @code{make} will keep track of
nested directives and report an error if they are not all properly
closed with @code{endef}. Note that lines beginning with the recipe
prefix character are considered part of a recipe, so any @code{define}
or @code{endef} strings appearing on such a line will not be
-considered @code{make} operators.
+considered @code{make} directives.
@example
-define two-lines
+define two-lines =
echo foo
echo $(bar)
endef
@code{override} directive together with @code{define}:
@example
-override define two-lines
+override define two-lines =
foo
$(bar)
endef
@noindent
@xref{Override Directive, ,The @code{override} Directive}.
-@node Environment, Target-specific, Defining, Using Variables
+@node Environment, Target-specific, Multi-Line, Using Variables
@section Variables from the Environment
@cindex variables, environment
.PHONY: all
all: $(PROGRAMS)
-define PROGRAM_template
+define PROGRAM_template =
$(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%)
ALL_OBJS += $$($(1)_OBJS)
endef
@item environment
-if @var{variable} was defined as an environment variable and the
-@samp{-e} option is @emph{not} turned on (@pxref{Options Summary, ,Summary of Options}).
+if @var{variable} was inherited from the environment provided to
+@code{make}.
@item environment override
-if @var{variable} was defined as an environment variable and the
-@w{@samp{-e}} option @emph{is} turned on (@pxref{Options Summary,
-,Summary of Options}).@refill
+if @var{variable} was inherited from the environment provided to
+@code{make}, and is overriding a setting for @var{variable} in the
+makefile as a result of the @w{@samp{-e}} option (@pxref{Options
+Summary, ,Summary of Options}).@refill
@item file
@item 1
The exit status is one if you use the @samp{-q} flag and @code{make}
determines that some target is not already up to date.
-@xref{Instead of Execution, ,Instead of Executing the Recipes}.
+@xref{Instead of Execution, ,Instead of Executing Recipes}.
@end table
@menu
@end table
@node Instead of Execution, Avoiding Compilation, Goals, Running
-@section Instead of Executing the Recipes
+@section Instead of Executing Recipes
@cindex execution, instead of
@cindex recipes, instead of executing
@cindex @code{-n}
``No-op''. The activity is to print what recipe would be used to make
-the targets up to date, but not actually execute it.
+the targets up to date, but not actually execute it. Some recipes are
+still executed, even with this flag (@pxref{MAKE Variable, ,How the @code{MAKE} Variable Works}).
@item -t
@itemx --touch
@end table
With the @samp{-n} flag, @code{make} prints the recipe that it would
-normally execute but does not execute it.
+normally execute but usually does not execute it.
With the @samp{-t} flag, @code{make} ignores the recipes in the rules
and uses (in effect) the command @code{touch} for each target that needs to
@cindex @code{--recon}
@c Extra blank line here makes the table look better.
-Print the recipe that would be executed, but do not execute it.
-@xref{Instead of Execution, ,Instead of Executing the Recipes}.
+Print the recipe that would be executed, but do not execute it (except
+in certain circumstances).
+@xref{Instead of Execution, ,Instead of Executing Recipes}.
@item -o @var{file}
@cindex @code{-o}
``Question mode''. Do not run any recipes, or print anything; just
return an exit status that is zero if the specified targets are already
up to date, one if any remaking is required, or two if an error is
-encountered. @xref{Instead of Execution, ,Instead of Executing the
+encountered. @xref{Instead of Execution, ,Instead of Executing
Recipes}.@refill
@item -r
Touch files (mark them up to date without really changing them)
instead of running their recipes. This is used to pretend that the
recipes were done, in order to fool future invocations of
-@code{make}. @xref{Instead of Execution, ,Instead of Executing the Recipes}.
+@code{make}. @xref{Instead of Execution, ,Instead of Executing Recipes}.
@item -v
@cindex @code{-v}
running a @code{touch} command on the given file before running
@code{make}, except that the modification time is changed only in the
imagination of @code{make}.
-@xref{Instead of Execution, ,Instead of Executing the Recipes}.
+@xref{Instead of Execution, ,Instead of Executing Recipes}.
@item --warn-undefined-variables
@cindex @code{--warn-undefined-variables}
@item
The ``what if'' flag (@samp{-W} in GNU @code{make}) was (as far as we know)
invented by Andrew Hume in @code{mk}.
-@xref{Instead of Execution, ,Instead of Executing the Recipes}.
+@xref{Instead of Execution, ,Instead of Executing Recipes}.
@item
The concept of doing several things at once (parallelism) exists in
@item
The special significance of @samp{+} characters preceding recipe lines
-(@pxref{Instead of Execution, ,Instead of Executing the Recipes}) is
+(@pxref{Instead of Execution, ,Instead of Executing Recipes}) is
mandated by @cite{IEEE Standard 1003.2-1992} (POSIX.2).
@item
@item
Make verbatim variable definitions with @code{define}.
-@xref{Defining, ,Defining Variables Verbatim}.
+@xref{Multi-Line, ,Defining Multi-Line Variables}.
@item
Declare phony targets with the special target @code{.PHONY}.
@table @code
@item define @var{variable}
+@itemx define @var{variable} =
+@itemx define @var{variable} :=
+@itemx define @var{variable} +=
+@itemx define @var{variable} ?=
@itemx endef
-
-Define a multi-line, recursively-expanded variable.@*
-@xref{Sequences}.
+Define multi-line variables.@*
+@xref{Multi-Line}.
@item ifdef @var{variable}
@itemx ifndef @var{variable}
@itemx ifneq '@var{a}' '@var{b}'
@itemx else
@itemx endif
-
Conditionally evaluate part of the makefile.@*
@xref{Conditionals}.
@item include @var{file}
@itemx -include @var{file}
@itemx sinclude @var{file}
-
Include another makefile.@*
@xref{Include, ,Including Other Makefiles}.
-@item override @var{variable} = @var{value}
-@itemx override @var{variable} := @var{value}
-@itemx override @var{variable} += @var{value}
-@itemx override @var{variable} ?= @var{value}
-@itemx override define @var{variable}
-@itemx endef
-
+@item override @var{variable-assignment}
Define a variable, overriding any previous definition, even one from
the command line.@*
@xref{Override Directive, ,The @code{override} Directive}.
@item export
-
Tell @code{make} to export all variables to child processes by default.@*
@xref{Variables/Recursion, , Communicating Variables to a Sub-@code{make}}.
@item export @var{variable}
-@itemx export @var{variable} = @var{value}
-@itemx export @var{variable} := @var{value}
-@itemx export @var{variable} += @var{value}
-@itemx export @var{variable} ?= @var{value}
+@itemx export @var{variable-assignment}
@itemx unexport @var{variable}
Tell @code{make} whether or not to export a particular variable to child
processes.@*
@xref{Variables/Recursion, , Communicating Variables to a Sub-@code{make}}.
+@item private @var{variable-assignment}
+Do not allow this variable assignment to be inherited by prerequisites.@*
+@xref{Suppressing Inheritance}.
+
@item vpath @var{pattern} @var{path}
Specify a search path for files matching a @samp{%} pattern.@*
@xref{Selective Search, , The @code{vpath} Directive}.
@xref{File Name Functions, ,Functions for File Names}.
@item $(error @var{text}@dots{})
-
When this function is evaluated, @code{make} generates a fatal error
with the message @var{text}.@*
@xref{Make Control Functions, ,Functions That Control Make}.
@item $(warning @var{text}@dots{})
-
When this function is evaluated, @code{make} generates a warning with
the message @var{text}.@*
@xref{Make Control Functions, ,Functions That Control Make}.
@item $(shell @var{command})
-
Execute a shell command and return its output.@*
@xref{Shell Function, , The @code{shell} Function}.
@item $(origin @var{variable})
-
Return a string describing how the @code{make} variable @var{variable} was
defined.@*
@xref{Origin Function, , The @code{origin} Function}.
@item $(flavor @var{variable})
-
Return a string describing the flavor of the @code{make} variable
@var{variable}.@*
@xref{Flavor Function, , The @code{flavor} Function}.
@item $(foreach @var{var},@var{words},@var{text})
-
Evaluate @var{text} with @var{var} bound to each word in @var{words},
and concatenate the results.@*
@xref{Foreach Function, ,The @code{foreach} Function}.
-@item $(call @var{var},@var{param},@dots{})
+@item $(if @var{condition},@var{then-part}[,@var{else-part}])
+Evaluate the condition @var{condition}; if it's non-empty substitute
+the expansion of the @var{then-part} otherwise substitute the
+expansion of the @var{else-part}.@*
+@xref{Conditional Functions, ,Functions for Conditionals}.
+@item $(or @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]])
+Evaluate each condition @var{conditionN} one at a time; substitute the
+first non-empty expansion. If all expansions are empty, substitute
+the empty string.@*
+@xref{Conditional Functions, ,Functions for Conditionals}.
+
+@item $(and @var{condition1}[,@var{condition2}[,@var{condition3}@dots{}]])
+Evaluate each condition @var{conditionN} one at a time; if any
+expansion results in the empty string substitute the empty string. If
+all expansions result in a non-empty string, substitute the expansion
+of the last @var{condition}.@*
+@xref{Conditional Functions, ,Functions for Conditionals}.
+
+@item $(call @var{var},@var{param},@dots{})
Evaluate the variable @var{var} replacing any references to @code{$(1)},
@code{$(2)} with the first, second, etc.@: @var{param} values.@*
@xref{Call Function, ,The @code{call} Function}.
@item $(eval @var{text})
-
Evaluate @var{text} then read the results as makefile commands.
Expands to the empty string.@*
@xref{Eval Function, ,The @code{eval} Function}.
@item $(value @var{var})
-
Evaluates to the contents of the variable @var{var}, with no expansion
performed on it.@*
@xref{Value Function, ,The @code{value} Function}.
static int eval (struct ebuffer *buffer, int flags);
static long readline (struct ebuffer *ebuf);
-static struct variable *do_define (char *name, unsigned int namelen,
- enum variable_origin origin,
+static struct variable *do_define (char *name, enum variable_origin origin,
struct ebuffer *ebuf);
static int conditional_line (char *line, int len, const struct floc *flocp);
static void record_files (struct nameseq *filenames, const char *pattern,
return 0;
}
+ /* Set close-on-exec to avoid leaking the makefile to children, such as
+ $(shell ...). */
+#ifdef HAVE_FILENO
+ CLOSE_ON_EXEC (fileno (ebuf.fp));
+#endif
+
/* Add this makefile to the list. */
do_variable_definition (&ebuf.floc, "MAKEFILE_LIST", filename, o_file,
f_append, 0);
ebuf.buffer = ebuf.bufnext = ebuf.bufstart = buffer;
ebuf.fp = NULL;
- ebuf.floc = *reading_file;
+ if (reading_file)
+ ebuf.floc = *reading_file;
+ else
+ ebuf.floc.filenm = NULL;
curfile = reading_file;
reading_file = &ebuf.floc;
continue;
}
- /* If it's a multi-line define / endef, manage that. */
if (vmod.define_v)
- {
- if (*p == '\0')
- fatal (fstart, _("empty variable name"));
-
- /* Let the variable name be the whole rest of the line,
- with trailing blanks stripped (comments have already been
- removed), so it could be a complex variable/function
- reference that might contain blanks. */
- p2 = p + strlen (p);
- while (isblank ((unsigned char)p2[-1]))
- --p2;
- v = do_define (p, p2 - p, origin, ebuf);
- }
+ v = do_define (p, origin, ebuf);
else
- {
- v = try_variable_definition (fstart, p, origin, 0);
- assert (v != NULL);
- }
+ v = try_variable_definition (fstart, p, origin, 0);
+
+ assert (v != NULL);
if (vmod.export_v)
v->export = v_export;
Because the target is not recorded until after ifeq directive is
evaluated the .DEFAULT_GOAL does not contain foo yet as one
- would expect. Because of this we have to move some of the logic
- here. */
+ would expect. Because of this we have to move the logic here. */
- if (**default_goal_name == '\0' && set_default)
+ if (set_default && default_goal_var->value[0] == '\0')
{
const char *name;
struct dep *d;
the variable to be defined. The following lines remain to be read. */
static struct variable *
-do_define (char *name, unsigned int namelen,
- enum variable_origin origin, struct ebuffer *ebuf)
+do_define (char *name, enum variable_origin origin, struct ebuffer *ebuf)
{
+ struct variable *v;
+ enum variable_flavor flavor;
struct floc defstart;
- long nlines = 0;
int nlevels = 1;
unsigned int length = 100;
char *definition = xmalloc (length);
unsigned int idx = 0;
- char *p;
-
- /* Expand the variable name. */
- char *var = alloca (namelen + 1);
- memcpy (var, name, namelen);
- var[namelen] = '\0';
- var = variable_expand (var);
+ char *p, *var;
defstart = ebuf->floc;
+ p = parse_variable_definition (name, &flavor);
+ if (p == NULL)
+ /* No assignment token, so assume recursive. */
+ flavor = f_recursive;
+ else
+ {
+ if (*(next_token (p)) != '\0')
+ error (&defstart, _("extraneous text after `define' directive"));
+
+ /* Chop the string before the assignment token to get the name. */
+ p[flavor == f_recursive ? -1 : -2] = '\0';
+ }
+
+ /* Expand the variable name and find the beginning (NAME) and end. */
+ var = allocated_variable_expand (name);
+ name = next_token (var);
+ if (*name == '\0')
+ fatal (&defstart, _("empty variable name"));
+ p = name + strlen (name) - 1;
+ while (p > name && isblank ((unsigned char)*p))
+ --p;
+ p[1] = '\0';
+
+ /* Now read the value of the variable. */
while (1)
{
unsigned int len;
char *line;
+ long nlines = readline (ebuf);
- nlines = readline (ebuf);
- ebuf->floc.lineno += nlines;
-
- /* If there is nothing left to eval, we're done. */
+ /* If there is nothing left to be eval'd, there's no 'endef'!! */
if (nlines < 0)
- break;
+ fatal (&defstart, _("missing `endef', unterminated `define'"));
+ ebuf->floc.lineno += nlines;
line = ebuf->buffer;
collapse_continuations (line);
/* If the line doesn't begin with a tab, test to see if it introduces
- another define, or ends one. */
-
- /* Stop if we find an 'endef' */
+ another define, or ends one. Stop if we find an 'endef' */
if (line[0] != cmd_prefix)
{
p = next_token (line);
{
p += 5;
remove_comments (p);
- if (*next_token (p) != '\0')
+ if (*(next_token (p)) != '\0')
error (&ebuf->floc,
- _("Extraneous text after `endef' directive"));
+ _("extraneous text after `endef' directive"));
if (--nlevels == 0)
- {
- struct variable *v;
-
- /* Define the variable. */
- if (idx == 0)
- definition[0] = '\0';
- else
- definition[idx - 1] = '\0';
-
- /* Always define these variables in the global set. */
- v = define_variable_global (var, strlen (var), definition,
- origin, 1, &defstart);
- free (definition);
- return (v);
- }
+ break;
}
}
- /* Otherwise add this line to the variable definition. */
+ /* Add this line to the variable definition. */
len = strlen (line);
if (idx + len + 1 > length)
{
definition[idx++] = '\n';
}
- /* No `endef'!! */
- fatal (&defstart, _("missing `endef', unterminated `define'"));
+ /* We've got what we need; define the variable. */
+ if (idx == 0)
+ definition[0] = '\0';
+ else
+ definition[idx - 1] = '\0';
+
+ v = do_variable_definition (&defstart, name, definition, origin, flavor, 0);
+ free (definition);
+ free (var);
+ return (v);
}
\f
/* Interpret conditional commands "ifdef", "ifndef", "ifeq",
v = assign_variable_definition (&p->variable, defn);
assert (v != 0);
+ v->origin = origin;
if (v->flavor == f_simple)
v->value = allocated_variable_expand (v->value);
else
}
/* Set up the variable to be *-specific. */
- v->origin = origin;
v->per_target = 1;
v->private_var = vmod->private_v;
v->export = vmod->export_v ? v_export : v_default;
/* If it's not an override, check to see if there was a command-line
setting. If so, reset the value. */
- if (origin != o_override)
+ if (v->origin != o_override)
{
struct variable *gv;
int len = strlen(v->name);
}
name = f->name;
-
- /* If this target is a default target, update DEFAULT_GOAL_FILE. */
- if (streq (*default_goal_name, name)
- && (default_goal_file == 0
- || ! streq (default_goal_file->name, name)))
- default_goal_file = f;
}
if (implicit)