configury: move autoconf macros to build-aux subdirectory.
[m4/ericb.git] / build-aux / m4 / m4-syscmd.m4
blob514201fa7a7917c1e06b2216a9f9adc9289bb3d5
1 #                                                            -*- Autoconf -*-
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/>.
22 # serial 1
24 # M4_SYSCMD
25 # ---------
26 # Allow user to choose different shell than /bin/sh for e?syscmd.
27 AC_DEFUN([M4_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]])],
31   [case $withval in
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
44       else
45  echo "/bin$PATH_SEPARATOR$PATH"
46       fi`
47     do
48       IFS=$M4_save_IFS
49       test -z "$M4_dir" && continue
50       AS_EXECUTABLE_P(["$M4_dir/sh"]) \
51  && { with_syscmd_shell=$M4_dir/sh; break; }
52     done
53     IFS=$M4_save_IFS
54   fi
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.])