[21.5] Remove deprecation warnings for _BSD_SOURCE and _SVID_SOURCE

Mats Lidell <[email protected]> Thu, 09 Jul 2015 22:53:09 +0200
Newsgroups gmane.emacs.xemacs.patches
Organization The XEmacs Project
Message-ID <[email protected]>
Hi,

With glib 2.20 _BSD_SOURCE and _SVID_SOURCE are deprecated and give as
preprocessor warning. 

    See: http://man7.org/linux/man-pages/man7/feature_test_macros.7.html

The warning is annoying and the patch outline below is an attempt to
get rid of it. In later releases of glibc this will be an error. The
method used in the patch is to also define _DEFAULT_SOURCE if one of
the feature test macros are defined.

Since I don't fiddle with autoconf that often please check if this is
the proper way to do this.

Other things to consider is that since we get the flags from xmkmf
maybe that program will be updated to handle the deprecation as well
(so we might just have to stick it out for a while!?) I have searched
the net but found no trace of activity in that direction (and I don't
like the idea of warnings filling the screen anyway even if it will
only be for a year or two ;-) So some action on our part seems needed.

A more thorough analysis would also consider if we really need the
functionality in glibc provided by these feature macros. Maybe they
can be removed?

Here is the patch

# HG changeset patch
# User Mats Lidell <[email protected]>
# Date 1436473365 -7200
#      Thu Jul 09 22:22:45 2015 +0200
# Node ID 3d2fee93ca067038971c58c34e2f68bf2e8d40a5
# Parent  cb65bfaf7110db022418813ef36e1d6e502d5628
imported patch default_source_deprecation

diff -r cb65bfaf7110 -r 3d2fee93ca06 configure
--- a/configure	Fri Mar 27 16:05:15 2015 +0100
+++ b/configure	Thu Jul 09 22:22:45 2015 +0200
@@ -13523,6 +13523,17 @@
     done
   fi
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking Check if _DEFAULT_SOURCE is needed" >&5
+$as_echo_n "checking Check if _DEFAULT_SOURCE is needed... " >&6; }
+  if grep "^#define _BSD_SOURCE " confdefs.h >/dev/null &&\
+	grep "^#define _SVID_SOURCE " confdefs.h >/dev/null &&\
+	grep -v "^#define _DEFAULT_SOURCE " confdefs.h >/dev/null; then
+      	cat >>confdefs.h <<_ACEOF
+#define _DEFAULT_SOURCE 1
+_ACEOF
+
+  fi
+
     ac_fn_c_check_header_mongrel "$LINENO" "X11/Intrinsic.h" "ac_cv_header_X11_Intrinsic_h" "$ac_includes_default"
 if test "x$ac_cv_header_X11_Intrinsic_h" = xyes; then :
 
diff -r cb65bfaf7110 -r 3d2fee93ca06 configure.ac
--- a/configure.ac	Fri Mar 27 16:05:15 2015 +0100
+++ b/configure.ac	Thu Jul 09 22:22:45 2015 +0200
@@ -3144,6 +3144,14 @@
       esac
     done
   fi
+  
+  dnl Check if we need to define _DEFAULT_SOURCE
+  AC_MSG_CHECKING([Check if _DEFAULT_SOURCE is needed])
+  if grep "^#define _BSD_SOURCE " confdefs.h >/dev/null &&\
+	grep "^#define _SVID_SOURCE " confdefs.h >/dev/null &&\
+	grep -v "^#define _DEFAULT_SOURCE " confdefs.h >/dev/null; then
+      	AC_DEFINE_UNQUOTED(_DEFAULT_SOURCE,1)
+  fi	 
 
   dnl make sure we can find Intrinsic.h
   AC_CHECK_HEADER(X11/Intrinsic.h, ,
diff -r cb65bfaf7110 -r 3d2fee93ca06 src/config.h.in
--- a/src/config.h.in	Fri Mar 27 16:05:15 2015 +0100
+++ b/src/config.h.in	Thu Jul 09 22:22:45 2015 +0200
@@ -226,6 +226,7 @@
 #undef _POSIX_SOURCE
 #undef _BSD_SOURCE
 #undef _SVID_SOURCE
+#undef _DEFAULT_SOURCE
 #undef X_LOCALE
 #undef NARROWPROTO
 #endif /* HAVE_X_WINDOWS */


Yours
-- 
%% Mats