diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:40:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:40:15 +0000 |
commit | 399644e47874bff147afb19c89228901ac39340e (patch) | |
tree | 1c4c0b733f4c16b5783b41bebb19194a9ef62ad1 /share/mk/lint | |
parent | Initial commit. (diff) | |
download | manpages-upstream/6.05.01.tar.xz manpages-upstream/6.05.01.zip |
Adding upstream version 6.05.01.upstream/6.05.01
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share/mk/lint')
-rw-r--r-- | share/mk/lint/_.mk | 18 | ||||
-rw-r--r-- | share/mk/lint/c.mk | 102 | ||||
-rw-r--r-- | share/mk/lint/man/_.mk | 16 | ||||
-rw-r--r-- | share/mk/lint/man/man.mk | 69 | ||||
-rw-r--r-- | share/mk/lint/man/mdoc.mk | 44 |
5 files changed, 249 insertions, 0 deletions
diff --git a/share/mk/lint/_.mk b/share/mk/lint/_.mk new file mode 100644 index 0000000..9d93bd3 --- /dev/null +++ b/share/mk/lint/_.mk @@ -0,0 +1,18 @@ +######################################################################## +# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: GPL-3.0-or-later +######################################################################## + + +ifndef MAKEFILE_LINT_INCLUDED +MAKEFILE_LINT_INCLUDED := 1 + + +lint := lint-c lint-man lint-mdoc + + +.PHONY: lint +lint: $(lint); + + +endif # include guard diff --git a/share/mk/lint/c.mk b/share/mk/lint/c.mk new file mode 100644 index 0000000..b7d80a9 --- /dev/null +++ b/share/mk/lint/c.mk @@ -0,0 +1,102 @@ +######################################################################## +# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: GPL-3.0-or-later +######################################################################## + + +ifndef MAKEFILE_LINT_C_INCLUDED +MAKEFILE_LINT_C_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/src.mk +include $(MAKEFILEDIR)/cmd.mk +include $(MAKEFILEDIR)/lint/_.mk + + +DEFAULT_CHECKPATCHFLAGS := +EXTRA_CHECKPATCHFLAGS := +CHECKPATCHFLAGS := $(DEFAULT_CHECKPATCHFLAGS) $(EXTRA_CHECKPATCHFLAGS) +CHECKPATCH := checkpatch + +clang-tidy_config := $(SYSCONFDIR)/clang-tidy/config.yaml +DEFAULT_CLANG-TIDYFLAGS := \ + --config-file=$(clang-tidy_config) \ + --quiet \ + --use-color +EXTRA_CLANG-TIDYFLAGS := +CLANG-TIDYFLAGS := $(DEFAULT_CLANG-TIDYFLAGS) $(EXTRA_CLANG-TIDYFLAGS) +CLANG-TIDY := clang-tidy + +CPPCHECK_SUPPRESS := $(SYSCONFDIR)/cppcheck/cppcheck.suppress +DEFAULT_CPPCHECKFLAGS := \ + --enable=all \ + --error-exitcode=2 \ + --inconclusive \ + --quiet \ + --suppressions-list=$(CPPCHECK_SUPPRESS) +EXTRA_CPPCHECKFLAGS := +CPPCHECKFLAGS := $(DEFAULT_CPPCHECKFLAGS) $(EXTRA_CPPCHECKFLAGS) +CPPCHECK := cppcheck + +DEFAULT_CPPLINTFLAGS := +EXTRA_CPPLINTFLAGS := +CPPLINTFLAGS := $(DEFAULT_CPPLINTFLAGS) $(EXTRA_CPPLINTFLAGS) +CPPLINT := cpplint + +DEFAULT_IWYUFLAGS := \ + -Xiwyu --no_fwd_decls \ + -Xiwyu --error +EXTRA_IWYUFLAGS := +IWYUFLAGS := $(DEFAULT_IWYUFLAGS) $(EXTRA_IWYUFLAGS) +IWYU := iwyu + + +_LINT_c_checkpatch := $(patsubst %.c,%.lint-c.checkpatch.touch,$(_UNITS_src_c)) +_LINT_c_clang-tidy := $(patsubst %.c,%.lint-c.clang-tidy.touch,$(_UNITS_src_c)) +_LINT_c_cppcheck := $(patsubst %.c,%.lint-c.cppcheck.touch,$(_UNITS_src_c)) +_LINT_c_cpplint := $(patsubst %.c,%.lint-c.cpplint.touch,$(_UNITS_src_c)) +_LINT_c_iwyu := $(patsubst %.c,%.lint-c.iwyu.touch,$(_UNITS_src_c)) + + +linters_c := checkpatch clang-tidy cppcheck cpplint iwyu +lint_c := $(foreach x,$(linters_c),lint-c-$(x)) + + +$(_LINT_c_checkpatch): %.lint-c.checkpatch.touch: %.c + $(info LINT (checkpatch) $@) + $(CHECKPATCH) $(CHECKPATCHFLAGS) -f $< + touch $@ + +$(_LINT_c_clang-tidy): %.lint-c.clang-tidy.touch: %.c + $(info LINT (clang-tidy) $@) + $(CLANG-TIDY) $(CLANG-TIDYFLAGS) $< -- $(CPPFLAGS) $(CFLAGS) 2>&1 \ + | $(SED) '/generated\.$$/d' + touch $@ + +$(_LINT_c_cppcheck): %.lint-c.cppcheck.touch: %.c + $(info LINT (cppcheck) $@) + $(CPPCHECK) $(CPPCHECKFLAGS) $< + touch $@ + +$(_LINT_c_cpplint): %.lint-c.cpplint.touch: %.c + $(info LINT (cpplint) $@) + $(CPPLINT) $(CPPLINTFLAGS) $< >/dev/null + touch $@ + +$(_LINT_c_iwyu): %.lint-c.iwyu.touch: %.c + $(info LINT (iwyu) $@) + $(IWYU) $(IWYUFLAGS) $(CPPFLAGS) $(CFLAGS) $< 2>&1 \ + | $(TAC) \ + | $(SED) '/correct/{N;d}' \ + | $(TAC) + touch $@ + + +.PHONY: $(lint_c) +$(lint_c): lint-c-%: $$(_LINT_c_%); + +.PHONY: lint-c +lint-c: $(lint_c); + + +endif # include guard diff --git a/share/mk/lint/man/_.mk b/share/mk/lint/man/_.mk new file mode 100644 index 0000000..8bbc01c --- /dev/null +++ b/share/mk/lint/man/_.mk @@ -0,0 +1,16 @@ +######################################################################## +# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: GPL-3.0-or-later +######################################################################## + + +ifndef MAKEFILE_LINT_MAN_INCLUDED +MAKEFILE_LINT_MAN_INCLUDED := 1 + + +DEFAULT_MANDOCFLAGS := -Tlint +EXTRA_MANDOCFLAGS := +MANDOCFLAGS := $(DEFAULT_MANDOCFLAGS) $(EXTRA_MANDOCFLAGS) + + +endif # include guard diff --git a/share/mk/lint/man/man.mk b/share/mk/lint/man/man.mk new file mode 100644 index 0000000..cb1bf53 --- /dev/null +++ b/share/mk/lint/man/man.mk @@ -0,0 +1,69 @@ +######################################################################## +# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: GPL-3.0-or-later +######################################################################## + + +ifndef MAKEFILE_LINT_MAN_MAN_INCLUDED +MAKEFILE_LINT_MAN_MAN_INCLUDED := 1 + + +include $(MAKEFILEDIR)/cmd.mk +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/lint/_.mk +include $(MAKEFILEDIR)/lint/man/_.mk +include $(MAKEFILEDIR)/src.mk + + +mandoc_man_ignore_grep := $(DATAROOTDIR)/lint/mandoc/man.ignore.grep + +_LINT_man_mandoc :=$(patsubst $(MANDIR)/%,$(_MANDIR)/%.lint-man.mandoc.touch,$(NONSO_MAN)) +_LINT_man_tbl :=$(patsubst $(MANDIR)/%,$(_MANDIR)/%.lint-man.tbl.touch,$(NONSO_MAN)) + + +linters_man := mandoc tbl +lint_man := $(foreach x,$(linters_man),lint-man-$(x)) + + +$(_LINT_man_mandoc): $(_MANDIR)/%.lint-man.mandoc.touch: $(MANDIR)/% $(mandoc_man_ignore_grep) | $$(@D)/ + $(info LINT (mandoc) $@) + ! ($(MANDOC) -man $(MANDOCFLAGS) $< 2>&1 \ + | $(GREP) -v -f '$(mandoc_man_ignore_grep)' \ + ||:; \ + ) \ + | $(GREP) ^ >&2 + touch $@ + +$(_LINT_man_tbl): $(_MANDIR)/%.lint-man.tbl.touch: $(MANDIR)/% | $$(@D)/ + $(info LINT (tbl comment) $@) + if $(GREP) -q '^\.TS$$' $< && ! $(HEAD) -n1 $< | $(GREP) -q '\\" t$$'; \ + then \ + >&2 $(ECHO) "$<:1: missing '\\\" t' comment:"; \ + >&2 $(HEAD) -n1 <$<; \ + exit 1; \ + fi + if $(HEAD) -n1 $< | $(GREP) -q '\\" t$$' && ! $(GREP) -q '^\.TS$$' $<; \ + then \ + >&2 $(ECHO) "$<:1: spurious '\\\" t' comment:"; \ + >&2 $(HEAD) -n1 <$<; \ + exit 1; \ + fi + if $(TAIL) -n+2 <$< | $(GREP) -q '\\" t$$'; \ + then \ + >&2 $(ECHO) "$<: spurious '\\\" t' not in first line:"; \ + >&2 $(GREP) -n '\\" t$$' $< /dev/null; \ + exit 1; \ + fi + touch $@ + + +.PHONY: lint-man-mandoc +lint-man-mandoc: $(_LINT_man_mandoc); +.PHONY: lint-man-tbl +lint-man-tbl: $(_LINT_man_tbl); + +.PHONY: lint-man +lint-man: $(lint_man); + + +endif # include guard diff --git a/share/mk/lint/man/mdoc.mk b/share/mk/lint/man/mdoc.mk new file mode 100644 index 0000000..9b5f5b4 --- /dev/null +++ b/share/mk/lint/man/mdoc.mk @@ -0,0 +1,44 @@ +######################################################################## +# Copyright 2023, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: GPL-3.0-or-later +######################################################################## + + +ifndef MAKEFILE_LINT_MAN_MDOC_INCLUDED +MAKEFILE_LINT_MAN_MDOC_INCLUDED := 1 + + +include $(MAKEFILEDIR)/cmd.mk +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/lint/_.mk +include $(MAKEFILEDIR)/lint/man/_.mk +include $(MAKEFILEDIR)/src.mk + + +mandoc_mdoc_ignore_grep := $(DATAROOTDIR)/lint/mandoc/mdoc.ignore.grep + +_LINT_mdoc_mandoc:=$(patsubst $(MANDIR)/%,$(_MANDIR)/%.lint-mdoc.mandoc.touch,$(NONSO_MDOC)) + + +linters_mdoc := mandoc +lint_mdoc := $(foreach x,$(linters_mdoc),lint-mdoc-$(x)) + + +$(_LINT_mdoc_mandoc): $(_MANDIR)/%.lint-mdoc.mandoc.touch: $(MANDIR)/% $(mandoc_mdoc_ignore_grep) | $$(@D)/ + $(info LINT (mandoc) $@) + ! ($(MANDOC) -mdoc $(MANDOCFLAGS) $< 2>&1 \ + | $(GREP) -v -f '$(mandoc_mdoc_ignore_grep)' \ + ||:; \ + ) \ + | $(GREP) ^ >&2 + touch $@ + + +.PHONY: $(lint_mdoc) +$(lint_mdoc): lint-mdoc-%: $$(_LINT_mdoc_%); + +.PHONY: lint-mdoc +lint-mdoc: $(lint_mdoc); + + +endif # include guard |