bb457380a591e6d960474330c833ac0a251019d4
[platform/upstream/automake.git] / m4 / depout.m4
1 # Generate code to set up dependency tracking.   -*- Autoconf -*-
2
3 # Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
4
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 # 02111-1307, USA.
19
20 #serial 2
21
22 # _AM_OUTPUT_DEPENDENCY_COMMANDS
23 # ------------------------------
24 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
25 [for mf in $CONFIG_FILES; do
26   # Strip MF so we end up with the name of the file.
27   mf=`echo "$mf" | sed -e 's/:.*$//'`
28   if (head -1 $mf | fgrep 'generated by automake') > /dev/null 2>&1; then
29     dirpart=`AS_DIRNAME("$mf")`
30   else
31     dirpart=
32   fi
33   grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
34   # Extract the definition of DEP_FILES from the Makefile without
35   # running `make'.
36   DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"`
37   test -z "$DEPDIR" && continue
38   # When using ansi2knr, U may be empty or an underscore; expand it
39   U=`sed -n -e '/^U = / s///p' < "$mf"`
40   test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
41   # We invoke sed twice because it is the simplest approach to
42   # changing $(DEPDIR) to its actual value in the expansion.
43   for file in `sed -n -e '
44     /^DEP_FILES = .*\\\\$/ {
45       s/^DEP_FILES = //
46       :loop
47         s/\\\\$//
48         p
49         n
50         /\\\\$/ b loop
51       p
52     }
53     /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
54        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
55     # Make sure the directory exists.
56     test -f "$dirpart/$file" && continue
57     fdir=`AS_DIRNAME(["$file"])`
58     AS_MKDIR_P([$dirpart/$fdir])
59     # echo "creating $dirpart/$file"
60     echo '# dummy' > "$dirpart/$file"
61   done
62 done
63 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
64
65
66 # AM_OUTPUT_DEPENDENCY_COMMANDS
67 # -----------------------------
68 # This macro should only be invoked once -- use via AC_REQUIRE.
69 #
70 # This code is only required when automatic dependency tracking
71 # is enabled.  FIXME.  This creates each `.P' file that we will
72 # need in order to bootstrap the dependency handling code.
73 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
74 [AC_CONFIG_COMMANDS([depfiles],
75      [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
76      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
77 ])