chiark / gitweb /
Error handling: Provide err and ddbl_only, and an internal spec
[subdirmk.git] / cdeps.sd.mk
1 # subdirmk - useful rules for making and using cpp .*.d files
2 #  Copyright 2019 Mark Wooding
3 #  Copyright 2019 Ian Jackson
4 # SPDX-License-Identifier: LGPL-2.0-or-later
5
6 &# Usage:
7 &#   &:include subdirmk/cdeps.sd.mk
8 &# (probably in Suffix.sd.mk)
9 &#
10 &# Arranges for automatic #include dependency tracking for
11 &# C compilation.  The compiler is asked to write the dependencies to
12 &#  .*.d and these are automatically included.
13 &#
14 &# There is a bug: if a #included file is deleted and all references
15 &# in .c files to it removed, `make' will complain that it is needed
16 &# and can't be built.  `make clean' will fix this.
17
18 CDEPS_CFLAGS ?= -MD -MF $(*D)/.$(*F).d
19
20 &CDEPS_OBJECTS += $(&OBJECTS)
21
22 &DEPFILES += $(foreach b,$(patsubst %.o,%,$(&CDEPS_OBJECTS)), \
23                 $(dir $b).$(notdir $b).d)
24 -include $(&DEPFILES)
25
26 &CLEAN += $(&DEPFILES)