X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=subdirmk%2Fcdeps.sd.mk;h=37ea60ff856f70b1339da87e997aaa3d31c34b3f;hb=16bce837ffe3527d4e8ed306f4436a86891d6e60;hp=5d58b6b90c979ccd5153a95aed7f1e007d3a0301;hpb=a2d0da0b0b2f40319d8787b98f5198f78303f85d;p=secnet.git diff --git a/subdirmk/cdeps.sd.mk b/subdirmk/cdeps.sd.mk index 5d58b6b..37ea60f 100644 --- a/subdirmk/cdeps.sd.mk +++ b/subdirmk/cdeps.sd.mk @@ -2,10 +2,25 @@ # Copyright 2019 Mark Wooding # Copyright 2019 Ian Jackson # SPDX-License-Identifier: LGPL-2.0-or-later +# There is NO WARRANTY. + +&# Usage: +&# &:include subdirmk/cdeps.sd.mk +&# (probably in Suffix.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)