Blame SOURCES/zeromq-configure-c99.patch

c09f90
Build with -D_DEFAULT_SOURCE along with -std=c11
c09f90
    
c09f90
On its own, -std=c11 hides POSIX and other extensions from C headers
c09f90
such as <stdlib.h> when building against glibc. This causes the
c09f90
posix_memalign probe to fail incorrectly with compilers that do not
c09f90
accept implicit function declarations. _DEFAULT_SOURCE is ignored by
c09f90
most non-GNU/Linux systems or not relevant in this context, so there
c09f90
is no separate check for adding it.
c09f90
c09f90
Submitted upstream: <https://github.com/zeromq/libzmq/pull/4635>
c09f90
c09f90
diff --git a/CMakeLists.txt b/CMakeLists.txt
c09f90
index 68fb7251..f956f3fd 100644
c09f90
--- a/CMakeLists.txt
c09f90
+++ b/CMakeLists.txt
c09f90
@@ -122,7 +122,7 @@ if (NOT MSVC)
c09f90
   if(NOT CMAKE_C_FLAGS MATCHES "-std=" AND NOT C_STANDARD AND NOT CMAKE_C_STANDARD)
c09f90
     check_c_compiler_flag("-std=c11" COMPILER_SUPPORTS_C11)
c09f90
     if(COMPILER_SUPPORTS_C11)
c09f90
-      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
c09f90
+      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_DEFAULT_SOURCE -std=c11")
c09f90
     else()
c09f90
       set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
c09f90
     endif()
c09f90
diff --git a/configure.ac b/configure.ac
c09f90
index b9e13d4f..ffcc145b 100644
c09f90
--- a/configure.ac
c09f90
+++ b/configure.ac
c09f90
@@ -66,7 +66,7 @@ ZMQ_ORIG_CXXFLAGS="${CXXFLAGS:-none}"
c09f90
 
c09f90
 # Checks for programs.
c09f90
 AC_PROG_CC
c09f90
-AX_CHECK_COMPILE_FLAG([-std=c11], [CFLAGS+=" -std=c11"], [AC_PROG_CC_C99])
c09f90
+AX_CHECK_COMPILE_FLAG([-std=c11], [CFLAGS+=" -std=c11 -D_DEFAULT_SOURCE"], [AC_PROG_CC_C99])
c09f90
 AC_PROG_CXX
c09f90
 AX_CODE_COVERAGE
c09f90
 AM_PROG_CC_C_O