libtool-patches
[Top][All Lists]
Advanced

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

Find best grep for AIX


From: Albert Chin
Subject: Find best grep for AIX
Date: Sun, 11 Jan 2004 19:50:05 -0600
User-agent: Mutt/1.4i

AIX has a brain-dead grep that only handles lines < 2048 characters.
So, similar to how we find the "best" sed, we find the "best" grep to
handle the longest lines.

Did I put AC_REQUIRE([LT_AC_PROG_GREP]) in the correct place? We don't
use $GREP when generating libtool, only in ltmain.in.

Also, should I replace all uses of "grep" with $GREP?

Patch against CVS head.

2004-01-11  Albert Chin-A-Young  <address@hidden>

        * ltmain.in, m4/libtool.m4: New LT_AC_PROG_GREP macro to
        find best "grep" command to match the longest lines.

-- 
albert chin (address@hidden)

-- snip snip
Index: ltmain.in
===================================================================
RCS file: /cvsroot/libtool/libtool/ltmain.in,v
retrieving revision 1.366
diff -u -3 -p -r1.366 ltmain.in
--- ltmain.in   6 Jan 2004 19:26:17 -0000       1.366
+++ ltmain.in   12 Jan 2004 01:40:42 -0000
@@ -2643,7 +2643,7 @@ EOF
                  fi
                  ;;
                esac
-               if grep "^installed=no" $deplib > /dev/null; then
+               if $GREP "^installed=no" $deplib > /dev/null; then
                  path="$absdir/$objdir"
                else
                  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
@@ -3382,7 +3382,7 @@ EOF
                  for potent_lib in $potential_libs; do
                      # Follow soft links.
                      if ls -lLd "$potent_lib" 2>/dev/null \
-                        | grep " -> " >/dev/null; then
+                        | $GREP " -> " >/dev/null; then
                        continue
                      fi
                      # The statement above tries to avoid entering an
@@ -3492,7 +3492,7 @@ EOF
            done
          fi
          if $echo "X $tmp_deplibs" | $Xsed -e 's/[     ]//g' \
-           | grep . >/dev/null; then
+           | $GREP . >/dev/null; then
            $echo
            if test "X$deplibs_check_method" = "Xnone"; then
              $echo "*** Warning: inter-library dependencies are not supported 
in this platform."
Index: m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/m4/libtool.m4,v
retrieving revision 1.29
diff -u -3 -p -r1.29 libtool.m4
--- m4/libtool.m4       7 Jan 2004 12:26:25 -0000       1.29
+++ m4/libtool.m4       12 Jan 2004 01:40:43 -0000
@@ -471,7 +471,8 @@ _LT_OUTPUT_LIBTOOL_INIT
 # add code to config.status for appending the configuration named by
 # TAGNAME from the matching tagged config vars.
 m4_define([AC_LIBTOOL_CONFIG],
-[_LT_CONFIG_SAVE_COMMANDS([
+[AC_REQUIRE([LT_AC_PROG_GREP])dnl
+_LT_CONFIG_SAVE_COMMANDS([
   # See if we are running on zsh, and set the options which allow our
   # commands through without removal of \ escapes.
   if test -n "${ZSH_VERSION+set}" ; then
@@ -5872,6 +5873,62 @@ AU_DEFUN([AM_PROG_NM],        [AC_PROG_N
 # This is just to silence aclocal about the macro not being used
 m4_if([AC_DISABLE_FAST_INSTALL])
 
+
+# LT_AC_PROG_GREP
+# --------------
+# Check for a fully-functional grep program, that handles
+# the longest lines possible. Prefer GNU grep if found.
+AC_DEFUN([LT_AC_PROG_GREP],
+[AC_MSG_CHECKING([for a grep that handles long lines])
+AC_CACHE_VAL(lt_cv_path_GREP,
+[# Loop through the user's path and test for grep and ggrep.
+# Then use that list of grep's as ones to test for.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_grep_list="$lt_ac_grep_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+lt_ac_max=0
+lt_ac_count=0
+for lt_ac_grep in $lt_ac_grep_list; do
+  test ! -f $lt_ac_grep && break
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU grep and select it if it is found.
+  if "$lt_ac_grep" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_GREP=$lt_ac_grep
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo "GREP" >>conftest.nl
+    $lt_ac_grep 'GREP$' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_GREP=$lt_ac_grep
+    fi
+  done
+done
+GREP=$lt_cv_path_GREP
+])
+AC_MSG_RESULT([$GREP])
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+])# LT_AC_PROG_GREP
 
 # LT_AC_PROG_SED
 # --------------




reply via email to

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