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 # There is NO WARRANTY.
8 &# &:include subdirmk/cdeps.sd.mk
9 &# (probably in Suffix.sd.mk)
11 &# Arranges for automatic #include dependency tracking for
12 &# C compilation. The compiler is asked to write the dependencies to
13 &# .*.d and these are automatically included.
15 &# There is a bug: if a #included file is deleted and all references
16 &# in .c files to it removed, `make' will complain that it is needed
17 &# and can't be built. `make clean' will fix this.
19 CDEPS_CFLAGS ?= -MD -MF $(*D)/.$(*F).d
21 &CDEPS_OBJECTS += $(&OBJECTS)
23 &DEPFILES += $(foreach b,$(patsubst %.o,%,$(&CDEPS_OBJECTS)), \
24 $(dir $b).$(notdir $b).d)
27 &CLEAN += $(&DEPFILES)