X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=subdirmk%2Fcdeps.sd.mk;fp=subdirmk%2Fcdeps.sd.mk;h=402e687c6aa63153951e95e704d02f488a77d547;hb=e84c081039387230c524f9f34903afacaab4219b;hp=0000000000000000000000000000000000000000;hpb=d212a384b4ef631a876e1ddd3e52fd09e4b1f484;p=secnet.git diff --git a/subdirmk/cdeps.sd.mk b/subdirmk/cdeps.sd.mk new file mode 100644 index 0000000..402e687 --- /dev/null +++ b/subdirmk/cdeps.sd.mk @@ -0,0 +1,24 @@ +# subdirmk - useful rules for making and using cpp .*.d files +# Copyright 2019 Mark Wooding +# Copyright 2019 Ian Jackson +# SPDX-License-Identifier: LGPL-2.0-or-later + +&# Usage: +&# &:include subdirmk/cdeps.sd.mk +&# (probably in Perdir.sd.mk) +&# +&# Arranges for automatic #include dependency tracking for +&# C compilation. The compiler is asked to write the dependencies to +&# .*.d and these are automatically included. +&# +&# There is a bug: if a #included file is deleted and all references +&# in .c files to it removed, `make' will complain that it is needed +&# and can't be built. `make clean' will fix this. + +CDEPS_CFLAGS ?= -MD -MF $(*D)/.$(*F).d + +&DEPFILES += $(foreach b,$(patsubst %.o,%,$(&OBJECTS)), \ + $(dir $b).$(notdir $b).d) +-include $(&DEPFILES) + +&CLEAN += $(&DEPFILES)