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