fnmatch, fnmatch-gnu: Fix compilation error on Mac OS X.
authorBruno Haible <bruno@clisp.org>
Tue, 14 Aug 2018 00:00:05 +0000 (02:00 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 14 Aug 2018 00:10:45 +0000 (02:10 +0200)
Reported by Jeroen Meijer <jjgmeijer@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-08/msg00046.html>
and by Paul J. Lucas <paul@lucasmail.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2018-08/msg00069.html>.

* m4/fnmatch_h.m4 (gl_FNMATCH_H): Define through AC_DEFUN_ONCE.
(gl_FNMATCH_H_GNU): New macro.
* m4/fnmatch.m4 (gl_FUNC_FNMATCH_GNU): Require gl_FNMATCH_H_GNU.

ChangeLog
m4/fnmatch.m4
m4/fnmatch_h.m4

index 33b1c35e485b6ec9f69d8c7e9c21a8822f088941..1f39653aeba1eaeceedcb8a04b6fadc373cfd221 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2018-08-13  Bruno Haible  <bruno@clisp.org>
+
+       fnmatch, fnmatch-gnu: Fix compilation error on Mac OS X.
+       Reported by Jeroen Meijer <jjgmeijer@gmail.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2018-08/msg00046.html>
+       and by Paul J. Lucas <paul@lucasmail.org> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2018-08/msg00069.html>.
+       * m4/fnmatch_h.m4 (gl_FNMATCH_H): Define through AC_DEFUN_ONCE.
+       (gl_FNMATCH_H_GNU): New macro.
+       * m4/fnmatch.m4 (gl_FUNC_FNMATCH_GNU): Require gl_FNMATCH_H_GNU.
+
 2018-08-11  Bruno Haible  <bruno@clisp.org>
 
        setlocale: Trivial simplification.
@@ -11,7 +22,7 @@
 
 2018-08-10  Bruno Haible  <bruno@clisp.org>
 
-       fnmatch: Fix compilation error in C++ namespace mode on Mac OS X.
+       fnmatch-gnu: Fix compilation error in C++ namespace mode on Mac OS X.
        * modules/fnmatch-gnu (configure.ac): Invoke gl_MODULE_INDICATOR.
        * lib/fnmatch.in.h (fnmatch): Skip _GL_CXXALIASWARN if module
        'fnmatch-gnu' is in use.
index e6eb9f9d947e5862af177826eb20827d02041c4a..2dbfa04475e81aa4472c8f64f926b3a50e6e1512 100644 (file)
@@ -1,4 +1,4 @@
-# Check for fnmatch - serial 10.  -*- coding: utf-8 -*-
+# Check for fnmatch - serial 11.  -*- coding: utf-8 -*-
 
 # Copyright (C) 2000-2007, 2009-2018 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -135,6 +135,7 @@ AC_DEFUN([gl_FUNC_FNMATCH_GNU],
 [
   m4_divert_text([INIT_PREPARE], [gl_fnmatch_required=GNU])
 
+  AC_REQUIRE([gl_FNMATCH_H_GNU])
   AC_REQUIRE([gl_FUNC_FNMATCH_POSIX])
 ])
 
index c40d0a713b331152c64aeba6925b704ecd1b8998..f36557822a9fe1b24fa237d75e357f875383805e 100644 (file)
@@ -1,4 +1,4 @@
-# fnmatch_h.m4 serial 2
+# fnmatch_h.m4 serial 3
 dnl Copyright (C) 2009-2018 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,7 +6,8 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl From Bruno Haible.
 
-AC_DEFUN([gl_FNMATCH_H],
+# Request a POSIX compliant <fnmatch.h> include file.
+AC_DEFUN_ONCE([gl_FNMATCH_H],
 [
   AC_REQUIRE([gl_FNMATCH_H_DEFAULTS])
   m4_ifdef([gl_ANSI_CXX], [AC_REQUIRE([gl_ANSI_CXX])])
@@ -49,6 +50,27 @@ AC_DEFUN([gl_FNMATCH_H],
     [fnmatch])
 ])
 
+# Request a POSIX compliant <fnmatch.h> include file with GNU extensions.
+AC_DEFUN([gl_FNMATCH_H_GNU],
+[
+  AC_REQUIRE([gl_FNMATCH_H])
+  if test -z "$FNMATCH_H"; then
+    AC_CACHE_CHECK([whether <fnmatch.h> has the GNU extensions],
+      [gl_cv_header_fnmatch_h_gnu],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <fnmatch.h>]],
+            [[int gnu_flags = FNM_FILE_NAME | FNM_LEADING_DIR | FNM_CASEFOLD | FNM_EXTMATCH;]])],
+         [gl_cv_header_fnmatch_h_gnu=yes],
+         [gl_cv_header_fnmatch_h_gnu=no])
+      ])
+    if test $gl_cv_header_fnmatch_h_gnu != yes; then
+      FNMATCH_H=fnmatch.h
+      AM_CONDITIONAL([GL_GENERATE_FNMATCH_H], [test -n "$FNMATCH_H"])
+    fi
+  fi
+])
+
 AC_DEFUN([gl_FNMATCH_MODULE_INDICATOR],
 [
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.