autoconf-patches
[Top][All Lists]
Advanced

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

Re: Please normalize command line paths


From: Eric Blake
Subject: Re: Please normalize command line paths
Date: Fri, 05 Oct 2007 11:56:30 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to BJörn Lindqvist on 9/29/2007 7:52 PM:
> In some autotooled project, when I type:
> 
> ./configure --prefix=/usr/
> 
> I want autoconf to treat it as if I typed:
> 
> ./configure --prefix=/usr
> 
> The fix for this problem is, as expected, really trivial. A one-liner
> sed or awk should do it, but there may be even more efficient methods.
> A description of the problem and a proposed fix for the problem for
> the Python package is posted here:
> http://bugs.python.org/issue1676135.

The patch in that bug report only affected --prefix, and even then, didn't
do it correctly in the presence of multiple slashes.  I'm committing this
to autoconf instead:

2007-10-05  Eric Blake  <address@hidden>

        Resolve Python issue 1676135 regarding configure directory args.
        * lib/autoconf/general.m4 (_AC_INIT_PARSE_ARGS): Strip trailing
        slashes from directory arguments.
        * tests/base.at (configure directories): New test.
        * doc/autoconf.texi (Installation Directory Variables): Document
        the change.
        * NEWS: Likewise.
        * THANKS: Update.
        Reported by Björn Lindqvist.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHBnrN84KuGfSFAYARAn2XAJ4ghGB8wUZxpqcTbACwLV5TH3KhTgCfXbAw
hJ3mmAbU0FqX50x2T3qD9/4=
=+tOA
-----END PGP SIGNATURE-----
>From b5db063f5efa48068b1a75a4571905242444b31e Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Fri, 5 Oct 2007 11:26:26 -0600
Subject: [PATCH] Resolve Python issue 1676135 regarding configure directory 
args.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

* lib/autoconf/general.m4 (_AC_INIT_PARSE_ARGS): Strip trailing
slashes from directory arguments.
* tests/base.at (configure directories): New test.
* doc/autoconf.texi (Installation Directory Variables): Document
the change.
* NEWS: Likewise.
* THANKS: Update.
Reported by Björn Lindqvist.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |   10 ++++++++++
 NEWS                    |    6 ++++++
 doc/autoconf.texi       |    7 +++++--
 lib/autoconf/general.m4 |    8 +++++++-
 tests/base.at           |   34 ++++++++++++++++++++++++++++++++++
 5 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 57dfbb5..e5e01c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2007-10-05  Eric Blake  <address@hidden>
 
+       Resolve Python issue 1676135 regarding configure directory args.
+       * lib/autoconf/general.m4 (_AC_INIT_PARSE_ARGS): Strip trailing
+       slashes from directory arguments.
+       * tests/base.at (configure directories): New test.
+       * doc/autoconf.texi (Installation Directory Variables): Document
+       the change.
+       * NEWS: Likewise.
+       * THANKS: Update.
+       Reported by Björn Lindqvist.
+
        Provide better short-circuiting operation.
        * lib/m4sugar/m4sugar.m4 (m4_cond, m4_newline): New macros.
        (m4_text_wrap): Use it.  Also avoid useless m4_for.
diff --git a/NEWS b/NEWS
index 1bd5f5a..70a4a1a 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,12 @@ GNU Autoconf NEWS - User visible changes.
 
 ** The command 'autoconf -' now correctly processes a file from stdin.
 
+** For all of the directory arguments for 'configure', such as '--prefix'
+   or '--bindir', trailing slashes are stripped.  As an example, if
+   tab completion in the user's shell appends trailing slashes, the
+   command './configure --prefix=/usr/' will still result in an
+   expanded libdir value of /usr/lib, not /usr//lib.
+
 ** AT_SETUP now handles macro expansions properly when calculating line
    length.  However, as a side effect, any whitespace immediately
    following a single-quoted comma is lost.  If you previously used
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index ecc496b..1b470eb 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -1728,7 +1728,7 @@ M4.
 
 The following M4 macros (e.g., @code{AC_PACKAGE_NAME}), output variables
 (e.g., @code{PACKAGE_NAME}), and preprocessor symbols (e.g.,
address@hidden) are defined by @code{AC_INIT}:
address@hidden), are defined by @code{AC_INIT}:
 
 @table @asis
 @item @code{AC_PACKAGE_NAME}, @code{PACKAGE_NAME}
@@ -2465,7 +2465,10 @@ Absolute name of @code{top_srcdir}.
 The following variables specify the directories for
 package installation, see @ref{Directory Variables, , Variables for
 Installation Directories, standards, The @acronym{GNU} Coding
-Standards}, for more information.  See the end of this section for
+Standards}, for more information.  Each variable corresponds to an
+argument of @command{configure}; trailing slashes are stripped so that
+expressions such as @address@hidden@}/lib} expand with only one slash
+between directory names.  See the end of this section for
 details on when and how to use these variables.
 
 @defvar bindir
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index df501ec..0f8a5dc 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -895,13 +895,19 @@ if test -n "$ac_unrecognized_opts"; then
   esac
 fi
 
-# Be sure to have absolute directory names.
+# Check all directory arguments for consistency.
 for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
                datadir sysconfdir sharedstatedir localstatedir includedir \
                oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
                libdir localedir mandir
 do
   eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    / | // ) ;;
+    */ ) eval $ac_var='`echo "$ac_val" | sed "s|/*\$||"`' ;;
+  esac
+  # Be sure to have absolute directory names.
   case $ac_val in
     [[\\/$]]* | ?:[[\\/]]* )  continue;;
     NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
diff --git a/tests/base.at b/tests/base.at
index afbe884..f1f1a9d 100644
--- a/tests/base.at
+++ b/tests/base.at
@@ -321,3 +321,37 @@ AT_CHECK_CONFIGURE([FOO=bar --enable-baz --without-zork 
--silent], [0], [stdout]
 AT_CHECK([grep 'FOO=bar --enable-baz --without-zork --silent' stdout], [0], 
[ignore], [ignore])
 
 AT_CLEANUP
+
+
+## --------------------- ##
+## configure directories ##
+## --------------------- ##
+
+AT_SETUP([configure directories])
+
+AT_DATA([foo.in],
address@hidden@
address@hidden@
address@hidden@
+]])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_CONFIG_FILES([foo])
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+dnl check that relative paths are rejected
+AT_CHECK_CONFIGURE([--libdir=.], [1], [ignore], [stderr])
+AT_CHECK([grep 'expected an absolute directory name for --libdir: \.' stderr],
+        [0], [ignore])
+
+dnl check that extra slashes are stripped, and that defaults are not expanded
+AT_CHECK_CONFIGURE([--prefix=/usr//])
+AT_CHECK([cat foo], [0], [[prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+]])
+
+AT_CLEANUP
-- 
1.5.3.2


reply via email to

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