--- a/configure.in
+++ b/configure.in
@@ -1,10 +1,9 @@
 dnl ***********************************
 dnl *** include special GLib macros ***
 dnl ***********************************
-builtin(include, acglib.m4)dnl
 
-# require autoconf 2.13
-AC_PREREQ(2.13)
+# require autoconf 2.53
+AC_PREREQ(2.53)
 
 # init autoconf (and check for presence of glist.c)
 AC_INIT(glist.c)
@@ -13,11 +12,10 @@ AC_INIT(glist.c)
 cflags_set=${CFLAGS+set}
 
 # we rewrite this file
-rm -f glibconfig-sysdefs.h
+if test "x$cross_compiling" != "xyes"; then
+	rm -f glibconfig-sysdefs.h
+fi
 
-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
 #
 # 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 +36,6 @@ 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)
@@ -77,17 +74,13 @@ AM_PROG_LIBTOOL
 dnl Initialize maintainer mode
 AM_MAINTAINER_MODE
 
-AC_CANONICAL_HOST
-
 dnl figure debugging default, prior to $ac_help setup
 dnl
-AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)dnl
 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)
@@ -178,38 +171,6 @@ if test "x$GCC" = "xyes"; then
 fi
 changequote([,])dnl
 
-dnl DU4 native cc currently needs -std1 for ANSI mode (instead of K&R)
-AC_MSG_CHECKING([for extra flags to get ANSI library prototypes])
-glib_save_LIBS=$LIBS
-LIBS="$LIBS -lm"
-AC_TRY_RUN([#include <math.h>
-             int main (void) { return (log(1) != log(1.)); }],
-     AC_MSG_RESULT(none needed),
-     glib_save_CFLAGS=$CFLAGS
-     CFLAGS="$CFLAGS -std1"
-     AC_TRY_RUN([#include <math.h>
-                 int main (void) { return (log(1) != log(1.)); }],
-         AC_MSG_RESULT(-std1),
-         AC_MSG_RESULT()
-         CFLAGS=$glib_save_CFLAGS
-         AC_MSG_WARN(
-                [No ANSI prototypes found in library. (-std1 didn't work.)])
-     )
-)
-LIBS=$glib_save_LIBS
-
-dnl NeXTStep cc seems to need this
-AC_MSG_CHECKING([for extra flags for POSIX compliance])
-AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
-  AC_MSG_RESULT(none needed),
-  glib_save_CFLAGS=$CFLAGS
-  CFLAGS="$CFLAGS -posix"
-  AC_TRY_COMPILE([#include <dirent.h>], [DIR *dir;],
-    AC_MSG_RESULT(-posix),
-    AC_MSG_RESULT()
-    CFLAGS=$glib_save_CFLAGS
-    AC_MSG_WARN([Could not determine POSIX flag. (-posix didn't work.)])))
-
 # Checks for header files.
 AC_HEADER_STDC
 
@@ -405,11 +366,13 @@ AC_CACHE_VAL(glib_cv_sane_realloc,[
 	  return realloc (0, sizeof (int)) == 0;
 	}],
 	glib_cv_sane_realloc=yes
-	AC_DEFINE(REALLOC_0_WORKS)
 	,
 	glib_cv_sane_realloc=no
 	,)
 ])
+if test "x$glib_cv_sane_realloc" = "xyes"; then
+	AC_DEFINE(REALLOC_0_WORKS)
+fi
 AC_MSG_RESULT($glib_cv_sane_realloc)
 
 
@@ -485,7 +448,8 @@ AC_CACHE_VAL(glib_cv_va_val_copy,[
 ])
 if test "x$glib_cv_va_copy" = "xyes"; then
   AC_DEFINE(G_VA_COPY, va_copy)
-else if test "x$glib_cv___va_copy" = "xyes"; then
+else
+if test "x$glib_cv___va_copy" = "xyes"; then
   AC_DEFINE(G_VA_COPY, __va_copy)
 fi
 fi
@@ -505,21 +469,13 @@ G_MODULE_NEED_USCORE=0
 G_MODULE_BROKEN_RTLD_GLOBAL=0
 G_MODULE_HAVE_DLERROR=0
 dnl *** dlopen() and dlsym() in system libraries
-if test -z "$G_MODULE_IMPL"; then
-	AC_CHECK_FUNC(dlopen,
-		AC_CHECK_FUNC(dlsym,
-			G_MODULE_IMPL=G_MODULE_IMPL_DL
-		,)
-	,)
-fi
+AC_CHECK_FUNC([dlopen], [AC_CHECK_FUNC([dlsym], [G_MODULE_IMPL=G_MODULE_IMPL_DL], [])], [])
 dnl *** dlopen() and dlsym() in libdl
 if test -z "$G_MODULE_IMPL"; then
-	AC_CHECK_LIB(dl, dlopen,
-		AC_CHECK_LIB(dl, dlsym,
-			G_MODULE_LIBS=-ldl
-			G_MODULE_IMPL=G_MODULE_IMPL_DL
-		,)
-	,)
+	AC_CHECK_LIB([dl], [dlopen], [AC_CHECK_LIB([dl], [dlsym], [
+		G_MODULE_LIBS=-ldl
+		G_MODULE_IMPL=G_MODULE_IMPL_DL
+	], [])], [])
 fi
 dnl *** shl_load() in libdld (HP-UX)
 if test -z "$G_MODULE_IMPL"; then
@@ -854,49 +810,68 @@ if test x"$have_threads" != xnone; then
 			AC_MSG_CHECKING(whether getpwuid_r is posix like)
 			# The signature for the POSIX version is:
 			# int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **)
-			AC_TRY_COMPILE([#include <pwd.h>
-                                        #include <sys/types.h>
-                                        #include <stdlib.h>],
-				[getpwuid_r((uid_t)0, NULL, NULL, (size_t)0, NULL);],
-				[AC_DEFINE(HAVE_GETPWUID_R_POSIX)
-				AC_MSG_RESULT(yes)],
-				[AC_MSG_RESULT(no)])
+			AC_CACHE_CHECK([whether pthread_getspecific is posix like],
+			 	[ac_cv_func_getpwuid_r_posix],
+			 	[AC_TRY_COMPILE([#include <pwd.h>
+                                 #include <sys/types.h>
+                                 #include <stdlib.h>],
+					[getpwuid_r((uid_t)0, NULL, NULL, (size_t)0, NULL);],
+					[ac_cv_func_getpwuid_r_posix=yes],
+					[ac_cv_func_getpwuid_r_posix=no])]
+			)
+			if test "x$ac_cv_func_getpwuid_r_posix" = "xyes"; then
+				AC_DEFINE(HAVE_GETPWUID_R_POSIX)
+			fi
 		fi
 	fi
 	if test x"$have_threads" = xposix; then
 		LIBS="$LIBS $G_THREAD_LIBS"
 		AC_MSG_CHECKING(whether pthread_getspecific is posix like)
 		# PCThreads has pthread_getspecific(pthread_key_t, void **);
-		AC_TRY_COMPILE([#include <pthread.h>],
-			[pthread_getspecific(0,NULL);],
-			[AC_MSG_RESULT(no)],
-			[AC_MSG_RESULT(yes)
-			AC_DEFINE(HAVE_PTHREAD_GETSPECIFIC_POSIX)])
+		AC_CACHE_CHECK([whether pthread_getspecific is posix like],
+			[glib_cv_sys_pthread_getspecific_posix],
+			[AC_TRY_COMPILE([#include <pthread.h>],
+				[pthread_getspecific(0,NULL);],
+				[glib_cv_sys_pthread_getspecific_posix=no],
+				[glib_cv_sys_pthread_getspecific_posix=yes])]
+		)
+		if test "x$glib_cv_sys_pthread_getspecific_posix" = "xyes"; then
+			AC_DEFINE(HAVE_PTHREAD_GETSPECIFIC_POSIX)
+		fi
 		AC_MSG_CHECKING(whether pthread_mutex_trylock is posix like)
 		# DCE Threads return 1 as success, posix 0. what a mess.
-		AC_TRY_RUN([#include <pthread.h>
-			pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-			int main () { 
-			return !pthread_mutex_trylock (&mutex); }],
-			[AC_MSG_RESULT(no)],
-			[AC_MSG_RESULT(yes)
-			AC_DEFINE(HAVE_PTHREAD_MUTEX_TRYLOCK_POSIX)])
+		AC_CACHE_CHECK([whether pthread_mutex_trylock is posix like],
+			[glib_cv_sys_pthread_mutex_trylock_posix],
+			[AC_TRY_RUN([#include <pthread.h>
+				pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+				int main () { 
+				return !pthread_mutex_trylock (&mutex); }],
+			[glib_cv_sys_pthread_mutex_trylock_posix=no],
+			[glib_cv_sys_pthread_mutex_trylock_posix=yes])]
+		)
+		if test "x$glib_cv_sys_pthread_mutex_trylock_posix=no" = "xyes"; then
+			AC_DEFINE(HAVE_PTHREAD_MUTEX_TRYLOCK_POSIX)
+		fi
 		AC_MSG_CHECKING(whether pthread_cond_timedwait is posix like)
 		# DCE Threads return -1 as failure, posix ETIMEDOUT.
-		AC_TRY_RUN([#include <pthread.h>
-			int main () { 
-			pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-			pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-			struct timeval tval;
-			struct timespec tspec;
-			gettimeofday (&tval, NULL);
-			tspec.tv_sec = tval.tv_sec;
-			tspec.tv_nsec = 0;
-			return pthread_cond_timedwait (&cond,&mutex,&tspec) 
-				!= -1;}],
-			[AC_MSG_RESULT(no)],
-			[AC_MSG_RESULT(yes)
-			AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_POSIX)])
+		AC_CACHE_CHECK([whether pthread_cond_timedwait is posix like],
+			[glib_cv_sys_pthread_cond_timedwait_posix],
+			[AC_TRY_RUN([#include <pthread.h>
+				int main () { 
+				pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+				pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
+				struct timeval tval;
+				struct timespec tspec;
+				gettimeofday (&tval, NULL);
+				tspec.tv_sec = tval.tv_sec;
+				tspec.tv_nsec = 0;
+				return pthread_cond_timedwait (&cond,&mutex,&tspec) != -1;}],
+			[glib_cv_sys_pthread_cond_timedwait_posix=no],
+			[glib_cv_sys_pthread_cond_timedwait_posix=yes])]
+		)
+		if test "x$glib_cv_sys_pthread_cond_timedwait_posix" = "xyes"; then
+			AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_POSIX)
+		fi
 	fi
 	LIBS="$glib_save_LIBS"
 	CFLAGS="$glib_save_CFLAGS"
@@ -940,12 +915,14 @@ GLIB_IF_VAR_EQ(mutex_has_default, yes,
 dnl ****************************************
 dnl *** GLib POLL* compatibility defines ***
 dnl ****************************************
+if test "x$cross_compiling" != "xyes"; then
 GLIB_SYSDEFS(
 [#include <sys/types.h>
 #include <sys/poll.h>],
 	POLLIN:1 POLLOUT:4 POLLPRI:2 POLLERR:8 POLLHUP:16 POLLNVAL:32,
 	glibconfig-sysdefs.h,
 	=)
+fi
 
 
 dnl ******************************
--- 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
--- a/gmodule/Makefile.am
+++ b/gmodule/Makefile.am
@@ -42,7 +42,7 @@ libgplugin_b_la_LDFLAGS = @G_MODULE_LDFL
 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