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