changeset 39370:eaf5ea6225e1

mkfifo: Fix compilation error on Android. * m4/mkfifo.m4 (gl_FUNC_MKFIFO): Use AC_LINK_IFELSE instead of AC_CHECK_FUNC.
author Bruno Haible <bruno@clisp.org>
date Sun, 13 May 2018 16:08:56 +0200
parents b224f0eb9bbd
children 0ccebd8753c1
files ChangeLog m4/mkfifo.m4
diffstat 2 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun May 13 16:03:03 2018 +0200
+++ b/ChangeLog	Sun May 13 16:08:56 2018 +0200
@@ -1,3 +1,9 @@
+2018-05-13  Bruno Haible  <bruno@clisp.org>
+
+	mkfifo: Fix compilation error on Android.
+	* m4/mkfifo.m4 (gl_FUNC_MKFIFO): Use AC_LINK_IFELSE instead of
+	AC_CHECK_FUNC.
+
 2018-05-13  Bruno Haible  <bruno@clisp.org>
 
 	c-strtod: Fix configure test for Android.
--- a/m4/mkfifo.m4	Sun May 13 16:03:03 2018 +0200
+++ b/m4/mkfifo.m4	Sun May 13 16:08:56 2018 +0200
@@ -1,4 +1,4 @@
-# serial 5
+# serial 6
 # See if we need to provide mkfifo replacement.
 
 dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
@@ -12,8 +12,19 @@
 [
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([mkfifo])
-  if test $ac_cv_func_mkfifo = no; then
+
+  dnl We can't use AC_CHECK_FUNC here, because mkfifo() is defined as a
+  dnl static inline function when compiling for Android 4.4 or older.
+  AC_CACHE_CHECK([for mkfifo], [gl_cv_func_mkfifo],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/stat.h>]],
+          [[return mkfifo("/",0);]])
+       ],
+       [gl_cv_func_mkfifo=yes],
+       [gl_cv_func_mkfifo=no])
+    ])
+  if test $gl_cv_func_mkfifo = no; then
     HAVE_MKFIFO=0
   else
     dnl Check for Solaris 9 and FreeBSD bug with trailing slash.