[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AC_CONFIG_LINKS should look in build tree; more AC_CONFIG_FOOs issues
From: |
Ralf Wildenhues |
Subject: |
AC_CONFIG_LINKS should look in build tree; more AC_CONFIG_FOOs issues |
Date: |
Tue, 10 Apr 2007 21:26:21 +0200 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
As reported by Pallav Gupta in this thread:
<http://lists.gnu.org/archive/html/help-gnu-utils/2007-04/msg00005.html>
AC_CONFIG_LINKS doesn't search for its input file in the build tree,
rather it simply links to the source tree.
Here's a patch to expose the issue in the test suite, and a few more
while we're at it:
- AC_CONFIG_LINKS is not documented consistently to take FILE:IN
argument.
- with INIT-CMDS, the initialization is not consistent wrt.
./config.status
./config.status TAG
usage. One way to fix this is to encourage
init_var=...
AC_CONFIG_FOO(TAG-USING-$init_var, CMDS, [init_var='$init_var'])
- several examples from the manual don't actually work with that format.
I'm not sure whether the patch below is sufficient in terms of
documentation, or even the best way to go. If we could automatize bits
here, or avoid the need for double-initialization without shell quoting
issues, that would likely be better. I think it will require some
surgery in status.m4 though. (I'm posting what I have in case somebody
is eager to pick it up. ;-)
So for the moment: ok to apply the status.m4 change of the patch below?
Cheers,
Ralf
2007-04-09 Ralf Wildenhues <address@hidden>
* lib/autoconf/status.m4 (_AC_OUTPUT_LINK): Fix AC_CONFIG_LINKS
to prefer a link source from the build tree, if it exists.
Report by Pallav Gupta <address@hidden>.
* doc/autoconf.texi (Configuration Actions): AC_CONFIG_LINKS
also has the output:input tag format.
(Configuration Commands, Configuration Links, Obsolete Macros):
Adjust examples for missing initialization.
* tests/torture.at (AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS):
Test with input and output file names containing a (different
number of) directory components. Test also with input files
from the source tree, to expose AC_CONFIG_LINKS bug. Test both
`./configure' and `./config.status TAG' consistently. In the
configure.ac file, ensure that variables set in INIT-CMDS at
config.status time are also set at configure time.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.1141
diff -u -r1.1141 autoconf.texi
--- doc/autoconf.texi 29 Mar 2007 22:25:18 -0000 1.1141
+++ doc/autoconf.texi 9 Apr 2007 14:58:03 -0000
@@ -2026,10 +2027,12 @@
@dots{} && AC_CONFIG_FOOS([foooo])
@end example
-The macros @code{AC_CONFIG_FILES} and @code{AC_CONFIG_HEADERS} use
-special @var{tag} values: they may have the form @address@hidden or
address@hidden@var{output}:@var{inputs}}. The file @var{output} is instantiated
-from its templates, @var{inputs} (defaulting to @address@hidden).
+The macros @code{AC_CONFIG_FILES}, @code{AC_CONFIG_HEADERS}, and
address@hidden use special @var{tag} values: they may have the
+form @address@hidden or @address@hidden:@var{inputs}}. The file
address@hidden is instantiated from its templates, @var{inputs}
+(defaulting to @address@hidden; @code{AC_CONFIG_LINKS} accepts
+one @var{input} only).
@samp{AC_CONFIG_FILES([Makefile:boiler/top.mk:boiler/bot.mk)]},
for example, asks for
@@ -2069,7 +2072,6 @@
The name of the top source directory, assuming that the working
directory is the current build directory.
-
@item ac_top_build_prefix
The name of the top build directory, assuming that the working
directory is the current build directory.
@@ -2091,7 +2093,7 @@
@end example
@noindent
- with @option{--srcdir=../package} produces the following values:
+with @option{--srcdir=../package} produces the following values:
@example
# Argument of --srcdir
@@ -3240,7 +3242,7 @@
fubar=42
AC_CONFIG_COMMANDS([fubar],
[echo this is extra $fubar, and so on.],
- [fubar=$fubar])
+ [fubar='$fubar'])
@end example
Here is a better one:
@@ -3296,7 +3298,8 @@
@example
AC_CONFIG_LINKS([host.h:config/$machine.h
- object.h:config/$obj_format.h])
+ object.h:config/$obj_format.h], [],
+ [machine='$machine'; obj_format='$obj_format'])
@end example
@noindent
@@ -17183,7 +17186,8 @@
@example
AC_CONFIG_LINKS([host.h:config/$machine.h
- object.h:config/$obj_format.h])
+ object.h:config/$obj_format.h], [],
+ [machine='$machine'; obj_format='$obj_format'])
@end example
@end defmac
Index: lib/autoconf/status.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.133
diff -u -r1.133 status.m4
--- lib/autoconf/status.m4 28 Mar 2007 19:16:31 -0000 1.133
+++ lib/autoconf/status.m4 7 Apr 2007 13:19:37 -0000
@@ -873,22 +873,24 @@
# CONFIG_LINK
#
- AC_MSG_NOTICE([linking $srcdir/$ac_source to $ac_file])
+ test -r "$ac_source" || ac_source=$srcdir/$ac_source
- if test ! -r "$srcdir/$ac_source"; then
- AC_MSG_ERROR([$srcdir/$ac_source: file not found])
+ AC_MSG_NOTICE([linking $ac_source to $ac_file])
+
+ if test ! -r "$ac_source"; then
+ AC_MSG_ERROR([$ac_source: file not found])
fi
rm -f "$ac_file"
# Try a relative symlink, then a hard link, then a copy.
case $srcdir in
- [[\\/$]]* | ?:[[\\/]]* ) ac_rel_source=$srcdir/$ac_source ;;
- *) ac_rel_source=$ac_top_build_prefix$srcdir/$ac_source ;;
+ [[\\/$]]* | ?:[[\\/]]* ) ac_rel_source=$ac_source ;;
+ *) ac_rel_source=$ac_top_build_prefix$ac_source ;;
esac
ln -s "$ac_rel_source" "$ac_file" 2>/dev/null ||
- ln "$srcdir/$ac_source" "$ac_file" 2>/dev/null ||
- cp -p "$srcdir/$ac_source" "$ac_file" ||
- AC_MSG_ERROR([cannot link or copy $srcdir/$ac_source to $ac_file])
+ ln "$ac_source" "$ac_file" 2>/dev/null ||
+ cp -p "$ac_source" "$ac_file" ||
+ AC_MSG_ERROR([cannot link or copy $ac_source to $ac_file])
])# _AC_OUTPUT_LINK
Index: tests/torture.at
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/torture.at,v
retrieving revision 1.81
diff -u -r1.81 torture.at
--- tests/torture.at 7 Feb 2007 17:45:37 -0000 1.81
+++ tests/torture.at 7 Apr 2007 13:11:39 -0000
@@ -135,32 +135,38 @@
AT_DATA([configure.ac],
[[AC_INIT
-rm -f -r header var-header file var-file link var-link command var-command
-echo 'OK' >input
+(cd deep/dir && rm -f -r header var-header file var-file link var-link command
var-command )
+rm -f sub/input
+echo 'NOT OK' >$srcdir/sub/input
+echo 'OK' >$indir/input
# Be sure to also stress the associated INIT-CMDS.
case $what_to_test in
header)
- AC_CONFIG_HEADERS(header:input);;
+ AC_CONFIG_HEADERS(deep/dir/header:sub/input);;
var-header)
- AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
+ header_in=sub/input
+ AC_CONFIG_HEADERS(deep/dir/var-header:$header_in, [],
[header_in='$header_in']);;
file)
- AC_CONFIG_FILES(file:input);;
+ AC_CONFIG_FILES(deep/dir/file:sub/input);;
var-file)
- AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
+ file_in=sub/input
+ AC_CONFIG_FILES(deep/dir/var-file:$file_in, [], [file_in='$file_in']);;
command)
- AC_CONFIG_COMMANDS(command,
- [cp input command]);;
+ AC_CONFIG_COMMANDS(deep/dir/command,
+ [cp $indir/input deep/dir/command]);;
var-command)
- AC_CONFIG_COMMANDS(var-command,
- [cp $command_in var-command], [command_in=input]);;
+ command_in=$indir/input
+ AC_CONFIG_COMMANDS(deep/dir/var-command,
+ [cp $command_in deep/dir/var-command],
[command_in='$command_in']);;
link)
- AC_CONFIG_LINKS(link:input);;
+ AC_CONFIG_LINKS(deep/dir/link:sub/input);;
var-link)
- AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
+ link_in=sub/input
+ AC_CONFIG_LINKS(deep/dir/var-link:$link_in, [], [link_in='$link_in']);;
esac
AC_OUTPUT
]])
@@ -175,24 +181,36 @@
# Use `grep OK' instead of a simple `cat' to avoid banners such as in
# AC_CONFIG_HEADERS.
m4_define([AT_CHECK_CONFIG_CREATION],
-[AT_CHECK_CONFIGURE([what_to_test=$1])
-AT_CHECK([ls header var-header file var-file command var-command link var-link
2>/dev/null],
- [ignore], [$1
+[AT_CAPTURE_FILE([config.log])
+for indir in sub $source_dir; do
+ export indir
+ m4_foreach([Thing], [[$1], [var-$1]], [
+ AT_CHECK([eval "top_srcdir=\$abs_top_srcdir ../configure
$configure_options" what_to_test=Thing],
+ [], [ignore])
+ AT_CHECK([cd deep/dir && ls header var-header file var-file command
var-command link var-link 2>/dev/null],
+ [ignore], [Thing
+])
+ AT_CHECK([cd deep/dir && grep OK Thing], [], [OK
+])
+
+ rm deep/dir/Thing
+ AT_CHECK([eval "top_srcdir=\$abs_top_srcdir ../configure
$configure_options" what_to_test=Thing --no-create],
+ [], [ignore])
+ # config.status might be stupidly expecting data on stdin, if it's
+ # really broken...
+ AT_CHECK([./config.status deep/dir/Thing </dev/null], [], [ignore])
+ AT_CHECK([cd deep/dir && ls header var-header file var-file command
var-command link var-link 2>/dev/null],
+ [ignore], [Thing
])
-AT_CHECK([grep OK $1], [], [OK
-])
-
-AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
-# config.status might be stupidly expecting data on stdin, if it's
-# really broken...
-AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
-AT_CHECK([ls header var-header file var-file command var-command link var-link
2>/dev/null],
- [ignore], [var-$1
-])
-AT_CHECK([grep OK var-$1], [], [OK
+ AT_CHECK([cd deep/dir && grep OK Thing], [], [OK
])
+ ])
+done
])# AT_CHECK_CONFIG_CREATION
+mkdir sub build build/sub build/deep build/deep/dir
+source_dir=`pwd`/sub
+cd build
# Create a file
AT_CHECK_CONFIG_CREATION(file)
- AC_CONFIG_LINKS should look in build tree; more AC_CONFIG_FOOs issues,
Ralf Wildenhues <=