Improve cross-compilation guesses for native Windows.
authorBruno Haible <bruno@clisp.org>
Thu, 13 Jul 2017 17:46:33 +0000 (19:46 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 13 Jul 2017 17:46:33 +0000 (19:46 +0200)
* m4/memchr.m4 (gl_FUNC_MEMCHR): Add cross-compilation guess for native
Windows.
* m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE): Don't use internals of
memchr.m4.
* m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): Likewise.

ChangeLog
m4/memchr.m4
m4/strcasestr.m4
m4/strstr.m4

index 5519ae2a2b6a9ee813e1c0fa564a444d845cf889..8f7645a786ca76aa5efc180c4817c44571b99c66 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2017-07-13  Bruno Haible  <bruno@clisp.org>
+
+       Improve cross-compilation guesses for native Windows.
+       * m4/memchr.m4 (gl_FUNC_MEMCHR): Add cross-compilation guess for native
+       Windows.
+       * m4/strstr.m4 (gl_FUNC_STRSTR_SIMPLE): Don't use internals of
+       memchr.m4.
+       * m4/strcasestr.m4 (gl_FUNC_STRCASESTR_SIMPLE): Likewise.
+
 2017-07-13  Bruno Haible  <bruno@clisp.org>
 
        Improve cross-compilation guesses for native Windows.
index b6ec81401bdaa9cd20b8fb695eb8c645219096f9..62ce770c88d5fc32350ac90e058e7ffd2a00bc5c 100644 (file)
@@ -1,4 +1,4 @@
-# memchr.m4 serial 12
+# memchr.m4 serial 13
 dnl Copyright (C) 2002-2004, 2009-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,8 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
 [
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
   dnl Check for prerequisites for memory fence checks.
   gl_FUNC_MMAP_ANON
   AC_CHECK_HEADERS_ONCE([sys/mman.h])
@@ -73,12 +75,21 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
         result |= 4;
     }
   return result;
-]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no],
-      [dnl Be pessimistic for now.
-       gl_cv_func_memchr_works="guessing no"])])
-    if test "$gl_cv_func_memchr_works" != yes; then
-      REPLACE_MEMCHR=1
-    fi
+]])],
+         [gl_cv_func_memchr_works=yes],
+         [gl_cv_func_memchr_works=no],
+         [case "$host_os" in
+                    # Guess yes on native Windows.
+            mingw*) gl_cv_func_memchr_works="guessing yes" ;;
+                    # Be pessimistic for now.
+            *)      gl_cv_func_memchr_works="guessing no" ;;
+          esac
+         ])
+      ])
+    case "$gl_cv_func_memchr_works" in
+      *yes) ;;
+      *) REPLACE_MEMCHR=1 ;;
+    esac
   fi
 ])
 
index 3af9582ed6f8c4604e340b10260cc6be42bd50a6..d454ad947d6bad012dccc0b5f30f2123db26fe52 100644 (file)
@@ -1,4 +1,4 @@
-# strcasestr.m4 serial 22
+# strcasestr.m4 serial 23
 dnl Copyright (C) 2005, 2007-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_STRCASESTR_SIMPLE],
   if test $ac_cv_func_strcasestr = no; then
     HAVE_STRCASESTR=0
   else
-    if test "$gl_cv_func_memchr_works" != yes; then
+    if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
       REPLACE_STRCASESTR=1
     else
       dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092.
index 4b472ee62343bf073f5c4d433c6abb1e0ce7cb03..c6b7d649b8d8141a6eee787db281018ee7dc2636 100644 (file)
@@ -1,4 +1,4 @@
-# strstr.m4 serial 18
+# strstr.m4 serial 19
 dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
 [
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MEMCHR])
-  if test "$gl_cv_func_memchr_works" != yes; then
+  if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
     REPLACE_STRSTR=1
   else
     dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092.