[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] libtool: Support quoted arguments in user-supplied flags
From: |
Nikolai Merinov |
Subject: |
[PATCH 1/2] libtool: Support quoted arguments in user-supplied flags |
Date: |
Fri, 15 Mar 2019 03:46:06 +0500 |
* m4/libtool.m4 (_LT_COMPILER_OPTION): Evaluate `lt_compile' variable
twice in order to unquote user-supplied variables in same manner as
it made during compilation in Makefiles
(_LT_COMPILER_C_O): Same
* Makefile.am (TESTSUITE_AT): Add new test
* tests/escaped_cflags.at: New test for quoted CFLAGS. This test would
work only with autoconf > 2.69; for older autoconf ./configure will
fail and test will be skipped.
---
Makefile.am | 1 +
m4/libtool.m4 | 4 ++++
tests/escaped_cflags.at | 44 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+)
create mode 100644 tests/escaped_cflags.at
diff --git a/Makefile.am b/Makefile.am
index 6b546092..e99949b2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -658,6 +658,7 @@ TESTSUITE_AT = tests/testsuite.at \
tests/libtoolize.at \
tests/libtool.at \
tests/demo.at \
+ tests/escaped_cflags.at \
tests/pic_flag.at \
tests/with-pic.at \
tests/cdemo.at \
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index f2d1f398..fa7887e0 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1606,6 +1606,8 @@ AC_CACHE_CHECK([$1], [$2],
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ # Evaluate compilation command twice in order to unqoute *FLAGS
+ eval lt_compile="\"$lt_compile\""
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -2088,6 +2090,8 @@ AC_CACHE_CHECK([if $compiler supports -c -o
file.$ac_objext],
-e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ # Evaluate compilation command twice in order to unqoute *FLAGS
+ eval lt_compile="\"$lt_compile\""
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&AS_MESSAGE_LOG_FD
diff --git a/tests/escaped_cflags.at b/tests/escaped_cflags.at
new file mode 100644
index 00000000..3dd95ba4
--- /dev/null
+++ b/tests/escaped_cflags.at
@@ -0,0 +1,44 @@
+# escaped_cflags.at -- escaped CFLAGS and tests for PIC flags -*- Autotest
-*-
+
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+####
+
+AT_SETUP([check pic_flags with escaped CFLAGS])
+
+AT_DATA([foo.c],
+[[int data = 42;
+int func(void) { return data; }
+]])
+
+# Set up a tests/demo.at style project.
+_LT_DEMO_SETUP
+
+# Bootstrap, and configure it so that we can extract libtool --config
+# settings.
+LT_AT_BOOTSTRAP([], [-I m4], [], [--add-missing], [],
+ [CFLAGS='"-Wall"'], [ignore])
+
+: ${MAKE=make}
+AT_CHECK([$MAKE], [], [stdout], [ignore])
+AT_CHECK([if ./libtool --features | $GREP 'enable shared libraries'; then ]dnl
+ [ $GREP -i ' -fPIC' stdout; else exit 77; fi], [], [ignore], [ignore])
+
+AT_CLEANUP
--
2.21.0