* automake.texi (Texinfo): Mention vers*.texi.
[automake.git] / m4 / depout.m4
blobe79edf8623c4986ec27aedc8cc9ed7dbc1ed8292
1 dnl Generate code to set up dependency tracking.
2 dnl This macro should only be invoked once -- use via AC_REQUIRE.
3 dnl Usage:
4 dnl AM_OUTPUT_DEPENDENCY_COMMANDS
6 dnl
7 dnl This code is only required when automatic dependency tracking
8 dnl is enabled.  FIXME.  This creates each `.P' file that we will
9 dnl need in order to bootstrap the dependency handling code.
10 AC_DEFUN(AM_OUTPUT_DEPENDENCY_COMMANDS,[
11 AC_OUTPUT_COMMANDS([
12 test x"$AMDEP" != x"" ||
13 for mf in $CONFIG_FILES; do
14   case "$mf" in
15   Makefile) dirpart=.;;
16   */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;;
17   *) continue;;
18   esac
19   grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
20   # Extract the definition of DEP_FILES from the Makefile without
21   # running `make'.
22   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
23   test -z "$DEPDIR" && continue
24   # When using ansi2knr, U may be empty or an underscore; expand it
25   U=`sed -n -e '/^U = / s///p' < "$mf"`
26   test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
27   # We invoke sed twice because it is the simplest approach to
28   # changing $(DEPDIR) to its actual value in the expansion.
29   for file in `sed -n -e '
30     /^DEP_FILES = .*\\\\$/ {
31       s/^DEP_FILES = //
32       :loop
33         s/\\\\$//
34         p
35         n
36         /\\\\$/ b loop
37       p
38     }
39     /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
40        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
41     # Make sure the directory exists.
42     test -f "$dirpart/$file" && continue
43     fdir=`echo "$file" | sed -e 's|/[^/]*$||'`
44     $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1
45     # echo "creating $dirpart/$file"
46     echo '# dummy' > "$dirpart/$file"
47   done
48 done
49 ], [AMDEP="$AMDEP"
50 ac_aux_dir="$ac_aux_dir"])])