Makefile: add ability to TAB-complete cocci *.patch rules
Declare the contrib/coccinelle/<rule>.cocci.patch rules in such a way as to allow TAB-completion, and slightly optimize the Makefile by cutting down on the number of $(wildcard) in favor of defining "coccicheck" and "coccicheck-pending" in terms of the same incrementally filtered list. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Ævar Arnfjörð Bjarmason committed
Nov 1, 2022 at 23:35 UTC
e603a140aed8fc362320d949bfc0b47adcefc32f
1 file changed
+14
-3
Makefile
+14
-3
@@ -3139,9 +3139,20 @@ check: $(GENERATED_H)
3139
exit 1; \
3140
fi
3141
3142
+COCCI_GLOB = $(wildcard contrib/coccinelle/*.cocci)
3143
+COCCI_RULES = $(COCCI_GLOB)
3144
+
3145
+COCCICHECK_PENDING = $(filter %.pending.cocci,$(COCCI_RULES))
3146
+COCCICHECK = $(filter-out $(COCCICHECK_PENDING),$(COCCI_RULES))
3147
+
3148
+COCCICHECK_PATCHES = $(COCCICHECK:%=%.patch)
3149
+COCCICHECK_PATCHES_PENDING = $(COCCICHECK_PENDING:%=%.patch)
3150
+
3151
COCCI_TEST_RES = $(wildcard contrib/coccinelle/tests/*.res)
3152
3144
-%.cocci.patch: %.cocci $(COCCI_SOURCES)
3153
+COCCI_PATCHES = $(COCCI_RULES:%=%.patch)
3154
+$(COCCI_PATCHES): $(COCCI_SOURCES)
3155
+$(COCCI_PATCHES): %.patch: %
3156
$(QUIET_SPATCH) \
3157
if test $(SPATCH_BATCH_SIZE) = 0; then \
3158
limit=; \
@@ -3178,11 +3189,11 @@ $(COCCI_TEST_RES_GEN): .build/contrib/coccinelle/tests/%.res : contrib/coccinell
3189
coccicheck-test: $(COCCI_TEST_RES_GEN)
3190
3191
coccicheck: coccicheck-test
3181
-coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/coccinelle/*.cocci)))
3192
+coccicheck: $(COCCICHECK_PATCHES)
3193
3194
# See contrib/coccinelle/README
3195
coccicheck-pending: coccicheck-test
3185
-coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci))
3196
+coccicheck-pending: $(COCCICHECK_PATCHES_PENDING)
3197
3198
.PHONY: coccicheck coccicheck-pending
3199