52592b
diff --git a/support/apxs.in b/support/apxs.in
52592b
index ad1287f..efcfcf6 100644
52592b
--- a/support/apxs.in
52592b
+++ b/support/apxs.in
52592b
@@ -25,7 +25,18 @@ package apxs;
52592b
 
52592b
 my %config_vars = ();
52592b
 
52592b
-my $installbuilddir = "@exp_installbuilddir@";
52592b
+# Awful hack to make apxs libdir-agnostic:
52592b
+my $pkg_config = "/usr/bin/pkg-config";
52592b
+if (! -x "$pkg_config") {
52592b
+    error("$pkg_config not found!");
52592b
+    exit(1);
52592b
+}
52592b
+
52592b
+my $libdir = `pkg-config --variable=libdir apr-1`;
52592b
+chomp $libdir;
52592b
+
52592b
+my $installbuilddir = $libdir . "/httpd/build";
52592b
+
52592b
 get_config_vars("$installbuilddir/config_vars.mk",\%config_vars);
52592b
 
52592b
 # read the configuration variables once
52592b
@@ -275,7 +286,7 @@ if ($opt_g) {
52592b
     $data =~ s|%NAME%|$name|sg;
52592b
     $data =~ s|%TARGET%|$CFG_TARGET|sg;
52592b
     $data =~ s|%PREFIX%|$prefix|sg;
52592b
-    $data =~ s|%INSTALLBUILDDIR%|$installbuilddir|sg;
52592b
+    $data =~ s|%LIBDIR%|$libdir|sg;
52592b
 
52592b
     my ($mkf, $mods, $src) = ($data =~ m|^(.+)-=#=-\n(.+)-=#=-\n(.+)|s);
52592b
 
52592b
@@ -453,11 +464,11 @@ if ($opt_c) {
52592b
     my $ldflags = "$CFG_LDFLAGS";
52592b
     if ($opt_p == 1) {
52592b
         
52592b
-        my $apr_libs=`$apr_config --cflags --ldflags --link-libtool --libs`;
52592b
+        my $apr_libs=`$apr_config --cflags --ldflags --link-libtool`;
52592b
         chomp($apr_libs);
52592b
         my $apu_libs="";
52592b
         if ($apr_major_version < 2) {
52592b
-            $apu_libs=`$apu_config --ldflags --link-libtool --libs`;
52592b
+            $apu_libs=`$apu_config --ldflags --link-libtool`;
52592b
             chomp($apu_libs);
52592b
         }
52592b
         
52592b
@@ -672,8 +683,8 @@ __DATA__
52592b
 
52592b
 builddir=.
52592b
 top_srcdir=%PREFIX%
52592b
-top_builddir=%PREFIX%
52592b
-include %INSTALLBUILDDIR%/special.mk
52592b
+top_builddir=%LIBDIR%/httpd
52592b
+include %LIBDIR%/httpd/build/special.mk
52592b
 
52592b
 #   the used tools
52592b
 APACHECTL=apachectl