[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] AC_COMPILE_IFELSE: Evaluate user supplied arguments
From: |
Nikolai Merinov |
Subject: |
[PATCH] AC_COMPILE_IFELSE: Evaluate user supplied arguments |
Date: |
Thu, 7 Mar 2019 22:33:13 +0500 |
In the following call sequence
> ./configure CPPFLAGS='-DVARIABLE=\"string\"' && make
compilation with the `AC_COMPILE_IFELSE' macro and with the `make'
command should use same compilation commands. It means that the
`AC_COMPILE_IFELSE' macro should evaluate the `ac_compile` variable
twice in order to evaluate user-supplied variables.
* lib/autoconf/general.m4 (_AC_DO_STDERR): Reuse `_AC_DO_ECHO' trick
to evaluate arguments twice if compile string have no '\"', '`', or
'\\' symbols.
* tests/compile.at: Add test for CFLAGS evaluation.
---
lib/autoconf/general.m4 | 11 +++++++++--
tests/compile.at | 11 +++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index e1d82b54..0e816f4b 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -2456,8 +2456,15 @@ AC_DEFUN([_AC_DO],
# ----------------------
# Like _AC_RUN_LOG_STDERR, but eval (instead of running) COMMAND.
AC_DEFUN([_AC_DO_STDERR],
-[_AC_RUN_LOG_STDERR([eval "$1"],
- [_AC_DO_ECHO([$1])])])
+[m4_if([$1], [$ac_do_stderr], [], [ac_do_stderr="$1"
+])]dnl
+[[case "(($ac_do_stderr" in
+ *\"* | *\`* | *\\*) ac_do_stderr_command=\$ac_do_stderr;;
+ *) ac_do_stderr_command=$ac_do_stderr;;
+esac
+eval ac_do_stderr_command="\"$ac_do_stderr_command\""]
+_AC_RUN_LOG_STDERR([eval "$ac_do_stderr_command"],
+ [_AC_DO_ECHO([$ac_do_stderr])])])
# _AC_DO_VAR(VARIABLE)
diff --git a/tests/compile.at b/tests/compile.at
index 29374529..9af8cb38 100644
--- a/tests/compile.at
+++ b/tests/compile.at
@@ -301,6 +301,17 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return 2])],
AT_CHECK_AUTOCONF
AT_CHECK_CONFIGURE([-q])
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_PROG_CC
+test x$GCC = xyes && CFLAGS='"-Wall"'
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [return 0])], [],
+ [AC_MSG_ERROR([compiling trivial program failed])])
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE([-q])
+
AT_CLEANUP
## --------------- ##
--
2.20.0
- [PATCH] AC_COMPILE_IFELSE: Evaluate user supplied arguments,
Nikolai Merinov <=