[PATCH libxtrans] configure: under glibc define _GNU_SOURCE rather then _BSD_SOURCE

Hans de Goede hdegoede at redhat.com
Sun Mar 2 23:56:36 PST 2014


The latest glibc considers _BSD_SOURCE deprecated, leading to the following
warning being issued for pretty much every C-file in the xserver:

In file included from /usr/include/stdint.h:25:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/stdint.h:9,
                 from ../include/misc.h:81,
                 from miexpose.c:82:
/usr/include/features.h:145:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^

This silences up these warnings by switching to _GNU_SOURCE, which also
includes all the necessary functions from BSD.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 configure.ac | 14 ++++++++++++++
 xtrans.pc.in |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 6898c6d..735c77f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,20 @@ sticky_bit_define="-DHAS_STICKY_DIR_BIT"
 
 AC_SUBST(sticky_bit_define)
 
+# We need some BSD extensions, but the latest glibc does a #warn when using
+# _BSD_SOURCE
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <features.h>
+#ifndef __GLIBC__
+#error not glibc
+#endif
+]], [])],
+source_level_define="-D_GNU_SOURCE",
+source_level_define="-D_BSD_SOURCE")
+
+AC_SUBST(source_level_define)
+
 AC_CONFIG_FILES([Makefile
 		doc/Makefile
 		xtrans.pc])
diff --git a/xtrans.pc.in b/xtrans.pc.in
index 90d19b1..1fa83cc 100644
--- a/xtrans.pc.in
+++ b/xtrans.pc.in
@@ -6,4 +6,4 @@ includedir=@includedir@
 Name: XTrans
 Description: Abstract network code for X
 Version: @PACKAGE_VERSION@
-Cflags: -I${includedir} -D_BSD_SOURCE @fchown_define@ @sticky_bit_define@
+Cflags: -I${includedir} @source_level_define@ @fchown_define@ @sticky_bit_define@
-- 
1.9.0



More information about the xorg-devel mailing list