8172712: configure should check that grep handles empty pattern correctly
authorstuefe
Thu, 12 Jan 2017 14:38:02 +0100
changeset 43050 318848ed8345
parent 43049 316f167bdc9e
child 43051 6b8a8764b1fe
8172712: configure should check that grep handles empty pattern correctly Reviewed-by: ihse
common/autoconf/basics.m4
common/autoconf/generated-configure.sh
--- a/common/autoconf/basics.m4	Thu Jan 12 14:26:57 2017 +0100
+++ b/common/autoconf/basics.m4	Thu Jan 12 14:38:02 2017 +0100
@@ -1040,12 +1040,36 @@
   AC_SUBST(TAR_SUPPORTS_TRANSFORM)
 ])
 
+AC_DEFUN([BASIC_CHECK_GREP],
+[
+  # Test that grep supports -Fx with a list of pattern which includes null pattern.
+  # This is a problem for the grep resident on AIX.
+  AC_MSG_CHECKING([that grep ($GREP) -Fx handles empty lines in the pattern list correctly])
+  # Multiple subsequent spaces..
+  STACK_SPACES='aaa   bbb   ccc'
+  # ..converted to subsequent newlines, causes STACK_LIST to be a list with some empty
+  # patterns in it.
+  STACK_LIST=${STACK_SPACES// /$'\n'}
+  NEEDLE_SPACES='ccc bbb aaa'
+  NEEDLE_LIST=${NEEDLE_SPACES// /$'\n'}
+  RESULT="$($GREP -Fvx "$STACK_LIST" <<< "$NEEDLE_LIST")"
+  if test "x$RESULT" == "x"; then
+    AC_MSG_RESULT([yes])
+  else
+    if test "x$OPENJDK_TARGET_OS" = "xaix"; then
+      ADDINFO="Please make sure you use GNU grep, usually found at /opt/freeware/bin."
+    fi
+    AC_MSG_ERROR([grep does not handle -Fx correctly. ${ADDINFO}])
+  fi
+])
+
 AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
 [
   BASIC_CHECK_GNU_MAKE
 
   BASIC_CHECK_FIND_DELETE
   BASIC_CHECK_TAR
+  BASIC_CHECK_GREP
 
   # These tools might not be installed by default,
   # need hint on how to install them.
--- a/common/autoconf/generated-configure.sh	Thu Jan 12 14:26:57 2017 +0100
+++ b/common/autoconf/generated-configure.sh	Thu Jan 12 14:38:02 2017 +0100
@@ -3731,6 +3731,8 @@
 
 
 
+
+
 # Check if build directory is on local disk. If not possible to determine,
 # we prefer to claim it's local.
 # Argument 1: directory to test
@@ -5178,7 +5180,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1484135958
+DATE_WHEN_GENERATED=1484228046
 
 ###############################################################################
 #
@@ -21251,6 +21253,29 @@
 
 
 
+  # Test that grep supports -Fx with a list of pattern which includes null pattern.
+  # This is a problem for the grep resident on AIX.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking that grep ($GREP) -Fx handles empty lines in the pattern list correctly" >&5
+$as_echo_n "checking that grep ($GREP) -Fx handles empty lines in the pattern list correctly... " >&6; }
+  # Multiple subsequent spaces..
+  STACK_SPACES='aaa   bbb   ccc'
+  # ..converted to subsequent newlines, causes STACK_LIST to be a list with some empty
+  # patterns in it.
+  STACK_LIST=${STACK_SPACES// /$'\n'}
+  NEEDLE_SPACES='ccc bbb aaa'
+  NEEDLE_LIST=${NEEDLE_SPACES// /$'\n'}
+  RESULT="$($GREP -Fvx "$STACK_LIST" <<< "$NEEDLE_LIST")"
+  if test "x$RESULT" == "x"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  else
+    if test "x$OPENJDK_TARGET_OS" = "xaix"; then
+      ADDINFO="Please make sure you use GNU grep, usually found at /opt/freeware/bin."
+    fi
+    as_fn_error $? "grep does not handle -Fx correctly. ${ADDINFO}" "$LINENO" 5
+  fi
+
+
   # These tools might not be installed by default,
   # need hint on how to install them.