+
+dnl Old glib headers expect gcc to provide GNU inline semantics by default.
+dnl This is not the case with modern gcc if the language standard is set to
+dnl C99 or later. This results is linker failures due to multiple definitions
+dnl when two source files include the GLib headers.
+dnl
+dnl Pre-#defining G_INLINE_FUNC to 'static inline' works to avoid this problem,
+dnl so we have configure first test to see if the problem occurs, then test
+dnl if this definition fixes it, then AC_DEFINE that if necessary.
+AC_DEFUN([DX_LIB_GLIB_BUSTED_GNU_INLINE],
+[AC_CACHE_CHECK([whether GLib needs obsolete GNU inline semantics],
+[dx_cv_glib_busted_gnu_inline],
+[save_CFLAGS=$CFLAGS save_LIBS=$LIBS CFLAGS="$LIBGLIB_CFLAGS $CFLAGS"
+LIBS="conftest_bar.$OBJEXT $LIBGLIB_LIBS $save_LIBS"
+dx_cv_glib_busted_gnu_inline=unknown
+for dx_cv_glib_inline_workaround in no G_INLINE_FUNC G_IMPLEMENT_INLINES; do
+AS_CASE([$dx_cv_glib_inline_workaround],
+[G_INLINE_FUNC], [DEFTEST='#define G_INLINE_FUNC static inline' ret=yes
+], [G_IMPLEMENT_INLINES], [DEFTEST='#define G_IMPLEMENT_INLINES 1' ret=yes
+], [DEFTEST= ret=no
+])
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([$DEFTEST
+#include <glib.h>
+int bar(void) { return 0; }])],
+[mv -f conftest.$OBJEXT conftest_bar.$OBJEXT],
+[continue])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([$DEFTEST
+#include <glib.h>
+extern int bar(void);], [return bar();])],
+[dx_cv_glib_busted_gnu_inline=$ret; break])
+rm -f conftest_bar.$OBJEXT
+done
+CFLAGS=$save_CFLAGS LIBS=$save_LIBS])
+AS_CASE([$dx_cv_glib_inline_workaround],
+[G_INLINE_FUNC], [AC_DEFINE([G_INLINE_FUNC], [static inline],
+ [Define to static inline to work around multiple definitions in old GLib.])
+], [G_IMPLEMENT_INLINES], [AC_DEFINE([G_IMPLEMENT_INLINES], [1],
+ [If G_INLINE_FUNC cannot work around multiple definition issues,
+ define to 1 to disable inlining altogether in GLib.])
+])])