Patch below is an attempt to create a sanitized version of
config_vars.mk which is suitable for the installed tree.

The currently installed file has lots of references to the source and
build trees in e.g. EXTRA_INCLUDES, which cause various problems. (PR
28145, 20874, 29771, probably more)

The patch makes configure generate a config_vars.sh which in turn can
perform substitutions to generate a sane config_vars.mk.  The
double-indirection is necessary because some of the variables e.g.
APR_INCLUDEDIR can only be discovered *during* make install.

Any objections, particularly w.r.t the list of variables which get
substituted out?

Index: configure.in
===================================================================
--- configure.in        (revision 189939)
+++ configure.in        (working copy)
@@ -166,7 +166,7 @@
                   [--prefix=$prefix --exec-prefix=$exec_prefix 
--libdir=$libdir --includedir=$includedir --bindir=$bindir])
 
   APR_ADDTO(AP_LIBS, [$abs_builddir/srclib/pcre/libpcre.la])
-  APR_ADDTO(CPPFLAGS, [-I$abs_builddir/srclib/pcre])
+  APR_ADDTO(INCLUDES, [-I$abs_builddir/srclib/pcre])
 
   AP_BUILD_SRCLIB_DIRS="$AP_BUILD_SRCLIB_DIRS pcre"
   AP_CLEAN_SRCLIB_DIRS="$AP_CLEAN_SRCLIB_DIRS pcre" 
@@ -648,7 +648,7 @@
 HTTPD_VERSION=`$abs_srcdir/build/get-version.sh all 
$abs_srcdir/include/ap_release.h AP_SERVER`
 AC_SUBST(HTTPD_VERSION)
 
-AC_OUTPUT($APACHE_OUTPUT_FILES docs/conf/httpd.conf 
docs/conf/extra/httpd-autoindex.conf docs/conf/extra/httpd-dav.conf 
docs/conf/extra/httpd-default.conf docs/conf/extra/httpd-info.conf 
docs/conf/extra/httpd-languages.conf docs/conf/extra/httpd-manual.conf 
docs/conf/extra/httpd-mpm.conf docs/conf/extra/httpd-multilang-errordoc.conf 
docs/conf/extra/httpd-ssl.conf docs/conf/extra/httpd-userdir.conf 
docs/conf/extra/httpd-vhosts.conf include/ap_config_layout.h support/apxs 
support/apachectl support/dbmmanage support/envvars-std 
support/log_server_status support/logresolve.pl support/phf_abuse_log.cgi 
support/split-logfile build/rules.mk build/pkg/pkginfo,[true],[
+AC_OUTPUT($APACHE_OUTPUT_FILES docs/conf/httpd.conf 
docs/conf/extra/httpd-autoindex.conf docs/conf/extra/httpd-dav.conf 
docs/conf/extra/httpd-default.conf docs/conf/extra/httpd-info.conf 
docs/conf/extra/httpd-languages.conf docs/conf/extra/httpd-manual.conf 
docs/conf/extra/httpd-mpm.conf docs/conf/extra/httpd-multilang-errordoc.conf 
docs/conf/extra/httpd-ssl.conf docs/conf/extra/httpd-userdir.conf 
docs/conf/extra/httpd-vhosts.conf include/ap_config_layout.h support/apxs 
support/apachectl support/dbmmanage support/envvars-std 
support/log_server_status support/logresolve.pl support/phf_abuse_log.cgi 
support/split-logfile build/rules.mk build/pkg/pkginfo 
build/config_vars.sh,[true],[
   APACHE_GEN_MAKEFILES
 ])
 
Index: build/config_vars.sh.in
===================================================================
--- build/config_vars.sh.in     (revision 0)
+++ build/config_vars.sh.in     (revision 0)
@@ -0,0 +1,56 @@
+#! @SHELL@
+#
+# Copyright 2005 The Apache Software Foundation or its licensors, as
+# applicable.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# config_vars.sh is generated by configure, and is run by the "install-build"
+# target to generate a version of config_vars.mk which is suitable to be
+# installed.  Such a file cannot be generated at configure-time, since it
+# requires the output of the *installed* ap*-config scripts.
+
[EMAIL PROTECTED]@
[EMAIL PROTECTED]@
+
+APR_LIBTOOL="`${APR_CONFIG} --apr-libtool`"
+APR_INCLUDEDIR="`${APR_CONFIG} --includedir`"
+APU_INCLUDEDIR="`${APU_CONFIG} --includedir`"
+
+exec sed "
+/^[A-Z_]*_LDADD/d
+/MPM_LIB/d
+/APACHECTL_ULIMIT/d
+/[a-z]*_LTFLAGS/d
+/^DSO_MODULES/d
+/^MODULE_/d
+/^PORT/d
+/^nonssl_/d
+/^CORE_IMPLIB/d
+/^rel_/d
+/^abs_srcdir/d
+/^BUILTIN_LIBS/d
+/^[A-Z]*_SHARED_CMDS/d
+/^shared_build/d
+/^OS_DIR/d
+/^MPM_SUBDIR_NAME/d
+/^EXTRA_INCLUDES/{ 
+  s, = , = -I\$(includedir) ,
+  s, -I\$(top_srcdir)/[^ ]*,,g
+  s, -I\$(top_builddir)/[^ ]*,,g
+}
+/^HTTPD_LDFLAGS/d
+/^APR_INCLUDEDIR.*$/s,.*,APR_INCLUDEDIR = ${APR_INCLUDEDIR},
+/^APU_INCLUDEDIR.*$/s,.*,APU_INCLUDEDIR = ${APU_INCLUDEDIR},
+/^LIBTOOL.*$/s,/[^ ]*/libtool \(.*\),${APR_LIBTOOL} \$(LTFLAGS),
+"
Index: Makefile.in
===================================================================
--- Makefile.in (revision 189939)
+++ Makefile.in (working copy)
@@ -85,7 +85,11 @@
            fi ; \
        fi
 
-install-build:
+# Create a sanitized config_vars.mk
+build/config_vars.out: build/config_vars.mk
+       @$(SHELL) build/config_vars.sh < build/config_vars.mk > 
build/config_vars.out
+
+install-build: build/config_vars.out
        @echo Installing build system files 
        @$(MKINSTALLDIRS) $(DESTDIR)$(installbuilddir) 
        @for f in $(top_srcdir)/build/*.mk build/*.mk \
@@ -94,8 +98,8 @@
        done
        @$(INSTALL_PROGRAM) $(top_srcdir)/build/mkdir.sh 
$(DESTDIR)$(installbuilddir)
        @$(INSTALL_PROGRAM) $(top_srcdir)/build/instdso.sh 
$(DESTDIR)$(installbuilddir)
-       @sed "/^LIBTOOL/s#/[^ ]*/libtool \(.*\)#`$(APR_CONFIG) --apr-libtool` 
$(LTFLAGS)#" \
-           build/config_vars.mk > $(DESTDIR)$(installbuilddir)/config_vars.mk
+       @$(INSTALL_DATA) build/config_vars.out 
$(DESTDIR)$(installbuilddir)/config_vars.mk
+       @rm build/config_vars.out
 
 htdocs-srcdir = $(top_srcdir)/docs/docroot
 

Reply via email to