* main.c (switches): Add -E as an alias for --eval.

* make.1: Document the -E and --eval options.
* doc/make.texi: Document the -E option.
* tests/scripts/options/eval: Test the -E option and MAKEFILES.
* NEWS: Add information about the new option.
This commit is contained in:
Paul Smith 2016-12-28 00:41:38 -05:00
parent 3daaa4dd3e
commit d351c1fef2
5 changed files with 29 additions and 6 deletions

2
NEWS
View file

@ -36,6 +36,8 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=108&set
* A new option --no-silent has been added, that cancels the effect of the
-s/--silent/--quiet flag.
* A new option -E has been added as a short alias for --eval.
Version 4.2.1 (10 Jun 2016)

View file

@ -8657,6 +8657,8 @@ Give variables taken from the environment precedence
over variables from makefiles.
@xref{Environment, ,Variables from the Environment}.
@item -E @var{string}
@cindex @code{-E}
@item --eval=@var{string}
@cindex @code{--eval}
@c Extra blank line here makes the table look better.

4
main.c
View file

@ -350,7 +350,7 @@ static const char *const usage[] =
-e, --environment-overrides\n\
Environment variables override makefiles.\n"),
N_("\
--eval=STRING Evaluate STRING as a makefile statement.\n"),
-E STRING, --eval=STRING Evaluate STRING as a makefile statement.\n"),
N_("\
-f FILE, --file=FILE, --makefile=FILE\n\
Read FILE as a makefile.\n"),
@ -425,6 +425,7 @@ static const struct command_switch switches[] =
{ 'D', flag, &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" },
#endif
{ 'e', flag, &env_overrides, 1, 1, 0, 0, 0, "environment-overrides", },
{ 'E', strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
{ 'h', flag, &print_usage_flag, 0, 0, 0, 0, 0, "help" },
{ 'i', flag, &ignore_errors_flag, 1, 1, 0, 0, 0, "ignore-errors" },
{ 'k', flag, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag,
@ -465,7 +466,6 @@ static const struct command_switch switches[] =
"no-print-directory" },
{ CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
"warn-undefined-variables" },
{ CHAR_MAX+6, strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" },
{ CHAR_MAX+7, string, &sync_mutex, 1, 1, 0, 0, 0, "sync-mutex" },
{ CHAR_MAX+8, flag_off, &silent_flag, 1, 1, 0, 0, &default_silent_flag, "no-silent" },
{ CHAR_MAX+9, string, &jobserver_auth, 1, 0, 0, 0, 0, "jobserver-fds" },

8
make.1
View file

@ -148,8 +148,12 @@ for debugging while remaking makefiles. Use
to disable all previous debugging flags.
.TP 0.5i
\fB\-e\fR, \fB\-\-environment\-overrides\fR
Give variables taken from the environment precedence
over variables from makefiles.
Give variables taken from the environment precedence over variables
from makefiles.
.TP 0.5i
\fB\-E\fR \fIstring\fR, \fB\-\-eval\fR \fIstring\fR
Interpret \fIstring\fR using the \fBeval\fR function, before parsing any
makefiles.
.TP 0.5i
\fB\-f\fR \fIfile\fR, \fB\-\-file\fR=\fIfile\fR, \fB\-\-makefile\fR=\fIFILE\fR
Use

View file

@ -7,14 +7,22 @@ and are passed to sub-makes.";
# Verify that --eval is evaluated first
run_make_test(q!
$(info infile)
BAR = bar
all: ; @echo all
recurse: ; @$(MAKE) -f #MAKEFILE# && echo recurse!,
'--eval=\$\(info\ eval\) FOO=\$\(BAR\)', "eval\nall");
'--eval=\$\(info\ eval\) FOO=\$\(BAR\)', "eval\ninfile\nall");
# Make sure that --eval is handled correctly during recursion
run_make_test(undef, '--no-print-directory --eval=\$\(info\ eval\) recurse',
"eval\neval\nall\nrecurse");
"eval\ninfile\neval\ninfile\nall\nrecurse");
# Make sure that --eval is not passed in MAKEFLAGS
run_make_test(q!
all: ; @echo "MAKEFLAGS=$$MAKEFLAGS"
!,
'--eval=\$\(info\ eval\)',
"eval\n".'MAKEFLAGS= --eval=$$(info\ eval)');
# Make sure that --eval is handled correctly during restarting
run_make_test(q!
@ -26,4 +34,11 @@ gen.mk: ; @echo > $@
unlink('gen.mk');
# Check -E
run_make_test(q!
BAR = bar
all: ; @echo all
recurse: ; @$(MAKE) -f #MAKEFILE# && echo recurse!,
'-E \$\(info\ eval\) FOO=\$\(BAR\)', "eval\nall");
1;