autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CONFIG_SUBDIRS vs. accumulating configure args.


From: Akim Demaille
Subject: Re: CONFIG_SUBDIRS vs. accumulating configure args.
Date: 09 Sep 2002 17:48:26 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

| Hi,

Hi Ralf,

Thanks for the detailed report.

| The example below (3 cascaded config-subdirs) demonstrates what I think
| is a bug in autoconf-2.53c's handling of accumulating/duplicate
| configure arguments.
| 
| # ./configure --prefix=/foo --prefix=/bar
| # find . -name Makefile -exec grep -H '^prefix =' {} \;
| ./sub/sub/Makefile:prefix = /foo
| ./sub/Makefile:prefix = /bar
| ./Makefile:prefix = /bar
| 
| AFAIS, the cause for this behavior is autoconf's attempt to 
| "stripping off duplicate args" in _AC_INIT_PREPARE (~line 1154 in
| general.m4), which causes earlier "dups" to override later "dups".
| This is different from other places in autoconf and in former versions
| of autoconf, where "later dups" overrode "earlier dups"

Arg.  This patch is coming from:

http://mail.gnu.org/pipermail/bug-autoconf/2001-November/001170.html

It is mainly a problem of esthetics that it was trying to address, so
as far as I'm concerned, given that we are trying to 2.54, I'm in
favor of removing the `remove the duplicates' code.  You don't even
demonstrate the worst issues coming from the naive duplication
removal:

| /tmp/subtest-0.0 % ./configure --prefix /foo --prefix /bar
| checking for a BSD-compatible install... /usr/bin/install -c
| checking whether build environment is sane... yes
| checking for gawk... gawk
| checking whether make sets ${MAKE}... yes
| configure: creating ./config.status
| config.status: creating Makefile
| configure: configuring in sub
| configure: running /bin/sh './configure' --prefix=/bar  '--prefix' '/foo' 
'/bar' --cache-file=/dev/null --srcdir=.
| configure: WARNING: you should use --build, --host, --target
| configure: WARNING: invalid host type: /bar
| checking for a BSD-compatible install... /usr/bin/install -c
| checking whether build environment is sane... yes
| checking for gawk... gawk
| checking whether make sets ${MAKE}... yes
| configure: creating ./config.status
| config.status: creating Makefile
| configure: configuring in sub
| configure: running /bin/sh './configure' --prefix=/foo  '--prefix=/bar' 
'--prefix' '/foo' '/bar' '--cache-file=/dev/null' '--srcdir=.' 
'build_alias=/bar' 'host_alias=/bar' 'target_alias=/bar' --cache-file=/dev/null 
--srcdir=.
| configure: WARNING: you should use --build, --host, --target
| configure: WARNING: invalid host type: /bar
| checking for a BSD-compatible install... /usr/bin/install -c
| checking whether build environment is sane... yes
| checking for gawk... gawk
| checking whether make sets ${MAKE}... yes
| checking for /bar-gcc... no
| checking for gcc... gcc
| checking for C compiler default output... a.out
| checking whether the C compiler works... yes
| checking whether we are cross compiling... no
| checking for suffix of executables... 
| checking for suffix of object files... o
| checking whether we are using the GNU C compiler... yes
| checking whether gcc accepts -g... yes
| checking for gcc option to accept ANSI C... none needed
| checking for style of include used by make... GNU
| checking dependency style of gcc... gcc
| checking for /bar-ranlib... no
| checking for ranlib... ranlib
| configure: creating ./config.status
| config.status: creating Makefile
| config.status: executing depfiles commands

I'm installing the following patch:

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * lib/autoconf/general.m4 (_AC_INIT_PREPARE): Keep the
        `duplicates', since the algorithm was too naive and could keep
        `--prefix=1 --prefix=2 --prefix=1' as `--prefix=1 --prefix=2', and
        keep `--prefix foo --prefix bar' as `--prefix foo bar'.
        Reported by Ralf Corsepius.
        * tests/torture.at (Configuring subdirectories): Exercise these
        cases.

Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.803
diff -u -u -r1.803 general.m4
--- lib/autoconf/general.m4 9 Sep 2002 15:43:38 -0000 1.803
+++ lib/autoconf/general.m4 9 Sep 2002 15:50:47 -0000
@@ -1150,12 +1150,18 @@
 [  *" "*|*"    "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)]
     ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
   esac
-  case " $ac_configure_args " in
-    *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
-    *) ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
-       ac_sep=" " ;;
-  esac
+dnl If trying to remove duplicates, be sure to (i) keep the *last*
+dnl value (e.g. --prefix=1 --prefix=2 --prefix=1 might keep 2 only),
+dnl and (ii) not to strip long options (--prefix foo --prefix bar might
+dnl give --prefix foo bar).
+dnl   case " $ac_configure_args " in
+dnl     *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+dnl     *) ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+dnl        ac_sep=" " ;;
+dnl   esac
+  ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
   # Get rid of the leading space.
+  ac_sep=" "
 done
 
 # When interrupted or exit'd, cleanup temporary files, and complete
Index: tests/torture.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/torture.at,v
retrieving revision 1.34
diff -u -u -r1.34 torture.at
--- tests/torture.at 20 Apr 2002 06:09:02 -0000 1.34
+++ tests/torture.at 9 Sep 2002 15:50:47 -0000
@@ -579,7 +579,10 @@
 [AC_INIT(GNU Inner, 1.0)
 AC_CONFIG_SRCDIR([innermost/config.in])
 AC_ARG_VAR([INNER], [an inner variable])
-AC_SUBST([INNER], "inner")
+AC_SUBST([INNER])
+if test "x$INNER" = x; then
+  INNER=inner
+fi
 AC_CONFIG_FILES([innermost/config])
 AC_OUTPUT
 ])
@@ -588,6 +591,7 @@
 address@hidden@
 address@hidden@
 address@hidden@
address@hidden@
 ])
 
 # The contents of `.'
@@ -617,6 +621,7 @@
 [INNER=inner
 srcdir=.
 top_srcdir=..
+prefix=/usr/local
 ])
 
 # The same, but from a builddir.
@@ -626,7 +631,17 @@
 [INNER=inner
 srcdir=../../../inner/innermost
 top_srcdir=../../../inner
+prefix=/usr/local
 ])
 
+# Make sure precious variables and command line options are properly
+# passed, even when there are duplicates.
+AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad 
INNER=good], 0, [ignore])
+AT_CHECK([cat builddir/inner/innermost/config], 0,
+[INNER=good
+srcdir=../../../inner/innermost
+top_srcdir=../../../inner
+prefix=/good
+])
 
 AT_CLEANUP




reply via email to

[Prev in Thread] Current Thread [Next in Thread]