1 # geda-awk.m4 -*-Autoconf-*-
4 dnl Improved checks for awk executable path and features
5 dnl Copyright (C) 2008 Dan McMahill <dan@mcmahill.net>
6 dnl Copyright (C) 2009 Peter Brett <peter@peter-b.co.uk>
8 dnl This program is free software; you can redistribute it and/or modify
9 dnl it under the terms of the GNU General Public License as published by
10 dnl the Free Software Foundation; either version 2 of the License, or
11 dnl (at your option) any later version.
13 dnl This program is distributed in the hope that it will be useful,
14 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 dnl GNU General Public License for more details.
18 dnl You should have received a copy of the GNU General Public License
19 dnl along with this program; if not, write to the Free Software
20 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 AC_DEFUN([AX_PROG_AWK],
25 AC_PROVIDE([AC_PROG_AWK])dnl
26 AC_ARG_VAR([AWK], [Path to awk executable])
27 AC_PATH_PROGS([AWK], [mawk gawk nawk awk], [no])
28 if test "X$AWK" = "Xno"; then
29 AC_MSG_ERROR([The awk tool could not be found. Ensure it is installed and in your
34 dnl AX_AWK_IFELSE (PROGRAM, INPUT, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
35 AC_DEFUN([AX_AWK_IFELSE],
38 AC_REQUIRE([AC_PROG_AWK])dnl
39 cat > conftest.awk <<EOF
40 [#]line __oline__ "configure"
43 cat > conftest.txt <<EOF
46 if ($AWK -f conftest.awk conftest.txt >/dev/null; exit) 2>&AC_FD_CC; then
51 echo "configure:__oline__: $AWK -f conftest.awk conftest.txt" >&AC_FD_CC
52 echo "configure:__oline__: failed program was:" >&AC_FD_CC
53 cat conftest.awk >&AC_FD_CC
54 echo "configure:__oline__: failed input file was:" >&AC_FD_CC
55 cat conftest.txt >&AC_FD_CC
62 dnl Check for some miscellaneous Awk features used by gEDA.
63 AC_DEFUN([AX_AWK_FEATURES],
66 AC_REQUIRE([AC_PROG_AWK])dnl
68 AC_MSG_CHECKING([whether $AWK has gsub])
69 AX_AWK_IFELSE([{gsub(/foo/,"bar");}], [foo bar],
70 [AWK_GSUB="yes"],[AWK_GSUB="no"])
71 AC_MSG_RESULT([$AWK_GSUB])
73 AC_MSG_CHECKING([whether $AWK has toupper])
74 AX_AWK_IFELSE([{print toupper("test")}], [foo bar],
75 [AWK_TOUPPER=yes],[AWK_TOUPPER=no])
76 AC_MSG_RESULT([$AWK_TOUPPER])
78 if (test "X$AWK_GSUB" = "Xno" || test "X$AWK_TOUPPER" = "Xno"); then
79 AC_MSG_ERROR([Your awk ($AWK) is missing the `gsub' and/or `toupper' functions.
80 Consider installing gawk.])