From 54ff27a6bc817236c29caf2575707c0d40ced631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 6 Nov 2018 17:09:08 +0700 Subject: [PATCH] Add and use AX_POSIX_SHELL autoconf macro, so we can rely on POSIX shell features --- aclocal.m4 | 1 + configure | 38 ++++++++++++++++++++++++++++++++++++++ configure.ac | 1 + m4/ax_posix_shell.m4 | 28 ++++++++++++++++++++++++++++ util/copyrights | 7 ------- 5 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 m4/ax_posix_shell.m4 diff --git a/aclocal.m4 b/aclocal.m4 index 5a16166751..bee01f409b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -289,6 +289,7 @@ AS_VAR_IF([$1], [""], [$5], [$4])dnl ])dnl PKG_CHECK_VAR m4_include([m4/ax_check_openssl.m4]) +m4_include([m4/ax_posix_shell.m4]) m4_include([m4/ax_pthread.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) diff --git a/configure b/configure index b6a780f78f..90cffa9ec4 100755 --- a/configure +++ b/configure @@ -11697,6 +11697,44 @@ else $as_echo "no, using $LN_S" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a POSIX-compatible shell" >&5 +$as_echo_n "checking for a POSIX-compatible shell... " >&6; } +if ${ac_cv_prog_shell+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_test_shell_script=' + test "$(expr 1 + 1)" = "2" && + test "$(( 1 + 1 ))" = "2" + ' + + for ac_cv_prog_shell in \ + "$CONFIG_SHELL" "$SHELL" /bin/sh /bin/bash /bin/ksh /bin/sh5 no; do + case $ac_cv_prog_shell in #( + /*) : + + if "$ac_cv_prog_shell" -c "$ac_test_shell_script" 2>/dev/null; then : + ac_cv_path_shell=$SHELL +fi + ;; #( + *) : + ;; +esac + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_shell" >&5 +$as_echo "$ac_cv_prog_shell" >&6; } + if test "$ac_cv_prog_shell" = "no"; then : + SHELL=/bin/sh + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using $SHELL, even though it does not conform to POSIX" >&5 +$as_echo "$as_me: WARNING: using $SHELL, even though it does not conform to POSIX" >&2;} + +else + SHELL="$ac_cv_prog_shell" + +fi + + diff --git a/configure.ac b/configure.ac index 2b27558a6e..d100ae29ac 100644 --- a/configure.ac +++ b/configure.ac @@ -24,6 +24,7 @@ AC_PROG_MAKE_SET AC_PROG_LIBTOOL AC_PROG_INSTALL AC_PROG_LN_S +AX_POSIX_SHELL AC_SUBST(STD_CINCLUDES) AC_SUBST(STD_CDEFINES) diff --git a/m4/ax_posix_shell.m4 b/m4/ax_posix_shell.m4 new file mode 100644 index 0000000000..cdb3b11918 --- /dev/null +++ b/m4/ax_posix_shell.m4 @@ -0,0 +1,28 @@ +# AX_POSIX_SHELL +# ------------- +# Check for a POSIX-compatible shell. +# +AC_DEFUN([AX_POSIX_SHELL], + [AC_CACHE_CHECK([for a POSIX-compatible shell], [ac_cv_prog_shell], + [ac_test_shell_script=' + test "$(expr 1 + 1)" = "2" && + test "$(( 1 + 1 ))" = "2" + ' + + for ac_cv_prog_shell in \ + "$CONFIG_SHELL" "$SHELL" /bin/sh /bin/bash /bin/ksh /bin/sh5 no; do + AS_CASE([$ac_cv_prog_shell], + [/*],[ + AS_IF(["$ac_cv_prog_shell" -c "$ac_test_shell_script" 2>/dev/null], + [ac_cv_path_shell=$SHELL]) + ]) + done + ]) + AS_IF([test "$ac_cv_prog_shell" = "no"], + [SHELL=/bin/sh + AC_MSG_WARN([using $SHELL, even though it does not conform to POSIX]) + ], + [SHELL="$ac_cv_prog_shell" + ]) + AC_SUBST([SHELL]) + ]) diff --git a/util/copyrights b/util/copyrights index ee92136688..81be867724 100644 --- a/util/copyrights +++ b/util/copyrights @@ -3762,13 +3762,6 @@ ./lib/win32/bindevt/bindevt.vcxproj.in X 2013,2014,2015,2016,2018 ./lib/win32/bindevt/bindevt.vcxproj.user X 2013,2018 ./ltmain.sh X 1999,2000,2001,2003,2004,2006,2009,2012,2018 -./m4/ax_check_openssl.m4 X 2018 -./m4/ax_pthread.m4 X 2018 -./m4/libtool.m4 X 2012,2018 -./m4/ltoptions.m4 X 2012,2018 -./m4/ltsugar.m4 X 2012,2018 -./m4/ltversion.m4 X 2012,2018 -./m4/lt~obsolete.m4 X 2012,2018 ./make/includes.in MAKE 1999,2000,2001,2004,2005,2007,2012,2014,2016,2017,2018 ./make/mkdep.in X 1999,2000,2001,2006,2011,2014,2018 ./make/rules.in MAKE 1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018