recursion: support user-defined recursive targets
[platform/upstream/automake.git] / m4 / depout.m4
1 # Generate code to set up dependency tracking.              -*- Autoconf -*-
2
3 # Copyright (C) 1999-2012 Free Software Foundation, Inc.
4 #
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # serial 7
10
11 # _AM_OUTPUT_DEPENDENCY_COMMANDS
12 # ------------------------------
13 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
14 [{
15   # Older Autoconf quotes --file arguments for eval, but not when files
16   # are listed without --file.  Let's play safe and only enable the eval
17   # if we detect the quoting.
18   case $CONFIG_FILES in
19   *\'*) eval set x "$CONFIG_FILES" ;;
20   *)   set x $CONFIG_FILES ;;
21   esac
22   shift
23   for mf
24   do
25     # Strip MF so we end up with the name of the file.
26     mf=`echo "$mf" | sed -e 's/:.*$//'`
27     # Check whether this is an Automake generated Makefile or not.
28     # We used to match only the files named 'Makefile.in', but
29     # some people rename them; so instead we look at the file content.
30     # Grep'ing the first line is not enough: some people post-process
31     # each Makefile.in and add a new line on top of each file to say so.
32     # Grep'ing the whole file is not good either: AIX grep has a line
33     # limit of 2048, but all sed's we know have understand at least 4000.
34     if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
35       dirpart=`AS_DIRNAME("$mf")`
36     else
37       continue
38     fi
39     # Extract the definition of DEPDIR, am__include, and am__quote
40     # from the Makefile without running 'make'.
41     DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
42     test -z "$DEPDIR" && continue
43     am__include=`sed -n 's/^am__include = //p' < "$mf"`
44     test -z "am__include" && continue
45     am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
46     # Find all dependency output files, they are included files with
47     # $(DEPDIR) in their names.  We invoke sed twice because it is the
48     # simplest approach to changing $(DEPDIR) to its actual value in the
49     # expansion.
50     for file in `sed -n "
51       s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
52          sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
53       # Make sure the directory exists.
54       test -f "$dirpart/$file" && continue
55       fdir=`AS_DIRNAME(["$file"])`
56       AS_MKDIR_P([$dirpart/$fdir])
57       # echo "creating $dirpart/$file"
58       echo '# dummy' > "$dirpart/$file"
59     done
60   done
61 }
62 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
63
64
65 # AM_OUTPUT_DEPENDENCY_COMMANDS
66 # -----------------------------
67 # This macro should only be invoked once -- use via AC_REQUIRE.
68 #
69 # This code is only required when automatic dependency tracking
70 # is enabled.  FIXME.  This creates each '.P' file that we will
71 # need in order to bootstrap the dependency handling code.
72 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
73 [AC_CONFIG_COMMANDS([depfiles],
74      [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
75      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
76 ])