Index: configure
--- configure.orig	2010-11-25 20:19:01.000000000 +0100
+++ configure	2010-12-03 09:48:25.000000000 +0100
@@ -20255,11 +20255,11 @@
                 if test ${APR_MAJOR_VERSION:="0"} -eq 0; then
                     apr_config=apr-config
                     apu_config=apu-config
-                    apreq_libs="-lapr -laprutil"
+                    apreq_libs="-laprutil -lapr"
                 else
                     apr_config=apr-$APR_MAJOR_VERSION-config
                     apu_config=apu-$APR_MAJOR_VERSION-config
-                    apreq_libs="-lapr-$APR_MAJOR_VERSION -laprutil-$APR_MAJOR_VERSION"
+                    apreq_libs="-laprutil-$APR_MAJOR_VERSION -lapr-$APR_MAJOR_VERSION"
                 fi
 
                 if test -z "$APR_CONFIG"; then
@@ -20513,10 +20513,10 @@
         APU_LA="`$APU_CONFIG --apu-la-file`"
 
   if test "x$APR_LTFLAGS" = "x"; then
-    echo "  setting APR_LTFLAGS to \""`$APR_CONFIG --link-libtool`"\""
-    APR_LTFLAGS=""`$APR_CONFIG --link-libtool`""
+    echo "  setting APR_LTFLAGS to \""`$APU_CONFIG --link-libtool`"\""
+    APR_LTFLAGS=""`$APU_CONFIG --link-libtool`""
   else
-    apr_addto_bugger=""`$APR_CONFIG --link-libtool`""
+    apr_addto_bugger=""`$APU_CONFIG --link-libtool`""
     for i in $apr_addto_bugger; do
       apr_addto_duplicate="0"
       for j in $APR_LTFLAGS; do
@@ -20527,17 +20527,16 @@
       done
       if test $apr_addto_duplicate = "0"; then
         echo "  adding \"$i\" to APR_LTFLAGS"
-        APR_LTFLAGS="$APR_LTFLAGS $i"
+        APR_LTFLAGS="$i $APR_LTFLAGS"
       fi
     done
   fi
 
-
   if test "x$APR_LTFLAGS" = "x"; then
-    echo "  setting APR_LTFLAGS to \""`$APU_CONFIG --link-libtool`"\""
-    APR_LTFLAGS=""`$APU_CONFIG --link-libtool`""
+    echo "  setting APR_LTFLAGS to \""`$APR_CONFIG --link-libtool`"\""
+    APR_LTFLAGS=""`$APR_CONFIG --link-libtool`""
   else
-    apr_addto_bugger=""`$APU_CONFIG --link-libtool`""
+    apr_addto_bugger=""`$APR_CONFIG --link-libtool`""
     for i in $apr_addto_bugger; do
       apr_addto_duplicate="0"
       for j in $APR_LTFLAGS; do
@@ -20548,32 +20547,13 @@
       done
       if test $apr_addto_duplicate = "0"; then
         echo "  adding \"$i\" to APR_LTFLAGS"
-        APR_LTFLAGS="$APR_LTFLAGS $i"
+        APR_LTFLAGS="$i $APR_LTFLAGS"
       fi
     done
   fi
 
 
 
-  if test "x$APR_LIBS" = "x"; then
-    echo "  setting APR_LIBS to \""`$APR_CONFIG --libs`"\""
-    APR_LIBS=""`$APR_CONFIG --libs`""
-  else
-    apr_addto_bugger=""`$APR_CONFIG --libs`""
-    for i in $apr_addto_bugger; do
-      apr_addto_duplicate="0"
-      for j in $APR_LIBS; do
-        if test "x$i" = "x$j"; then
-          apr_addto_duplicate="1"
-          break
-        fi
-      done
-      if test $apr_addto_duplicate = "0"; then
-        echo "  adding \"$i\" to APR_LIBS"
-        APR_LIBS="$APR_LIBS $i"
-      fi
-    done
-  fi
 
 
         apu_avoid_libs=""
@@ -20653,6 +20633,25 @@
     done
   fi
 
+  if test "x$APR_LIBS" = "x"; then
+    echo "  setting APR_LIBS to \""`$APR_CONFIG --libs`"\""
+    APR_LIBS=""`$APR_CONFIG --libs`""
+  else
+    apr_addto_bugger=""`$APR_CONFIG --libs`""
+    for i in $apr_addto_bugger; do
+      apr_addto_duplicate="0"
+      for j in $APR_LIBS; do
+        if test "x$i" = "x$j"; then
+          apr_addto_duplicate="1"
+          break
+        fi
+      done
+      if test $apr_addto_duplicate = "0"; then
+        echo "  adding \"$i\" to APR_LIBS"
+        APR_LIBS="$APR_LIBS $i"
+      fi
+    done
+  fi
 
         if test -n "$EXPAT_DIR"; then
 
Index: library/Makefile.in
--- library/Makefile.in.orig	2010-11-25 20:19:03.000000000 +0100
+++ library/Makefile.in	2010-12-03 09:49:05.000000000 +0100
@@ -218,7 +218,7 @@
                        parser_urlencoded.c parser_header.c parser_multipart.c \
 	               module.c module_custom.c module_cgi.c error.c
 
-libapreq2_la_LDFLAGS = -version-info @APREQ_LIBTOOL_VERSION@ @APR_LTFLAGS@ @APR_LIBS@
+libapreq2_la_LDFLAGS = -static -version-info @APREQ_LIBTOOL_VERSION@ @APR_LTFLAGS@ @APR_LIBS@
 @ENABLE_PROFILE_TRUE@AM_CFLAGS = -pg -fprofile-arcs -ftest-coverage
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
