From: Alejandro Colomar Date: Sat, 2 Apr 2022 23:57:19 +0000 (+0200) Subject: Makefile: lint-iwyu: Add target to run iwyu(1) to lint example programs X-Git-Tag: man-pages-5.19-rc1~52 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c06d9826c2dfe39bd83f09f29c67bb4291198be2;p=thirdparty%2Fman-pages.git Makefile: lint-iwyu: Add target to run iwyu(1) to lint example programs Signed-off-by: Alejandro Colomar --- diff --git a/Makefile b/Makefile index 84f06c0d29..55d5648e1b 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,11 @@ _mandir := $(DESTDIR)$(mandir) _htmldir := $(DESTDIR)$(htmldir_) +DEFAULT_IWYUFLAGS := -Xiwyu --no_fwd_decls +DEFAULT_IWYUFLAGS += -Xiwyu --error +EXTRA_IWYUFLAGS := +IWYUFLAGS := $(DEFAULT_IWYUFLAGS) $(EXTRA_IWYUFLAGS) + DEFAULT_CPPFLAGS := EXTRA_CPPFLAGS := CPPFLAGS := $(DEFAULT_CPPFLAGS) $(EXTRA_CPPFLAGS) @@ -136,6 +141,7 @@ INSTALL_DIR := $(INSTALL) -m 755 -d MKDIR := mkdir -p RM := rm RMDIR := rmdir --ignore-fail-on-non-empty +IWYU := iwyu CC := cc LD := $(CC) $(CFLAGS) GROFF := groff @@ -213,6 +219,7 @@ _UNITS_c :=$(sort $(patsubst $(MANDIR)/%,$(_SRCDIR)/%,$(shell \ done))) _UNITS_o := $(patsubst %.c,%.o,$(_UNITS_c)) _UNITS_bin := $(patsubst %.c,%,$(_UNITS_c)) +_LINT_iwyu := $(patsubst %.c,%.lint.iwyu.touch,$(_UNITS_c)) MANDIRS := $(sort $(shell find $(MANDIR)/man? -type d)) _HTMLDIRS := $(patsubst $(MANDIR)/%,$(_HTMLDIR)/%/.,$(MANDIRS)) @@ -349,9 +356,14 @@ builddirs-src: $(_SRCDIRS) ######################################################################## # lint -linters := groff mandoc +linters := iwyu groff mandoc lint := $(foreach x,$(linters),lint-$(x)) +$(_LINT_iwyu): %.lint.iwyu.touch: %.c + $(info LINT (iwyu) $@) + $(IWYU) $(IWYUFLAGS) $(CPPFLAGS) $(CFLAGS) $< + touch $@ + $(_LINT_groff): $(_LINTDIR)/%.lint.groff.touch: $(MANDIR)/% | $$(@D)/. $(info LINT (groff) $@) $(GROFF) $(GROFFFLAGS) -z $< @@ -370,7 +382,7 @@ $(lint): lint-%: $$(_LINT_%) | lintdirs @: .PHONY: lintdirs -lintdirs: $(_LINTDIRS) +lintdirs: $(_LINTDIRS) $(_SRCDIRS) @: .PHONY: lint