* 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.
diff --git a/NEWS b/NEWS
index 9e10a9f..e60644a 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,8 @@
* 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)
diff --git a/doc/make.texi b/doc/make.texi
index a1aa5d3..e629f49 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -8657,6 +8657,8 @@
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.
diff --git a/main.c b/main.c
index a17b70e..5b0a854 100644
--- a/main.c
+++ b/main.c
@@ -350,7 +350,7 @@
-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 @@
{ '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 @@
"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" },
diff --git a/make.1 b/make.1
index 5396650..e0faeae 100644
--- a/make.1
+++ b/make.1
@@ -148,8 +148,12 @@
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
diff --git a/tests/scripts/options/eval b/tests/scripts/options/eval
index 0f82409..b02b925 100644
--- a/tests/scripts/options/eval
+++ b/tests/scripts/options/eval
@@ -7,14 +7,22 @@
# 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 @@
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;