autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new macros AC_FUNC_EGREP, AC_FUNC_FGREP for POSIX 1003.1-2001 support


From: Paul Eggert
Subject: new macros AC_FUNC_EGREP, AC_FUNC_FGREP for POSIX 1003.1-2001 support
Date: Wed, 29 May 2002 15:35:14 -0700 (PDT)

POSIX 1003.1-2001 no longer requires support for the obsolete commands
'egrep' and 'fgrep', so I've installed the following changes into
Autoconf.

2002-05-29  Paul Eggert  <address@hidden>

        * bin/autom4te.in ($m4): Do not assume that egrep and fgrep exist.
        * lib/autoconf/c.m4 (AC_C_BIGENDIAN): Likewise.
        * lib/autoconf/general.m4 (_AC_RUN_LOG_STDERR, AC_EGREP_CPP):
        Likewise.
        * lib/autoconf/Makefile.am (check-local): Likewise.
        * lib/autoconf/status.m4 (AC_CONFIG_HEADER): Likewise.
        * lib/autoconf/types.m4 (commentary only): Likewise.
        * lib/autotest/general.m4 (AT_INIT, AT_CHECK): Likewise.
        * lib/autotest/Makefile.am (check-local): Likewise.
        * lib/m4sugar/Makefile.am (check-local): Likewise.
        * tests/atspecific.m4 (AT_CONFIGURE_AC, AT_CHECK_DEFINES): Likewise.
        * tests/mktests.sh (egrep): New var; use it instead of plain egrep.

        * lib/autoconf/programs.m4 (AC_PROG_EGREP, AC_PROG_FGREP): New macros.
        * doc/autoconf.texi (Particular Programs): Document them.
        (Limitations of Usual Tools): Warn that egrep and fgrep may not exist.
        * NEWS: Likewise.

Index: bin/autom4te.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autom4te.in,v
retrieving revision 1.61
diff -p -u -r1.61 autom4te.in
--- bin/autom4te.in     20 Apr 2002 06:09:01 -0000      1.61
+++ bin/autom4te.in     29 May 2002 22:10:06 -0000
@@ -279,7 +279,7 @@ my $freeze = 0;
 my $m4 = $ENV{"M4"} || '@M4@';
 # Some non-GNU m4's don't reject the --help option, so give them /dev/null.
 die "$me: need GNU m4 1.4 or later: $m4\n"
-  if system "$m4 --help </dev/null 2>&1 | fgrep reload-state >/dev/null";
+  if system "$m4 --help </dev/null 2>&1 | grep reload-state >/dev/null";
 
 # Set some high recursion limit as the default limit, 250, has already
 # been hit with AC_OUTPUT.  Don't override the user's choice.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.628
diff -p -u -r1.628 autoconf.texi
--- doc/autoconf.texi   28 May 2002 04:14:49 -0000      1.628
+++ doc/autoconf.texi   29 May 2002 22:10:10 -0000
@@ -3023,6 +3023,19 @@ It tries @code{gawk} first because that 
 best implementation.
 @end defmac
 
address@hidden AC_PROG_EGREP
address@hidden PROG_EGREP
address@hidden EGREP
+Check for @code{grep -E} and @code{egrep}, in that order, and set
+output variable @code{EGREP} to the first one that is found.
address@hidden defmac
+
address@hidden AC_PROG_FGREP
address@hidden PROG_FGREP
address@hidden FGREP
+Check for @code{grep -F} and @code{fgrep}, in that order, and set
+output variable @code{FGREP} to the first one that is found.
address@hidden defmac
 
 @defmac AC_PROG_INSTALL
 @acindex PROG_INSTALL
@@ -5474,7 +5487,7 @@ in another header file that the file you
 @defmac AC_EGREP_HEADER (@var{pattern}, @var{header-file}, 
@var{action-if-found}, @ovar{action-if-not-found})
 @acindex EGREP_HEADER
 If the output of running the preprocessor on the system header file
