summaryrefslogtreecommitdiffstats
path: root/config/depend.in
blob: 46dac4eaac51403caf859944186a34e5cc90e244 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#------------------------------------------------------------- -*- makefile -*-
# The following section of this makefile comes from the
# `./config/targets' file which was generated with config.status
# from `./config/targets.in'.
#------------------------------------------------------------------------------

# We keep a list of dependencies in `.depend' for each of the source
# files on which it depends.  When one of the source files is modified
# we remove its record from .depend and regenerate its dependencies,
# tacking them onto the end of .depend.  By including the .depend file
# into the makefile, we're telling make that the makefile depends on
# the dependency list in the .depend file.
#
# This is as fast as the `.d' method described in the GNU make manual
# for automatic dependencies, but has the added advantage that all
# dependencies are stored in one place.  The advantage over the
# `makedepend' program is that only those files that are out of date
# have dependency information rebuilt, and the Makefile is not
# modified.
#
.PRECIOUS: .depend
dep depend: .depend

.depend: $(LIB_SRC) $(PROG_SRC)
	@touch .depend
	@for dep in $? dummy; do					      \
	   if [ $$dep != "dummy" ]; then				      \
	      echo Building dependencies for $$dep;			      \
	      obj=`echo $$dep | sed 's/\.c/\\\\.o/'`;			      \
	      sed "/$$obj/,/[^\\]$$/d" <$@ >$@- && mv $@- $@;		      \
	      $(CC) -M -MG $(CPPFLAGS) $$dep >>$@;			      \
	   fi;								      \
	done

-include .depend