chiark / gitweb /
changelog: work on documentation of changes since ea31544cc33a
[secnet.git] / subdirmk / cdeps.sd.mk
index c898cc09d1c6e3337364b824a6b5af2f1260245d..37ea60ff856f70b1339da87e997aaa3d31c34b3f 100644 (file)
@@ -2,8 +2,26 @@
 #  Copyright 2019 Mark Wooding
 #  Copyright 2019 Ian Jackson
 # SPDX-License-Identifier: LGPL-2.0-or-later
+# There is NO WARRANTY.
 
-&DEPFILES += $(foreach b,$(patsubst %.o,%,$(&OBJECTS)), \
+&# 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
+
+&CDEPS_OBJECTS += $(&OBJECTS)
+
+&DEPFILES += $(foreach b,$(patsubst %.o,%,$(&CDEPS_OBJECTS)), \
                $(dir $b).$(notdir $b).d)
 -include $(&DEPFILES)
 
+&CLEAN += $(&DEPFILES)