[FFmpeg-devel] [PATCH v2 1/1] configure: Refactor setting of feature test macro _XOPEN_SOURCE

Jörg Krause jkrause at posteo.de
Thu Sep 18 16:22:27 CEST 2014


glibc, uclibc, and musl uses feature test macros to expose definitions 
conforming to the standards ISO C, POSIX and extensions. According to
which feature test macros are defined by the user or the compiler, 
the header file <features.h> used by these libraries internally defines
various other macros.

glibc and uclibc also defines release test macros, eg __GLIBC__ and
__UCLIBC__ in <features.h>. musl does not have (and do not want) such 
a macro like __MUSL__. 

Building ffmpeg with the musl toolchain needs the feature test macro
_XOPEN_SOURCE=600 to be defined. As it is not possible to detect musl  
check for the <features.h> header file, which is assumed to be specific 
to glibc, uclibc, and musl. 

Signed-off-by: Jörg Krause <jkrause at posteo.de>
---
Changes  v1 -> v2:
  - do not set _XOPEN_SOURCE twice for glibc and uclibc

---
 configure | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/configure b/configure
index 110a3fd..74173ae 100755
--- a/configure
+++ b/configure
@@ -4182,13 +4182,16 @@ esac
 probe_libc(){
     pfx=$1
     pfx_no_=${pfx%_}
-    # uclibc defines __GLIBC__, so it needs to be checked before glibc.
-    if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
-        eval ${pfx}libc_type=uclibc
-        add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
-    elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
-        eval ${pfx}libc_type=glibc
-        add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
+    # feature test macros are understood by glibc, uclibc, and musl
+    if check_header features.h; then
+        # _XOPEN_SOURCE=600 implicitly defines _POSIX_C_SOURCE=200112L
+        add_${pfx}cppflags -D_XOPEN_SOURCE=600
+        # uclibc defines __GLIBC__, so it needs to be checked before glibc.
+        if check_${pfx}cpp_condition features.h "defined __UCLIBC__"; then
+            eval ${pfx}libc_type=uclibc
+        elif check_${pfx}cpp_condition features.h "defined __GLIBC__"; then
+            eval ${pfx}libc_type=glibc
+    fi
     # MinGW headers can be installed on Cygwin, so check for newlib first.
     elif check_${pfx}cpp_condition newlib.h "defined _NEWLIB_VERSION"; then
         eval ${pfx}libc_type=newlib
-- 
2.1.0



More information about the ffmpeg-devel mailing list