[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
rewrite of m4/depout.m4
From: |
Ralf Wildenhues |
Subject: |
rewrite of m4/depout.m4 |
Date: |
Sat, 6 May 2006 18:13:25 +0200 |
User-agent: |
Mutt/1.5.11+cvs20060403 |
Let's un-bitrot _AM_OUTPUT_DEPENDENCY_COMMANDS and make it nice and
fast. We observe:
1) In the line,
| test -z "am__include" && continue
there's a `$' missing; but also, am__include may be `#' but not `'.
2) Some inconsistent quoting: for example, the argument to AS_MKDIR_P
has not been quoted by Autoconf since end of 2000-11-10. So let's do
that.
3) Several of the values we extract from the Makefile are constant over
all Makefiles, and moreover known and fixed at config.status time;
so they can be passed in the INIT-COMMANDS of AC_CONFIG_COMMANDS.
* m4/depout.m4
Index: m4/depout.m4
===================================================================
RCS file: /cvs/automake/automake/m4/depout.m4,v
retrieving revision 1.18
diff -u -r1.18 depout.m4
--- m4/depout.m4 9 Jan 2005 14:46:21 -0000 1.18
+++ m4/depout.m4 5 May 2006 08:57:51 -0000
@@ -14,38 +14,42 @@
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
- mf=`echo "$mf" | sed -e 's/:.*$//'`
+ mf=`echo "$mf" | sed 's/:.*//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# So let's grep whole file.
- if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
+ if grep '^#.*generated by automake' "$mf" > /dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
- # Extract the definition of DEPDIR, am__include, and am__quote
+ # Extract the definition of top_builddir
# from the Makefile without running `make'.
- DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
- test -z "$DEPDIR" && continue
- am__include=`sed -n 's/^am__include = //p' < "$mf"`
- test -z "am__include" && continue
- am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
- # When using ansi2knr, U may be empty or an underscore; expand it
- U=`sed -n 's/^U = //p' < "$mf"`
- # Find all dependency output files, they are included files with
- # $(DEPDIR) in their names. We invoke sed twice because it is the
- # simplest approach to changing $(DEPDIR) to its actual value in the
- # expansion.
+ am__top_builddir=`sed -n 's/^\(top_builddir\) = /am__\1=/p' < "$mf"`
+ test -z "$am__top_builddir" && am__top_builddir=.
+ # The script below extracts all dependency output files; they are
+ # included files with $(DEPDIR) in their names.
+ # Furthermore, the include statement may contain
+ # - $U when using ansi2knr (empty or an underscore)
+ # - $(top_builddir) when using LIBOBJDIR and subdir-objects
+ #
+ # Since this code is executed often, care is taken to use
+ # few forks and read $mf few times.
for file in `sed -n "
- s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
- sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+ /^$am__include $am__quote.*(DEPDIR).*$am__quote\$/{
+ s&^$am__include $am__quote\\(.*(DEPDIR).*\\)$am__quote\$&\\1&
+ s&\\\$(DEPDIR)&$DEPDIR&g
+ s&\\\$U&$U&g
+ s&\\\$(top_builddir)&$am__top_builddir&g
+ p
+ }" <"$mf"`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
- AS_MKDIR_P([$dirpart/$fdir])
+ AS_MKDIR_P(["$dirpart/$fdir"])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
@@ -62,6 +66,9 @@
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
- [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
- [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+ [test x"$AMDEP_TRUE" = x"" && test -n "$DEPDIR" &&
+ test x"$am__include" != x"#" &&
+ _AM_OUTPUT_DEPENDENCY_COMMANDS],
+ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" U="$U"
+ DEPDIR="$DEPDIR" am__include="$am__include" am__quote='$am__quote'])
])
- rewrite of m4/depout.m4,
Ralf Wildenhues <=