2 # m4-syscmd.m4 -- Allow choice of syscmd shell.
3 # Written by Eric Blake <ebb9@byu.net>
5 # Copyright (C) 2009-2010, 2013-2014, 2017 Free Software Foundation,
8 # This file is part of GNU M4.
10 # GNU M4 is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # GNU M4 is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 # Allow user to choose different shell than /bin/sh for e?syscmd.
29 [AC_MSG_CHECKING([[which shell to use for syscmd]])
30 AC_ARG_WITH([syscmd-shell],
31 [AS_HELP_STRING([--with-syscmd-shell], [shell used by syscmd [/bin/sh]])],
33 yes[)] with_syscmd_shell=no;;
34 esac], [with_syscmd_shell=no])
35 if test "$with_syscmd_shell" = no ; then
36 with_syscmd_shell=/bin/sh
37 if test "$cross_compiling" != yes ; then
38 dnl Give mingw a default that is more likely to be available.
39 AS_IF([AS_EXECUTABLE_P([/bin/sh$EXEEXT])], [],
40 [if (cmd /c) 2>/dev/null; then with_syscmd_shell=cmd; fi])
41 dnl Too bad _AS_PATH_WALK is not public.
42 M4_save_IFS=$IFS; IFS=$PATH_SEPARATOR
43 for M4_dir in `if (command -p getconf PATH) 2>/dev/null ; then
44 command -p getconf PATH
46 echo "/bin$PATH_SEPARATOR$PATH"
50 test -z "$M4_dir" && continue
51 AS_EXECUTABLE_P(["$M4_dir/sh"]) \
52 && { with_syscmd_shell=$M4_dir/sh; break; }
57 AC_MSG_RESULT([$with_syscmd_shell])
58 AC_DEFINE_UNQUOTED([M4_SYSCMD_SHELL], ["$with_syscmd_shell"],
59 [Shell used by syscmd and esyscmd, must accept -c argument.])