* automake.in (handle_lib_objects_cond): Prefer `$1' over `\1'.
[platform/upstream/automake.git] / lib / am / depend2.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994-1998, 1999 Free Software Foundation, Inc.
3
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
7 ## any later version.
8
9 ## This program is distributed in the hope that it will be useful,
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ## GNU General Public License for more details.
13
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; if not, write to the Free Software
16 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 ## 02111-1307, USA.
18 @OBJ@: @SOURCE@
19         @echo '@COMPILE@ -c -o $@ $<'; \
20 ## There are various ways to get dependency output from gcc.  Here's
21 ## why we pick this rather obscure method:
22 ## - Don't want to use -MD because we'd like the dependencies to end
23 ##   up in a subdir.  Having to rename by hand is ugly.
24 ##   (We might end up doing this anyway to support other compilers.)
25 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
26 ##   -MM, not -M (despite what the docs say).
27 ## - Using -M directly means running the compiler twice (even worse
28 ##   than renaming).
29         @COMPILE@ -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $<
30 ## This next piece of magic avoids the `deleted header file' problem.
31 ## The problem is that when a header file which appears in a .P file
32 ## is deleted, the dependency causes make to die (because there is
33 ## typically no way to rebuild the header).  We avoid this by adding
34 ## dummy dependencies for each header file.  Too bad gcc doesn't do
35 ## this for us directly.
36         @-cp .deps/$(*D)/$(*F).pp .deps/$(*D)/$(*F).P; \
37         tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
38 ## Some versions of gcc put a space before the `:'.  On the theory
39 ## that the space means something, we add a space to the output as
40 ## well.
41           | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
42             >> .deps/$(*D)/$(*F).P; \
43         rm .deps/$(*D)/$(*F).pp
44
45 @LTOBJ@: @SOURCE@
46         @echo '@LTCOMPILE@ -c -o $@ $<'; \
47 ## See above to understand implementation weirdness.
48         @LTCOMPILE@ -Wp,-MD,.deps/$(*D)/$(*F).pp -c -o $@ $<
49 ## Account for versions of gcc that put a space before the `:'.
50         @-sed -e 's/^\([^:]*\)\.o[      ]*:/\1.lo \1.o :/' \
51           < .deps/$(*D)/$(*F).pp > .deps/$(*D)/$(*F).P; \
52 ## See above to understand deleted header file trick.
53         tr ' ' '\012' < .deps/$(*D)/$(*F).pp \
54 ## Some versions of gcc put a space before the `:'.  On the theory
55 ## that the space means something, we add a space to the output as
56 ## well.
57           | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
58             >> .deps/$(*D)/$(*F).P; \
59         rm -f .deps/$(*D)/$(*F).pp