Add support for BeOS.
[gnulib.git] / m4 / jm-glibc-io.m4
index e6ff4da..d485b10 100644 (file)
@@ -1,24 +1,35 @@
-#serial 1
+#serial 4
 
 dnl From Jim Meyering.
 dnl
 dnl See if the glibc *_unlocked I/O macros are available.
+dnl Use only those *_unlocked macros that are declared.
 dnl
 
 AC_DEFUN(jm_FUNC_GLIBC_UNLOCKED_IO,
-  [AC_CHECK_FUNCS(                             \
-    clearerr_unlocked                          \
-    fclose_unlocked                            \
-    feof_unlocked                              \
-    ferror_unlocked                            \
-    fflush_unlocked                            \
-    fputc_unlocked                             \
-    fread_unlocked                             \
-    fwrite_unlocked                            \
-    getc_unlocked                              \
-    getchar_unlocked                           \
-    putc_unlocked                              \
-    putchar_unlocked                           \
-   )
+  [
+    # Kludge (not executed) to make autoheader do the right thing.
+    if test a = b; then
+      AC_CHECK_DECLS([clearerr_unlocked, feof_unlocked, ferror_unlocked,
+       fflush_unlocked, fputc_unlocked, fread_unlocked, fwrite_unlocked,
+       getc_unlocked, getchar_unlocked, putc_unlocked, putchar_unlocked])
+    fi
+
+    io_functions='clearerr_unlocked feof_unlocked ferror_unlocked
+    fflush_unlocked fputc_unlocked fread_unlocked fwrite_unlocked
+    getc_unlocked getchar_unlocked putc_unlocked putchar_unlocked'
+    for jm_io_func in $io_functions; do
+      # Check for the existence of each function only if its declared.
+      # Otherwise, we'd get the Solaris5.5.1 functions that are not
+      # declared, and that have been removed from Solaris5.6.  The resulting
+      # 5.5.1 binaries would not run on 5.6 due to shared library differences.
+      AC_CHECK_DECLS([$jm_io_func],
+                    jm_declared=yes,
+                    jm_declared=no,
+                    [#include <stdio.h>])
+      if test $jm_declared = yes; then
+        AC_CHECK_FUNCS($jm_io_func)
+      fi
+    done
   ]
 )