Patches from Jim Meyering.
[platform/upstream/automake.git] / depend.am
1 ## automake - create Makefile.in from Makefile.am
2 ## Copyright (C) 1994, 1995, 1996 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 # This fragment is probably only useful for maintainers.  It relies on
19 # GNU make and gcc.  It is only included in the generated Makefile.in
20 # if `automake' is not passed the `--include-deps' flag.
21
22 MKDEP = gcc -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
23
24 ## Use $(kr) in case we are doing auto-deANSIfication.
25 DEP_FILES = $(patsubst %.$(kr)o, $(srcdir)/.deps/%.P,$(OBJECTS))
26
27 ## We use ".P" as the name of our placeholder because it can't be
28 ## duplicated by any C source file.  (Well, there could be ".c", but
29 ## no one does that in practice)
30 -include $(srcdir)/.deps/.P
31 $(srcdir)/.deps/.P: $(BUILT_SOURCES)
32         cd $(srcdir) && test -d .deps || mkdir .deps
33 ## Use ":" here and not "echo timestamp".  Otherwise GNU Make barfs:
34 ## .deps/.P:1: *** missing separator.  Stop.
35         : > $@
36
37 -include $(DEP_FILES)
38 $(DEP_FILES): $(srcdir)/.deps/.P
39
40 $(srcdir)/.deps/%.P: $(srcdir)/%.c
41         @echo "mkdeps $< > $@"
42 ## Need \< in regexp because otherwise when srcdir=. too much can be
43 ## matched.  Also we regexp-quote srcdir because "." is a matching
44 ## operator, and commonly appears in filenames.
45         @re=`echo 's,\<$(srcdir),,g' | sed 's/\./\\./g'`; \
46           $(MKDEP) $< | sed $$re > $@-tmp
47         @mv $@-tmp $@
48
49 # End of maintainer-only section