address@hidden matches the @code{egrep} regular expression
address@hidden matches the extended regular expression
 @var{pattern}, execute shell commands @var{action-if-found}, otherwise
 execute @var{action-if-not-found}.
 @end defmac
@@ -5496,7 +5509,7 @@ AC_EGREP_CPP(yes,
 @var{program} is the text of a C or C++ program, on which shell
 variable, back quote, and backslash substitutions are performed.  If the
 output of running the preprocessor on @var{program} matches the
address@hidden regular expression @var{pattern}, execute shell commands
+extended regular expression @var{pattern}, execute shell commands
 @var{action-if-found}, otherwise execute @var{action-if-not-found}.
 
 This macro calls @code{AC_PROG_CPP} or @code{AC_PROG_CXXCPP} (depending
@@ -9671,21 +9684,25 @@ It says that the behavior of dirname on 
 @item @command{egrep}
 @c ------------------
 @prindex @command{egrep}
address@hidden 1003.1-2001 no longer requires @command{egrep},
+but many older hosts do not yet support the @acronym{POSIX}
+replacement @code{grep -E}.  To work around this problem, invoke
address@hidden and then use @code{$EGREP}.
+
 The empty alternative is not portable, use @samp{?} instead. For
 instance with Digital Unix v5.0:
 
 @example
-> printf "foo\n|foo\n" | egrep '^(|foo|bar)$'
+> printf "foo\n|foo\n" | $EGREP '^(|foo|bar)$'
 |foo
-> printf "bar\nbar|\n" | egrep '^(foo|bar|)$'
+> printf "bar\nbar|\n" | $EGREP '^(foo|bar|)$'
 bar|
-> printf "foo\nfoo|\n|bar\nbar\n" | egrep '^(foo||bar)$'
+> printf "foo\nfoo|\n|bar\nbar\n" | $EGREP '^(foo||bar)$'
 foo
 |bar
 @end example
 
address@hidden also suffers the limitations of @command{grep}.
-
address@hidden also suffers the limitations of @command{grep}.
 
 @item @command{expr}
 @c -----------------
@@ -9784,6 +9801,15 @@ simple work around consists in testing @
 set to @command{expr} or to @command{false} according to the result.
 
 
address@hidden @command{fgrep}
address@hidden ------------------
address@hidden @command{fgrep}
address@hidden 1003.1-2001 no longer requires @command{fgrep},
+but many older hosts do not yet support the @acronym{POSIX}
+replacement @code{grep -F}.  To work around this problem, invoke
address@hidden and then use @code{$FGREP}.
+
+
 @item @command{find}
 @c -----------------
 The option @option{-maxdepth} seems to be GNU specific. Tru64 v5.1,
@@ -9815,7 +9841,7 @@ status of @code{grep} to determine wheth
 Don't use multiple regexps with @option{-e}, as some @code{grep} will only
 honor the last pattern (eg., IRIX 6.5 and Solaris 2.5.1).  Anyway,
 Stardent Vistra SVR4 @code{grep} lacks @address@hidden  Instead, use
-alternation and @code{egrep}.
+extended regular expressions and alternation.
 
 
 @item @command{ln}
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.163
diff -p -u -r1.163 c.m4
--- lib/autoconf/c.m4   20 Apr 2002 06:09:02 -0000      1.163
+++ lib/autoconf/c.m4   29 May 2002 22:10:10 -0000
@@ -887,10 +887,10 @@ short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x
 short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
 void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]],
 [[ _ascii (); _ebcdic (); ]])],
