--- 64bit/support/apxs.in.orig	2020-09-08 09:24:00 +0000
+++ 64bit/support/apxs.in	2020-09-08 09:27:28 +0000
@@ -35,7 +35,18 @@
 
 my %config_vars = ();
 
-my $installbuilddir = "@exp_installbuilddir@";
+# Awful hack to make apxs libdir-agnostic:
+my $pkg_config = "/opt/freeware/bin/pkg-config";
+if (! -x "$pkg_config") {
+    error("$pkg_config not found!");
+    exit(1);
+}
+
+my $libdir = `pkg-config --variable=libdir apr-1`;
+chomp $libdir;
+
+my $installbuilddir = $libdir . "/httpd/build";
+
 get_config_vars($destdir . "$installbuilddir/config_vars.mk",\%config_vars);
 
 # read the configuration variables once
@@ -290,7 +301,7 @@
     $data =~ s|%NAME%|$name|sg;
     $data =~ s|%TARGET%|$CFG_TARGET|sg;
     $data =~ s|%PREFIX%|$prefix|sg;
-    $data =~ s|%INSTALLBUILDDIR%|$installbuilddir|sg;
+    $data =~ s|%LIBDIR%|$libdir|sg;
 
     my ($mkf, $mods, $src) = ($data =~ m|^(.+)-=#=-\n(.+)-=#=-\n(.+)|s);
 
@@ -468,11 +479,11 @@
     my $ldflags = "$CFG_LDFLAGS";
     if ($opt_p == 1) {
         
-        my $apr_libs=`$apr_config --cflags --ldflags --link-libtool --libs`;
+        my $apr_libs=`$apr_config --cflags --ldflags --link-libtool`;
         chomp($apr_libs);
         my $apu_libs="";
         if ($apr_major_version < 2) {
-            $apu_libs=`$apu_config --ldflags --link-libtool --libs`;
+            $apu_libs=`$apu_config --ldflags --link-libtool`;
             chomp($apu_libs);
         }
         
@@ -687,8 +698,8 @@
 
 builddir=.
 top_srcdir=%PREFIX%
-top_builddir=%PREFIX%
-include %INSTALLBUILDDIR%/special.mk
+top_builddir=%LIBDIR%/httpd
+include %LIBDIR%/httpd/build/special.mk
 
 #   the used tools
 APACHECTL=apachectl
--- 32bit/support/apxs.in.orig	2020-09-08 09:30:54 +0000
+++ 32bit/support/apxs.in	2020-09-08 09:30:22 +0000
@@ -35,7 +35,18 @@
 
 my %config_vars = ();
 
-my $installbuilddir = "@exp_installbuilddir@";
+# Awful hack to make apxs libdir-agnostic:
+my $pkg_config = "/opt/freeware/bin/pkg-config_32";
+if (! -x "$pkg_config") {
+    error("$pkg_config not found!");
+    exit(1);
+}
+
+my $libdir = `pkg-config_32 --variable=libdir apr-1`;
+chomp $libdir;
+
+my $installbuilddir = $libdir . "/httpd/build";
+
 get_config_vars($destdir . "$installbuilddir/config_vars.mk",\%config_vars);
 
 # read the configuration variables once
@@ -290,7 +301,7 @@
     $data =~ s|%NAME%|$name|sg;
     $data =~ s|%TARGET%|$CFG_TARGET|sg;
     $data =~ s|%PREFIX%|$prefix|sg;
-    $data =~ s|%INSTALLBUILDDIR%|$installbuilddir|sg;
+    $data =~ s|%LIBDIR%|$libdir|sg;
 
     my ($mkf, $mods, $src) = ($data =~ m|^(.+)-=#=-\n(.+)-=#=-\n(.+)|s);
 
@@ -468,11 +479,11 @@
     my $ldflags = "$CFG_LDFLAGS";
     if ($opt_p == 1) {
         
-        my $apr_libs=`$apr_config --cflags --ldflags --link-libtool --libs`;
+        my $apr_libs=`$apr_config --cflags --ldflags --link-libtool`;
         chomp($apr_libs);
         my $apu_libs="";
         if ($apr_major_version < 2) {
-            $apu_libs=`$apu_config --ldflags --link-libtool --libs`;
+            $apu_libs=`$apu_config --ldflags --link-libtool`;
             chomp($apu_libs);
         }
         
@@ -687,8 +698,8 @@
 
 builddir=.
 top_srcdir=%PREFIX%
-top_builddir=%PREFIX%
-include %INSTALLBUILDDIR%/special.mk
+top_builddir=%LIBDIR%/httpd
+include %LIBDIR%/httpd/build/special.mk
 
 #   the used tools
 APACHECTL=apachectl
--- 64bit/support/apxs.in.orig	2020-09-08 10:47:07 +0000
+++ 64bit/support/apxs.in	2020-09-08 10:47:18 +0000
@@ -702,7 +702,7 @@
 include %LIBDIR%/httpd/build/special.mk
 
 #   the used tools
-APACHECTL=apachectl
+APACHECTL=apachectl_64
 
 #   additional defines, includes and libraries
 #DEFS=-Dmy_define=my_value
