]> granicus.if.org Git - json-c/commitdiff
Issue #396: check for toolchain compatibilty with _REENTRANT before adding it to...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Mon, 5 Mar 2018 03:32:45 +0000 (22:32 -0500)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Mon, 5 Mar 2018 03:32:45 +0000 (22:32 -0500)
configure.ac

index ef556ebc89b78de4a30b21da611e61be8d9b795d..272ea6af9c3b42e23b4ede4712b204a9ec1e6104 100644 (file)
@@ -167,7 +167,28 @@ AC_SUBST(JSON_BSYMBOLIC_LDFLAGS)
 
 AX_APPEND_COMPILE_FLAGS([-Wall -Werror -Wcast-qual -Wno-error=deprecated-declarations])
 AX_APPEND_COMPILE_FLAGS([-Wextra -Wwrite-string -Wno-unused-parameter])
-AX_APPEND_COMPILE_FLAGS([-D_GNU_SOURCE -D_REENTRANT])
+AX_APPEND_COMPILE_FLAGS([-D_GNU_SOURCE])
+
+AC_LANG_PUSH([C])
+AC_MSG_CHECKING([for compatibility with _REENTRANT and toolchain headers])
+AC_LINK_IFELSE(
+[
+ AC_LANG_SOURCE([[
+/* uClibc toolchains without threading barf when _REENTRANT is defined */
+#define _REENTRANT 1
+#include <sys/types.h>
+int main ()
+{
+  return 0;
+}
+]])], [
+    AC_MSG_RESULT(yes)
+    AX_APPEND_COMPILE_FLAGS([-D_REENTRANT])
+], [
+    AC_MSG_RESULT(no)
+])
+AC_LANG_POP([C])
+
 
 AX_COMPILE_CHECK_SIZEOF(int)
 AX_COMPILE_CHECK_SIZEOF(long)