-[if fgrep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
+[if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
   ac_cv_c_bigendian=yes
 fi
-if fgrep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
   if test "$ac_cv_c_bigendian" = unknown; then
     ac_cv_c_bigendian=no
   else
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.797
diff -p -u -r1.797 general.m4
--- lib/autoconf/general.m4     25 Apr 2002 08:54:47 -0000      1.797
+++ lib/autoconf/general.m4     29 May 2002 22:10:11 -0000
@@ -1977,7 +1977,7 @@ AC_DEFUN([_AC_RUN_LOG_STDERR],
 [{ ($2) >&AS_MESSAGE_LOG_FD
   ($1) 2>conftest.er1
   ac_status=$?
-  egrep -v '^ *\+' conftest.er1 >conftest.err
+  grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&AS_MESSAGE_LOG_FD
   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
@@ -2090,12 +2090,13 @@ AC_DEFUN([AC_TRY_CPP],
 # come early, it is not included in AC_BEFORE checks.
 AC_DEFUN([AC_EGREP_CPP],
 [AC_LANG_PREPROC_REQUIRE()dnl
+AC_REQUIRE([AC_PROG_EGREP])dnl
 AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])])
 dnl eval is necessary to expand ac_cpp.
 dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
 if (eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
 dnl Quote $1 to prevent m4 from eating character classes
-  egrep "[$1]" >/dev/null 2>&1; then
+  $EGREP "[$1]" >/dev/null 2>&1; then
   m4_default([$3], :)
 m4_ifvaln([$4], [else
   $4])dnl
Index: lib/autoconf/Makefile.am
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/Makefile.am,v
retrieving revision 1.17
diff -p -u -r1.17 Makefile.am
--- lib/autoconf/Makefile.am    5 Feb 2002 08:24:06 -0000       1.17
+++ lib/autoconf/Makefile.am    29 May 2002 22:10:11 -0000
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 
-## Copyright 2001 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
 ##
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ ETAGS_ARGS = --lang=none \
 
 check-local:
        if (cd $(srcdir) && \
-           egrep '^_?EOF' $(dist_autoconflib_DATA)) >eof.log; then \
+           grep '^_*EOF' $(dist_autoconflib_DATA)) >eof.log; then \
          echo "ERROR: user EOF tags were used:" >&2; \
          sed "s,^,$*.m4: ," <eof.log >&2; \
          echo >&2; \
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.10
diff -p -u -r1.10 programs.m4
--- lib/autoconf/programs.m4    19 Apr 2002 19:04:35 -0000      1.10
+++ lib/autoconf/programs.m4    29 May 2002 22:10:11 -0000
@@ -259,6 +259,31 @@ AC_DEFUN([AC_PROG_AWK],
 [AC_CHECK_PROGS(AWK, gawk mawk nawk awk, )])
 
 
+# AC_PROG_EGREP
+# -------------
+AC_DEFUN([AC_PROG_EGREP],
+[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+   [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi])
+ EGREP=$ac_cv_prog_egrep
+ AC_SUBST([EGREP])
+])# AC_PROG_EGREP
+
+# AC_PROG_FGREP
+# -------------
+AC_DEFUN([AC_PROG_FGREP],
+[AC_CACHE_CHECK([for fgrep], [ac_cv_prog_fgrep],
+   [if echo 'ab*c' | (grep -F 'ab*c') >/dev/null 2>&1
+    then ac_cv_prog_fgrep='grep -F'
+    else ac_cv_prog_fgrep='fgrep'
+    fi])
+ FGREP=$ac_cv_prog_fgrep
+ AC_SUBST([FGREP])
+])# AC_PROG_FGREP
+
+
 # AC_PROG_INSTALL
 # ---------------
 AC_DEFUN([AC_PROG_INSTALL],
Index: lib/autoconf/status.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.25
diff -p -u -r1.25 status.m4
--- lib/autoconf/status.m4      25 Apr 2002 08:54:48 -0000      1.25
+++ lib/autoconf/status.m4      29 May 2002 22:10:12 -0000
@@ -577,7 +577,7 @@ _ACEOF
 # Break up conftest.defines because some shells have a limit on the size
 # of here documents, and old seds have small limits too (100 cmds).
 echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo '  if egrep ["^[  ]*#[    ]*define"] $tmp/in >/dev/null; then' 
>>$CONFIG_STATUS
+echo '  if grep ["^[   ]*#[    ]*define"] $tmp/in >/dev/null; then' 
>>$CONFIG_STATUS
 echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
 echo '  :' >>$CONFIG_STATUS
 rm -f conftest.tail
@@ -601,7 +601,7 @@ do
   mv conftest.tail conftest.defines
 done
 rm -f conftest.defines
-echo '  fi # egrep' >>$CONFIG_STATUS
+echo '  fi # grep' >>$CONFIG_STATUS
 echo >>$CONFIG_STATUS
 
 # Break up conftest.undefs because some shells have a limit on the size
Index: lib/autoconf/types.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/types.m4,v
retrieving revision 1.17
diff -p -u -r1.17 types.m4
--- lib/autoconf/types.m4       28 May 2002 04:13:07 -0000      1.17
+++ lib/autoconf/types.m4       29 May 2002 22:10:12 -0000
@@ -1,7 +1,6 @@
 # This file is part of Autoconf.                       -*- Autoconf -*-
 # Type related macros: existence, sizeof, and structure members.
-# Copyright 2000, 2001
-# Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -83,8 +82,8 @@
 # Check whether the type TYPE is supported by the system, maybe via the
 # the provided includes.  This macro implements the former task of
 # AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
-# grepping in the headers, which, BTW, led to many problems until
-# the egrep expression was correct and did not given false positives.
+# grepping in the headers, which, BTW, led to many problems until the
+# extended regular expression was correct and did not given false positives.
 # It turned out there are even portability issues with egrep...
 #
 # The most obvious way to check for a TYPE is just to compile a variable
Index: lib/autotest/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autotest/general.m4,v
retrieving revision 1.133
diff -p -u -r1.133 general.m4
--- lib/autotest/general.m4     21 Apr 2002 06:35:08 -0000      1.133
+++ lib/autotest/general.m4     29 May 2002 22:10:12 -0000
@@ -251,7 +251,7 @@ while test address@hidden:@] -gt 0; do
         do
           # It is on purpose that we match the test group titles too.
           at_groups_selected=`echo "$at_groups_selected" |
-                             egrep -i "^[[^;]]*;[[^;]]*;.*$at_keyword"`
+                             grep -i "^[[^;]]*;[[^;]]*;.*$at_keyword"`
         done
         at_groups_selected=`echo "$at_groups_selected" | sed 's/;.*//'`
        # Smash the end of lines.
@@ -335,10 +335,9 @@ AT_TESTSUITE_NAME test groups:
 _ATEOF
   # "  1 42  45 " => "^(1|42|45);".
   at_groups_pattern=`echo "$at_groups" | sed 's/^  *//;s/  *$//;s/  */|/g'`
-  at_groups_pattern="^(${at_groups_pattern});"
   echo "$at_help_all" |
-    egrep -e "$at_groups_pattern" |
     awk 'BEGIN { FS = ";" }
+         { if ($[1] !~ /^('"$at_groups_pattern"')$/) next }
          { if ($[1]) printf " %3d: %-18s %s\n", $[1], $[2], $[3]
            if ($[4]) printf "      %s\n", $[4] } '
   exit 0
@@ -849,8 +848,8 @@ $at_verbose "AT_LINE: AS_ESCAPE([$1])"
 echo AT_LINE >$at_check_line_file
 ( $at_traceon; $1 ) >$at_stdout 2>$at_stder1
 at_status=$?
-egrep '^ *\+' $at_stder1 >&2
-egrep -v '^ *\+' $at_stder1 >$at_stderr
+grep '^ *+' $at_stder1 >&2
+grep -v '^ *+' $at_stder1 >$at_stderr
 at_failed=false
 dnl Check stderr.
 m4_case([$4],
Index: lib/autotest/Makefile.am
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autotest/Makefile.am,v
retrieving revision 1.7
diff -p -u -r1.7 Makefile.am
--- lib/autotest/Makefile.am    6 Feb 2002 17:29:44 -0000       1.7
+++ lib/autotest/Makefile.am    29 May 2002 22:10:12 -0000
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 
-## Copyright 2001, 2002 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002 Free Software Foundation, Inc.
 ##
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@ ETAGS_ARGS = --lang=none \
 
 check-local:
        if (cd $(srcdir) && \
-           egrep '^_?EOF' $(dist_autotestlib_DATA)) >eof.log; then \
+           grep '^_*EOF' $(dist_autotestlib_DATA)) >eof.log; then \
          echo "ERROR: user EOF tags were used:" >&2; \
          sed "s,^,$*.m4: ," <eof.log >&2; \
          echo >&2; \
Index: lib/m4sugar/Makefile.am
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/Makefile.am,v
retrieving revision 1.8
diff -p -u -r1.8 Makefile.am
--- lib/m4sugar/Makefile.am     5 Feb 2002 08:24:06 -0000       1.8
+++ lib/m4sugar/Makefile.am     29 May 2002 22:10:12 -0000
@@ -57,7 +57,7 @@ ETAGS_ARGS = --lang=none \
 
 check-local:
        if (cd $(srcdir) && \
-           egrep '^_?EOF' $(dist_m4sugarlib_DATA)) >eof.log; then \
+           grep '^_*EOF' $(dist_m4sugarlib_DATA)) >eof.log; then \
          echo "ERROR: user EOF tags were used:" >&2; \
          sed "s,^,$*.m4: ," <eof.log >&2; \
          echo >&2; \
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.242
diff -p -u -r1.242 NEWS
--- NEWS        28 May 2002 04:15:52 -0000      1.242
+++ NEWS        29 May 2002 22:10:13 -0000
@@ -20,7 +20,7 @@
 - AC_FUNC_SETVBUF_REVERSED no longer fails when cross-compiling.
 - AC_PROG_CC_STDC is integrated into AC_PROG_CC.
 - AC_PROG_F77 default search no longer includes cf77 and cfg77.
-- New macros: AC_GNU_SOURCE, AC_TYPE_MBSTATE_T.
+- New macros: AC_GNU_SOURCE, AC_PROG_EGREP, AC_PROG_FGREP, AC_TYPE_MBSTATE_T.
 
 ** Bug fixes
 
@@ -34,10 +34,14 @@
 - AC_PATH_PROG
   Now colon in the optional path arguments are properly handled.
 
-** Improved Zsh portability
-  Both Autoconf the package, and the scripts it produces, should run
+** Improved portability
+
+- Both Autoconf the package, and the scripts it produces, should run
   more reliably with Zsh.  Bear in mind it is the default Bourne shell
   on Darwin.
+
+- Autoconf and the scripts it produces no longer assume the existence of
+  the obsolescent commands egrep and fgrep.
 
 ** Documentation
 
Index: tests/atspecific.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/atspecific.m4,v
retrieving revision 1.69
diff -p -u -r1.69 atspecific.m4
--- tests/atspecific.m4 20 Apr 2002 06:09:02 -0000      1.69
+++ tests/atspecific.m4 29 May 2002 22:10:13 -0000
@@ -123,12 +123,12 @@ m4_define([AT_CONFIGURE_AC],
 # we can ask help from AC_SUBST.  We have the right to touch what
 # is AC_SUBST'ed.
 #
-# Some `egrep' choke on such a big regex (e.g., SunOS 4.1.3).  In this
-# case just don't pay attention to the env.  It would be great
+# Perhaps grep -E is not supported, or perhaps it chokes on such a big regex.
+# In this case just don't pay attention to the env.  It would be great
 # to keep the error message but we can't: that would break AT_CHECK.
 m4_defun([AC_STATE_SAVE],
 [(set) 2>&1 |
-  egrep -v -e 'm4_join([|],
+  grep -E -v -e 'm4_join([|],
       [^a[cs]_],
       [^((exec_)?prefix|DEFS|CONFIG_STATUS)=],
       [^(CC|CFLAGS|CPP|GCC|CXX|CXXFLAGS|CXXCPP|GXX|F77|FFLAGS|FLIBS|G77)=],
@@ -148,7 +148,7 @@ m4_defun([AC_STATE_SAVE],
   grep '^m4_defn([m4_re_word])=' >address@hidden&address@hidden
 test $? = 0 || rm -f address@hidden&address@hidden
 
-ls -1 | egrep -v '^(at-|state-|config\.)' | sort >address@hidden&address@hidden
+ls -1 | sed '/^at-/d;/^state-/d;/^config\./d' | sort 
>address@hidden&address@hidden
 ])# AC_STATE_SAVE
 ]])
 
@@ -220,8 +220,17 @@ fi
 # and symbols (PACKAGE_...).
 # AT_CHECK_HEADER is a better name, but too close from AC_CHECK_HEADER.
 m4_define([AT_CHECK_DEFINES],
-[AT_CHECK([[fgrep '#' config.h |
- egrep -v 
'STDC_HEADERS|STD(INT|LIB)|INTTYPES|MEMORY|PACKAGE_|STRING|SYS_(TYPES|STAT)|UNISTD']],,
+[AT_CHECK([[sed '/#/!d
+/INTTYPES/d
+/MEMORY/d
+/PACKAGE_/d
+/STDC_HEADERS/d
+/STDINT/d
+/STDLIB/d
+/STRING/d
+/SYS_STAT/d
+/SYS_TYPES/d
+/UNISTD/d' config.h]],,
           [$1])])
 
 
Index: tests/mktests.sh
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.24
diff -p -u -r1.24 mktests.sh
--- tests/mktests.sh    2 Apr 2002 18:22:08 -0000       1.24
+++ tests/mktests.sh    29 May 2002 22:10:13 -0000
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Build some of the Autoconf test files.
-# Copyright 2000, 2001 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -137,7 +137,7 @@ _AC_'
 
 # ac_exclude_egrep
 # ----------------
-# Build a single egrep pattern out of filter_macros_list.
+# Build a single extended regular expression out of filter_macros_list.
 # Sed is used to get rid of the trailing `|' coming from the trailing
 # `\n' from `echo'.
 ac_exclude_egrep=`echo "$exclude_list$ac_exclude_list" | tr '
@@ -165,13 +165,20 @@ au_exclude_list='^AC_LANG_RESTORE$
 
 # au_exclude_egrep
 # ----------------
-# Build a single egrep pattern out of filter_macros_list.
+# Build a single extended regular expression out of filter_macros_list.
 # Sed is used to get rid of the trailing `|' coming from the trailing
 # `\n' from `echo'.
 au_exclude_egrep=`echo "$exclude_list$au_exclude_list" | tr '
 ' '|' | sed 's/.$//'`
 
 
+# egrep
+# -----
+if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+then egrep='grep -E'
+else egrep='egrep'
+fi
+
 
 ## ------------------------- ##
 ## Creating the test files.  ##
@@ -188,14 +195,14 @@ do
     sort |
     uniq |
     # Watch out we are `set -e': don't fail.
-    ( egrep -v "$ac_exclude_egrep" || true) >acdefuns
+    ($egrep -v "$ac_exclude_egrep" || true) >acdefuns
 
   # Get the list of macros which are defined in Autoupdate level.
   cat $file |
     sed -n 's/^AU_DEFUN(\[*\([a-zA-Z][a-zA-Z0-9_]*\).*$/\1/p' |
     sort |
     uniq |
-    ( egrep -v "$au_exclude_egrep" || true) > audefuns
+    ($egrep -v "$au_exclude_egrep" || true) > audefuns
 
   # Filter out required macros.
   {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]