From afb8aab8236d2c30c34642c755ce7c07dfc95ab2 Mon Sep 17 00:00:00 2001
From: Chris Roberts <cpr420@gmail.com>
Date: Mon, 9 Dec 2013 16:58:10 -0700
Subject: Attempt to bring glib-1 into the modern age


diff --git a/Makefile.am b/Makefile.am
index 3a6e201..f059565 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,7 +70,7 @@ configinclude_DATA = \
 
 CONFIGURE_DEPENDENCIES = acglib.m4		
 
-BUILT_SOURCES = stamp-gc-h #note: not glibconfig.h
+BUILT_SOURCES += stamp-gc-h #note: not glibconfig.h
 glibconfig.h: stamp-gc-h
 	@:
 stamp-gc-h: config.status
diff --git a/acinclude.m4 b/acinclude.m4
index 47abe43..43ed3f1 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -21,6 +21,18 @@
 ## configuration script generated by Autoconf, you may include it under
 ## the same distribution terms that you use for the rest of that program.
 
+# GLIB_AC_DIVERT_BEFORE_HELP(STUFF)
+# ---------------------------------
+# Put STUFF early enough so that they are available for $ac_help expansion.
+# Handle both classic (<= v2.13) and modern autoconf
+AC_DEFUN([GLIB_AC_DIVERT_BEFORE_HELP],
+[ifdef([m4_divert_text], [m4_divert_text([NOTICE],[$1])],
+	[ifdef([AC_DIVERT], [AC_DIVERT([NOTICE],[$1])],
+		[AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
+$1
+AC_DIVERT_POP()])])])
+
+
 # serial 40 AC_PROG_LIBTOOL
 AC_DEFUN(AC_PROG_LIBTOOL,
 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
diff --git a/configure.in b/configure.in
index 8ee9339..cad722f 100644
--- a/configure.in
+++ b/configure.in
@@ -17,7 +17,7 @@ rm -f glibconfig-sysdefs.h
 
 dnl we need to AC_DIVERT_PUSH/AC_DIVERT_POP these variable definitions so they
 dnl are available for $ac_help expansion (don't we all *love* autoconf?)
-AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
+GLIB_AC_DIVERT_BEFORE_HELP([
 #
 # The following version number definitions apply to GLib, GModule and GThread
 # as a whole, so if changes occoured in any of them, they are all
@@ -38,7 +38,7 @@ GLIB_INTERFACE_AGE=10
 GLIB_BINARY_AGE=10
 GLIB_VERSION=$GLIB_MAJOR_VERSION.$GLIB_MINOR_VERSION.$GLIB_MICRO_VERSION
 dnl
-AC_DIVERT_POP()dnl
+])
 
 AC_SUBST(GLIB_MAJOR_VERSION)
 AC_SUBST(GLIB_MINOR_VERSION)
@@ -63,7 +63,7 @@ PACKAGE=glib
 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
 
 # Specify a configuration file
-AM_CONFIG_HEADER(config.h)
+AC_CONFIG_HEADERS(config.h)
 
 AC_DEFINE_UNQUOTED(GLIB_MAJOR_VERSION, $GLIB_MAJOR_VERSION)
 AC_DEFINE_UNQUOTED(GLIB_MINOR_VERSION, $GLIB_MINOR_VERSION)
@@ -71,6 +71,7 @@ AC_DEFINE_UNQUOTED(GLIB_MICRO_VERSION, $GLIB_MICRO_VERSION)
 AC_DEFINE_UNQUOTED(GLIB_INTERFACE_AGE, $GLIB_INTERFACE_AGE)
 AC_DEFINE_UNQUOTED(GLIB_BINARY_AGE, $GLIB_BINARY_AGE)
 
+AC_CANONICAL_SYSTEM
 dnl Initialize libtool
 AM_PROG_LIBTOOL
 
@@ -81,13 +82,13 @@ AC_CANONICAL_HOST
 
 dnl figure debugging default, prior to $ac_help setup
 dnl
-AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
+GLIB_AC_DIVERT_BEFORE_HELP([
 if test `expr $GLIB_MINOR_VERSION \% 2` = 1 ; then
 	debug_default=yes
 else
 	debug_default=minimum
 fi
-AC_DIVERT_POP()dnl
+])
 
 dnl declare --enable-* args and collect ac_help strings
 AC_ARG_ENABLE(debug, [  --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,enable_debug=$debug_default)
@@ -154,7 +155,6 @@ AC_DEFINE_UNQUOTED(G_COMPILED_WITH_DEBUGGING, "${enable_debug}")
 
 # Checks for programs.
 AC_PROG_CC
-AM_PROG_CC_STDC
 AC_PROG_INSTALL
 
 changequote(,)dnl
diff --git a/gmodule/Makefile.am b/gmodule/Makefile.am
index ff4410a..5f0ce56 100644
--- a/gmodule/Makefile.am
+++ b/gmodule/Makefile.am
@@ -42,7 +42,7 @@ libgplugin_b_la_LDFLAGS = @G_MODULE_LDFLAGS@ -avoid-version -module
 libgplugin_b_la_LIBADD = @G_MODULE_LIBS@ # $(libglib)
 
 noinst_PROGRAMS = testgmodule
-testgmodule_LDFLAGS += @G_MODULE_LDFLAGS@
+testgmodule_LDFLAGS = @G_MODULE_LDFLAGS@
 testgmodule_LDADD = libgmodule.la $(libglib) @G_MODULE_LIBS@
 
 .PHONY: files release
diff --git a/gstrfuncs.c b/gstrfuncs.c
index feb4572..f3859b4 100644
--- a/gstrfuncs.c
+++ b/gstrfuncs.c
@@ -702,7 +702,7 @@ g_strsignal (gint signum)
   char *msg;
 
 #ifdef HAVE_STRSIGNAL
-  extern char *strsignal (int sig);
+  extern const char *strsignal (int sig);
   return strsignal (signum);
 #elif NO_SYS_SIGLIST
   switch (signum)
@@ -867,8 +867,7 @@ g_printf_string_upper_bound (const gchar* format,
                   /* beware of positional parameters
                    */
                 case '$':
-                  g_warning (G_GNUC_PRETTY_FUNCTION
-                             "(): unable to handle positional parameters (%%n$)");
+                  g_warning ("%s(): unable to handle positional parameters (%%n$)", G_GNUC_PRETTY_FUNCTION);
                   len += 1024; /* try adding some safety padding */
                   break;
 
@@ -1034,8 +1033,7 @@ g_printf_string_upper_bound (const gchar* format,
                   /*          n   .   dddddddddddddddddddddddd   E   +-  eeee */
                   conv_len += 1 + 1 + MAX (24, spec.precision) + 1 + 1 + 4;
                   if (spec.mod_extra_long)
-                    g_warning (G_GNUC_PRETTY_FUNCTION
-                               "(): unable to handle long double, collecting double only");
+                    g_warning ("%s(): unable to handle long double, collecting double only", G_GNUC_PRETTY_FUNCTION);
 #ifdef HAVE_LONG_DOUBLE
 #error need to implement special handling for long double
 #endif
@@ -1077,8 +1075,7 @@ g_printf_string_upper_bound (const gchar* format,
                   conv_done = TRUE;
                   if (spec.mod_long)
                     {
-                      g_warning (G_GNUC_PRETTY_FUNCTION
-                                 "(): unable to handle wide char strings");
+                      g_warning ("%s(): unable to handle wide char strings", G_GNUC_PRETTY_FUNCTION);
                       len += 1024; /* try adding some safety padding */
                     }
                   break;
@@ -1108,9 +1105,7 @@ g_printf_string_upper_bound (const gchar* format,
                   conv_len += format - spec_start;
                   break;
                 default:
-                  g_warning (G_GNUC_PRETTY_FUNCTION
-                             "(): unable to handle `%c' while parsing format",
-                             c);
+                  g_warning ("%s(): unable to handle `%c' while parsing format", G_GNUC_PRETTY_FUNCTION, c);
                   break;
                 }
               conv_done |= conv_len > 0;
-- 
1.8.3.4

