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>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-11-01 23:35:45 +01:00 коммит произвёл Taylor Blau
Родитель 895ae7ae2a
Коммит e603a140ae
1 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -3139,9 +3139,20 @@ check: $(GENERATED_H)
exit 1; \
fi
COCCI_GLOB = $(wildcard contrib/coccinelle/*.cocci)
COCCI_RULES = $(COCCI_GLOB)
COCCICHECK_PENDING = $(filter %.pending.cocci,$(COCCI_RULES))
COCCICHECK = $(filter-out $(COCCICHECK_PENDING),$(COCCI_RULES))
COCCICHECK_PATCHES = $(COCCICHECK:%=%.patch)
COCCICHECK_PATCHES_PENDING = $(COCCICHECK_PENDING:%=%.patch)
COCCI_TEST_RES = $(wildcard contrib/coccinelle/tests/*.res)
%.cocci.patch: %.cocci $(COCCI_SOURCES)
COCCI_PATCHES = $(COCCI_RULES:%=%.patch)
$(COCCI_PATCHES): $(COCCI_SOURCES)
$(COCCI_PATCHES): %.patch: %
$(QUIET_SPATCH) \
if test $(SPATCH_BATCH_SIZE) = 0; then \
limit=; \
@ -3178,11 +3189,11 @@ $(COCCI_TEST_RES_GEN): .build/contrib/coccinelle/tests/%.res : contrib/coccinell
coccicheck-test: $(COCCI_TEST_RES_GEN)
coccicheck: coccicheck-test
coccicheck: $(addsuffix .patch,$(filter-out %.pending.cocci,$(wildcard contrib/coccinelle/*.cocci)))
coccicheck: $(COCCICHECK_PATCHES)
# See contrib/coccinelle/README
coccicheck-pending: coccicheck-test
coccicheck-pending: $(addsuffix .patch,$(wildcard contrib/coccinelle/*.pending.cocci))
coccicheck-pending: $(COCCICHECK_PATCHES_PENDING)
.PHONY: coccicheck coccicheck-pending