X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=blobdiff_plain;f=subdirmk%2Fcdeps.sd.mk;h=5a2bfb28df5bf2737c2c556eac31b1090c7b41db;hp=6ba0bbb271093c94130ed56d649181f34bbd378f;hb=95bcfc013b7ec7ccf60e522409d71daa7464a2ee;hpb=6600b10418c5c38d43bf6c732724123ed34779b6 diff --git a/subdirmk/cdeps.sd.mk b/subdirmk/cdeps.sd.mk index 6ba0bbb..5a2bfb2 100644 --- a/subdirmk/cdeps.sd.mk +++ b/subdirmk/cdeps.sd.mk @@ -3,9 +3,24 @@ # 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)), \ +&CDEPS_OBJECTS += $(&OBJECTS) + +&DEPFILES += $(foreach b,$(patsubst %.o,%,$(&CDEPS_OBJECTS)), \ $(dir $b).$(notdir $b).d) -include $(&DEPFILES) +&CLEAN += $(&DEPFILES)