diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:41:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:41:07 +0000 |
commit | 3af6d22bb3850ab2bac67287e3a3d3b0e32868e5 (patch) | |
tree | 3ee7a3ec64525911fa865bb984c86d997d855527 /share | |
parent | Adding debian version 6.05.01-1. (diff) | |
download | manpages-3af6d22bb3850ab2bac67287e3a3d3b0e32868e5.tar.xz manpages-3af6d22bb3850ab2bac67287e3a3d3b0e32868e5.zip |
Merging upstream version 6.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share')
108 files changed, 2756 insertions, 1217 deletions
diff --git a/share/lint/mandoc/mdoc.ignore.grep b/share/lint/mandoc/mdoc.ignore.grep deleted file mode 100644 index 3fe2831..0000000 --- a/share/lint/mandoc/mdoc.ignore.grep +++ /dev/null @@ -1,5 +0,0 @@ -STYLE: legacy man(7) date format: Dd -STYLE: lower case character in document title: Dt -STYLE: operating system explicitly specified: Os -STYLE: referenced manual not found: Xr -WARNING: cross reference to self: Xr diff --git a/share/mk/build/_.mk b/share/mk/build/_.mk index bdce760..8ced940 100644 --- a/share/mk/build/_.mk +++ b/share/mk/build/_.mk @@ -1,52 +1,25 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception ifndef MAKEFILE_BUILD_INCLUDED MAKEFILE_BUILD_INCLUDED := 1 -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/src.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk -builddir := .tmp - -SYSCONFDIR := $(srcdir)/etc - _MANDIR := $(builddir)/man -MKDIR := mkdir -p -RM := rm - - -NONSO_MAN := $(shell $(FIND) $(MANDIR)/* -type f \ - | $(GREP) '$(MANEXT)' \ - | $(XARGS) $(GREP) -l '^\.TH ' \ - | $(SORT) \ - | $(SED) 's,:,\\:,g') -NONSO_MDOC := $(shell $(FIND) $(MANDIR)/* -type f \ - | $(GREP) '$(MANEXT)' \ - | $(XARGS) $(GREP) -l '^\.Dt ' \ - | $(SORT) \ - | $(SED) 's,:,\\:,g') - - -$(builddir)/%/: - +$(info MKDIR $@) - +$(MKDIR) $@ - - .PHONY: build -build: build-catman build-html build-pdf build-ps build-src; - -.PHONY: clean -clean: - $(info RM -rf $(builddir)) - $(RM) -rf $(builddir) +build: \ + build-book \ + build-catman \ + build-html \ + build-pdf \ + build-ps \ + build-ex; endif # include guard diff --git a/share/mk/build/book.mk b/share/mk/build/book.mk new file mode 100644 index 0000000..a941ced --- /dev/null +++ b/share/mk/build/book.mk @@ -0,0 +1,42 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_BOOK_INCLUDED +MAKEFILE_BUILD_BOOK_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/groff.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk +include $(MAKEFILEDIR)/configure/build-depends/moreutils.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/src.mk + + +LMBDIR := $(srcdir)/scripts/LinuxManBook +BUILDLMB := $(LMBDIR)/build.sh + + +_LMB := $(_MANDIR)/man-pages.pdf + + +$(_LMB): $(MANPAGES) $(wildcard $(LMBDIR)/* $(LMBDIR)/*/*) | $$(@D)/ + $(info $(INFO_)Build $@) + CAT='$(CAT)' \ + PRECONV='$(PRECONV)' \ + PIC='$(PIC)' \ + TBL='$(TBL)' \ + EQN='$(EQN)' \ + TROFF='$(TROFF)' \ + GROPDF='$(GROPDF)' \ + $(BUILDLMB) $(MANDIR) \ + | $(SPONGE) $@ + + +.PHONY: build-book +build-book: $(_LMB); + + +endif # include guard diff --git a/share/mk/build/catman.mk b/share/mk/build/catman.mk deleted file mode 100644 index 7b8766e..0000000 --- a/share/mk/build/catman.mk +++ /dev/null @@ -1,89 +0,0 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_BUILD_CATMAN_INCLUDED -MAKEFILE_BUILD_CATMAN_INCLUDED := 1 - - -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/build/groff.mk -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/src.mk - - -groff_man_ignore_grep := $(DATAROOTDIR)/lint/groff/man.ignore.grep - -MANWIDTH ?= 80 -TROFF_CHECKSTYLE_LVL := 3 -NROFF_LINE_LENGTH := $(shell $(EXPR) $(MANWIDTH) - 2) -NROFF_OUT_DEVICE := $(shell $(LOCALE) charmap \ - | $(GREP) -i 'utf-*8' >/dev/null \ - && $(ECHO) utf8 \ - || $(ECHO) ascii) - -DEFAULT_NROFFFLAGS := \ - -T$(NROFF_OUT_DEVICE) \ - -rLL=$(NROFF_LINE_LENGTH)n \ - -rCHECKSTYLE=$(TROFF_CHECKSTYLE_LVL) \ - -ww -EXTRA_NROFFFLAGS := -NROFFFLAGS := $(DEFAULT_NROFFFLAGS) $(EXTRA_NROFFFLAGS) - -DEFAULT_GROTTYFLAGS := -c -EXTRA_GROTTYFLAGS := -GROTTYFLAGS := $(DEFAULT_GROTTYFLAGS) $(EXTRA_GROTTYFLAGS) -GROTTY := grotty - - -_CATMAN_troff := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.troff,$(NONSO_MAN) $(NONSO_MDOC)) -_CATMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.set,$(NONSO_MAN)) -_CATMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.set,$(NONSO_MDOC)) -_CATMAN := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat,$(NONSO_MAN) $(NONSO_MDOC)) - - -$(_CATMAN_troff): %.cat.troff: %.eqn | $$(@D)/ - $(info EQN $@) - ! ($(EQN) -T$(NROFF_OUT_DEVICE) $(EQNFLAGS) <$< 2>&1 >$@) \ - | $(GREP) ^ >&2 - -$(_CATMAN_MAN_set): %.cat.set: %.cat.troff $(groff_man_ignore_grep) | $$(@D)/ - $(info TROFF $@) - ! ($(TROFF) $(TROFFFLAGS_MAN) $(NROFFFLAGS) <$< 2>&1 >$@ \ - | $(GREP) -v -f '$(groff_man_ignore_grep)' \ - ||:; \ - ) \ - | $(GREP) ^ >&2 - -$(_CATMAN_MDOC_set): %.cat.set: %.cat.troff | $$(@D)/ - $(info TROFF $@) - ! ($(TROFF) $(TROFFFLAGS_MDOC) $(NROFFFLAGS) <$< 2>&1 >$@) \ - | $(GREP) ^ >&2 - -$(_CATMAN): %.cat: %.cat.set | $$(@D)/ - $(info GROTTY $@) - $(GROTTY) $(GROTTYFLAGS) <$< >$@ - - -.PHONY: build-catman-eqn -build-catman-eqn: $(_CATMAN_troff); - -.PHONY: build-catman-troff-man -build-catman-troff-man: $(_CATMAN_MAN_set); - -.PHONY: build-catman-troff-mdoc -build-catman-troff-mdoc: $(_CATMAN_MDOC_set); - -.PHONY: build-catman-troff -build-catman-troff: build-catman-troff-man build-catman-troff-mdoc; - -.PHONY: build-catman-grotty -build-catman-grotty: $(_CATMAN); - -.PHONY: build-catman -build-catman: build-catman-grotty; - - -endif # include guard diff --git a/share/mk/build/catman/_.mk b/share/mk/build/catman/_.mk new file mode 100644 index 0000000..78aa862 --- /dev/null +++ b/share/mk/build/catman/_.mk @@ -0,0 +1,13 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_CATMAN_INCLUDED +MAKEFILE_BUILD_CATMAN_INCLUDED := 1 + + +.PHONY: build-catman +build-catman: build-catman-grotty; + + +endif # include guard diff --git a/share/mk/build/catman/eqn.mk b/share/mk/build/catman/eqn.mk new file mode 100644 index 0000000..48b6e75 --- /dev/null +++ b/share/mk/build/catman/eqn.mk @@ -0,0 +1,27 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_CATMAN_EQN_INCLUDED +MAKEFILE_BUILD_CATMAN_EQN_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/pre/tbl.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk + + +_CATMAN_troff := $(patsubst %.eqn,%.cat.troff,$(_MAN_eqn)) + + +$(_CATMAN_troff): %.cat.troff: %.eqn $(MK) | $$(@D)/ + $(info $(INFO_)EQN $@) + ! ($(EQN) -T$(NROFF_OUT_DEVICE) $(EQNFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + + +.PHONY: build-catman-eqn +build-catman-eqn: $(_CATMAN_troff); + + +endif # include guard diff --git a/share/mk/build/catman/grotty.mk b/share/mk/build/catman/grotty.mk new file mode 100644 index 0000000..7def414 --- /dev/null +++ b/share/mk/build/catman/grotty.mk @@ -0,0 +1,25 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_CATMAN_GROTTY_INCLUDED +MAKEFILE_BUILD_CATMAN_GROTTY_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/catman/troff.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk + + +_CATMAN := $(patsubst %.cat.set,%.cat,$(_CATMAN_MAN_set) $(_CATMAN_MDOC_set)) + + +$(_CATMAN): %.cat: %.cat.set $(MK) | $$(@D)/ + $(info $(INFO_)GROTTY $@) + $(GROTTY) $(GROTTYFLAGS) <$< >$@ + + +.PHONY: build-catman-grotty +build-catman-grotty: $(_CATMAN); + + +endif # include guard diff --git a/share/lint/groff/man.ignore.grep b/share/mk/build/catman/troff.ignore.grep index 912eb57..912eb57 100644 --- a/share/lint/groff/man.ignore.grep +++ b/share/mk/build/catman/troff.ignore.grep diff --git a/share/mk/build/catman/troff.mk b/share/mk/build/catman/troff.mk new file mode 100644 index 0000000..c38ba17 --- /dev/null +++ b/share/mk/build/catman/troff.mk @@ -0,0 +1,85 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_CATMAN_TROFF_INCLUDED +MAKEFILE_BUILD_CATMAN_TROFF_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/configure/xfail.mk +include $(MAKEFILEDIR)/src.mk + + +_XFAIL_CATMAN_MAN_set := \ + $(_MANDIR)/man2/fanotify_init.2.cat.set \ + $(_MANDIR)/man3/unlocked_stdio.3.cat.set \ + $(_MANDIR)/man4/console_codes.4.cat.set \ + $(_MANDIR)/man4/lirc.4.cat.set \ + $(_MANDIR)/man5/proc_pid_smaps.5.cat.set \ + $(_MANDIR)/man5/tzfile.5.cat.set \ + $(_MANDIR)/man7/ascii.7.cat.set \ + $(_MANDIR)/man7/bpf-helpers.7.cat.set \ + $(_MANDIR)/man7/charsets.7.cat.set \ + $(_MANDIR)/man7/iso_8859-1.7.cat.set \ + $(_MANDIR)/man7/iso_8859-2.7.cat.set \ + $(_MANDIR)/man7/iso_8859-3.7.cat.set \ + $(_MANDIR)/man7/iso_8859-4.7.cat.set \ + $(_MANDIR)/man7/iso_8859-5.7.cat.set \ + $(_MANDIR)/man7/iso_8859-6.7.cat.set \ + $(_MANDIR)/man7/iso_8859-7.7.cat.set \ + $(_MANDIR)/man7/iso_8859-8.7.cat.set \ + $(_MANDIR)/man7/iso_8859-9.7.cat.set \ + $(_MANDIR)/man7/iso_8859-10.7.cat.set \ + $(_MANDIR)/man7/iso_8859-11.7.cat.set \ + $(_MANDIR)/man7/iso_8859-13.7.cat.set \ + $(_MANDIR)/man7/iso_8859-14.7.cat.set \ + $(_MANDIR)/man7/iso_8859-15.7.cat.set \ + $(_MANDIR)/man7/iso_8859-16.7.cat.set \ + $(_MANDIR)/man8/tzselect.8.cat.set \ + $(_MANDIR)/man8/zdump.8.cat.set \ + $(_MANDIR)/man8/zic.8.cat.set + + + +troff_man_ignore_grep := $(MAKEFILEDIR)/build/catman/troff.ignore.grep + + +_CATMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.set,$(NONSO_MAN)) +_CATMAN_MDOC_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.set,$(NONSO_MDOC)) + + +ifeq ($(SKIP_XFAIL),yes) +_CATMAN_MAN_set := $(filter-out $(_XFAIL_CATMAN_MAN_set), $(_CATMAN_MAN_set)) +endif + + +$(_CATMAN_MAN_set): %.cat.set: %.cat.troff $(troff_man_ignore_grep) $(MK) | $$(@D)/ + $(info $(INFO_)TROFF $@) + ! ($(TROFF) -man $(TROFFFLAGS) $(NROFFFLAGS) <$< 2>&1 >$@ \ + | $(GREP) -v -f '$(troff_man_ignore_grep)' \ + || $(TRUE); \ + ) \ + | $(GREP) ^ >&2 + +$(_CATMAN_MDOC_set): %.cat.set: %.cat.troff $(MK) | $$(@D)/ + $(info $(INFO_)TROFF $@) + ! ($(TROFF) -mdoc $(TROFFFLAGS) $(NROFFFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + + +.PHONY: build-catman-troff-man +build-catman-troff-man: $(_CATMAN_MAN_set); + +.PHONY: build-catman-troff-mdoc +build-catman-troff-mdoc: $(_CATMAN_MDOC_set); + +.PHONY: build-catman-troff +build-catman-troff: build-catman-troff-man build-catman-troff-mdoc; + + +endif # include guard diff --git a/share/mk/build/examples/_.mk b/share/mk/build/examples/_.mk new file mode 100644 index 0000000..c01a952 --- /dev/null +++ b/share/mk/build/examples/_.mk @@ -0,0 +1,28 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_EX_DIR_INCLUDED +MAKEFILE_BUILD_EX_DIR_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/src.mk + + +_PAGEEXDIRS := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.d/,$(NONSO_MAN)) + + +$(_PAGEEXDIRS): + +$(info $(INFO_)MKDIR $@) + +$(MKDIR) -p $@ + +$(TOUCH) $@ + + +.PHONY: build-ex +build-ex: build-ex-ld; + + +endif # include guard diff --git a/share/mk/build/examples/cc.mk b/share/mk/build/examples/cc.mk new file mode 100644 index 0000000..6513fbe --- /dev/null +++ b/share/mk/build/examples/cc.mk @@ -0,0 +1,54 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_EX_CC_INCLUDED +MAKEFILE_BUILD_EX_CC_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/cc.mk +include $(MAKEFILEDIR)/configure/build-depends/cpp.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_UNITS_ex_o := \ + $(_MANDIR)/man2/bpf.2.d/bpf.o \ + $(_MANDIR)/man2/seccomp.2.d/seccomp.o \ + $(_MANDIR)/man2/sigaction.2.d/sigaction.o \ + $(_MANDIR)/man2/spu_run.2.d/spu_run.o \ + $(_MANDIR)/man2/_syscall.2.d/_syscall.o \ + $(_MANDIR)/man3/circleq.3.d/circleq.o \ + $(_MANDIR)/man3/encrypt.3.d/encrypt.o \ + $(_MANDIR)/man3/getsubopt.3.d/getsubopt.o \ + $(_MANDIR)/man3/hsearch.3.d/hsearch.o \ + $(_MANDIR)/man3/malloc_info.3.d/malloc_info.o \ + $(_MANDIR)/man3/mallopt.3.d/mallopt.o \ + $(_MANDIR)/man3/matherr.3.d/matherr.o \ + $(_MANDIR)/man3/mcheck.3.d/mcheck.o \ + $(_MANDIR)/man3/mtrace.3.d/t_mtrace.o \ + $(_MANDIR)/man3/__ppc_get_timebase.3.d/__ppc_get_timebase.o \ + $(_MANDIR)/man3/pthread_getcpuclockid.3.d/pthread_getcpuclockid.o \ + $(_MANDIR)/man3/rtime.3.d/rtime.o \ + $(_MANDIR)/man3/setbuf.3.d/setbuf.o \ + $(_MANDIR)/man3/stpncpy.3.d/stpncpy.o \ + $(_MANDIR)/man3head/printf.h.3head.d/register_printf_specifier.o + + +_UNITS_ex_o := $(patsubst %.c,%.o,$(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_UNITS_ex_o := $(filter-out $(_XFAIL_UNITS_ex_o), $(_UNITS_ex_o)) +endif + + +$(_UNITS_ex_o): %.o: %.c $(MK) + $(info $(INFO_)CC $@) + $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< + + +.PHONY: build-ex-cc +build-ex-cc: $(_UNITS_ex_o); + + +endif # include guard diff --git a/share/mk/build/examples/ld.mk b/share/mk/build/examples/ld.mk new file mode 100644 index 0000000..9d5535d --- /dev/null +++ b/share/mk/build/examples/ld.mk @@ -0,0 +1,51 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_EX_LD_INCLUDED +MAKEFILE_BUILD_EX_LD_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/cc.mk +include $(MAKEFILEDIR)/configure/build-depends/ld.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_UNITS_ex_bin := \ + $(_MANDIR)/man2/add_key.2.d/add_key \ + $(_MANDIR)/man2/keyctl.2.d/key_instantiate \ + $(_MANDIR)/man2/request_key.2.d/t_request_key \ + $(_MANDIR)/man2/select_tut.2.d/select \ + $(_MANDIR)/man2/shmop.2.d/svshm_string_read \ + $(_MANDIR)/man3/cacos.3.d/cacos \ + $(_MANDIR)/man3/cacosh.3.d/cacosh \ + $(_MANDIR)/man3/catan.3.d/catan \ + $(_MANDIR)/man3/catanh.3.d/catanh \ + $(_MANDIR)/man3/getaddrinfo_a.3.d/async \ + $(_MANDIR)/man3/inet_net_pton.3.d/inet_net_pton \ + $(_MANDIR)/man3/list.3.d/list \ + $(_MANDIR)/man3/mallinfo.3.d/mallinfo \ + $(_MANDIR)/man3/slist.3.d/slist \ + $(_MANDIR)/man3/stailq.3.d/stailq \ + $(_MANDIR)/man3/strncat.3.d/strncat \ + $(_MANDIR)/man3/tailq.3.d/tailq \ + $(_MANDIR)/man3/tsearch.3.d/tsearch + + +_UNITS_ex_bin := $(patsubst %.o,%,$(_UNITS_ex_o)) +ifeq ($(SKIP_XFAIL),yes) +_UNITS_ex_bin := $(filter-out $(_XFAIL_UNITS_ex_bin), $(_UNITS_ex_bin)) +endif + + +$(_UNITS_ex_bin): %: %.o $(MK) + $(info $(INFO_)LD $@) + $(LD) $(LDFLAGS) -o $@ $< $(LDLIBS) + + +.PHONY: build-ex-ld +build-ex-ld: $(_UNITS_ex_bin); + + +endif # include guard diff --git a/share/mk/build/examples/src.mk b/share/mk/build/examples/src.mk new file mode 100644 index 0000000..f47a713 --- /dev/null +++ b/share/mk/build/examples/src.mk @@ -0,0 +1,55 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_EX_SRC_INCLUDED +MAKEFILE_BUILD_EX_SRC_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/findutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/mandoc.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk +include $(MAKEFILEDIR)/src.mk + + +_UNITS_ex_src := \ + $(patsubst $(MANDIR)/%, $(_MANDIR)/%, \ + $(shell \ + $(FIND) $(MANDIR)/* -type f \ + | $(GREP) '$(MANEXT)' \ + | $(XARGS) $(GREP) -H '^\.\\" SRC BEGIN ' \ + | $(SED) 's,:\.\\" SRC BEGIN (,.d/,' \ + | $(SED) 's/)//' \ + | $(SORTMAN) \ + | $(SED) 's,:,\\:,g' \ + ) \ + ) +_UNITS_ex_h := $(filter %.h,$(_UNITS_ex_src)) +_UNITS_ex_c := $(filter %.c,$(_UNITS_ex_src)) + + +$(_UNITS_ex_src): $$(patsubst $(_MANDIR)/%.d,$(MANDIR)/%,$$(@D)) $(MK) | $$(@D)/ +$(_UNITS_ex_c): $$(filter $$(@D)/%.h,$(_UNITS_ex_h)) +$(_UNITS_ex_src): + $(info $(INFO_)SED $@) + <$< \ + $(SED) -n \ + -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \ + -e '/^\.SH EXAMPLES/p' \ + -e "/^\... SRC BEGIN ($(@F))$$/,/^\... SRC END$$/p" \ + | $(MANDOC) -Tutf8 \ + | $(HEAD) -n-2 \ + | $(SED) '/^[^ ]/d' \ + | $(SED) 's/^ //' \ + >$@ + + +.PHONY: build-ex-src +build-ex-src: $(_UNITS_ex_src); + + +endif # include guard diff --git a/share/mk/build/groff.mk b/share/mk/build/groff.mk deleted file mode 100644 index 2a5a3de..0000000 --- a/share/mk/build/groff.mk +++ /dev/null @@ -1,39 +0,0 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_BUILD_GROFF_INCLUDED -MAKEFILE_BUILD_GROFF_INCLUDED := 1 - - -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/src.mk - - -DEFAULT_EQNFLAGS := -EXTRA_EQNFLAGS := -EQNFLAGS := $(DEFAULT_EQNFLAGS) $(EXTRA_EQNFLAGS) -EQN := eqn - -DEFAULT_TROFFFLAGS := -wbreak -EXTRA_TROFFFLAGS := -TROFFFLAGS := $(DEFAULT_TROFFFLAGS) $(EXTRA_TROFFFLAGS) -TROFF := troff - -DEFAULT_TROFFFLAGS_MAN := \ - $(TROFFFLAGS) \ - -man -EXTRA_TROFFFLAGS_MAN := -TROFFFLAGS_MAN := $(DEFAULT_TROFFFLAGS_MAN) $(EXTRA_TROFFFLAGS_MAN) - -DEFAULT_TROFFFLAGS_MDOC := \ - $(TROFFFLAGS) \ - -mdoc -EXTRA_TROFFFLAGS_MDOC := -TROFFFLAGS_MDOC := $(DEFAULT_TROFFFLAGS_MDOC) $(EXTRA_TROFFFLAGS_MDOC) - - -endif # include guard diff --git a/share/mk/build/html.mk b/share/mk/build/html.mk deleted file mode 100644 index 084654d..0000000 --- a/share/mk/build/html.mk +++ /dev/null @@ -1,42 +0,0 @@ -######################################################################## -# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_BUILD_HTML_INCLUDED -MAKEFILE_BUILD_HTML_INCLUDED := 1 - - -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/src.mk - - -htmlext := .html -_HTMLDIR := $(builddir)/html - - -DEFAULT_MAN2HTMLFLAGS := -EXTRA_MAN2HTMLFLAGS := -MAN2HTMLFLAGS := $(DEFAULT_MAN2HTMLFLAGS) $(EXTRA_MAN2HTMLFLAGS) -MAN2HTML := man2html - - -_HTMLPAGES := $(patsubst $(MANDIR)/%,$(_HTMLDIR)/%$(htmlext),$(MANPAGES)) - - -# Use with -# make MAN2HTMLFLAGS=whatever html -# The sed removes the lines "Content-type: text/html\n\n" -$(_HTMLPAGES): $(_HTMLDIR)/%$(htmlext): $(MANDIR)/% | $$(@D)/ - $(info MAN2HTML $@) - $(MAN2HTML) $(MAN2HTMLFLAGS) $< \ - | $(SED) -e 1,2d >$@ - - -.PHONY: build-html html -build-html html: $(_HTMLPAGES); - - -endif # include guard diff --git a/share/mk/build/html/_.mk b/share/mk/build/html/_.mk new file mode 100644 index 0000000..b3e3041 --- /dev/null +++ b/share/mk/build/html/_.mk @@ -0,0 +1,13 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_HTML_INCLUDED +MAKEFILE_BUILD_HTML_INCLUDED := 1 + + +.PHONY: build-html +build-html: build-html-post-grohtml; + + +endif # include guard diff --git a/share/mk/build/html/post-grohtml.mk b/share/mk/build/html/post-grohtml.mk new file mode 100644 index 0000000..fe77776 --- /dev/null +++ b/share/mk/build/html/post-grohtml.mk @@ -0,0 +1,25 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_HTML_POST_GROHTML_INCLUDED +MAKEFILE_BUILD_HTML_POST_GROHTML_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/html/troff.mk +include $(MAKEFILEDIR)/configure/build-depends/groff.mk + + +_HTMLMAN := $(patsubst %.html.set,%.html,$(_HTMLMAN_MAN_set) $(_HTMLMAN_MDOC_set)) + + +$(_HTMLMAN): %.html: %.html.set $(MK) | $$(@D)/ + $(info $(INFO_)POST_GROHTML $@) + $(POST_GROHTML) $(POST_GROHTMLFLAGS) <$< >$@ + + +.PHONY: build-html-post-grohtml +build-html-post-grohtml: $(_HTMLMAN); + + +endif # include guard diff --git a/share/mk/build/html/troff.mk b/share/mk/build/html/troff.mk new file mode 100644 index 0000000..010c211 --- /dev/null +++ b/share/mk/build/html/troff.mk @@ -0,0 +1,58 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_HTML_TROFF_INCLUDED +MAKEFILE_BUILD_HTML_TROFF_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/configure/xfail.mk +include $(MAKEFILEDIR)/src.mk + + +_XFAIL_HTMLMAN_MAN_set := \ + $(_MANDIR)/man2/fanotify_init.2.html.set \ + $(_MANDIR)/man2/membarrier.2.html.set \ + $(_MANDIR)/man5/proc.5.html.set \ + $(_MANDIR)/man7/bpf-helpers.7.html.set \ + $(_MANDIR)/man7/charsets.7.html.set \ + $(_MANDIR)/man7/iso_8859-16.7.html.set \ + $(_MANDIR)/man7/iso_8859-6.7.html.set \ + $(_MANDIR)/man8/zic.8.html.set + + +_HTMLMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.html.set,$(NONSO_MAN)) +_HTMLMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.html.set,$(NONSO_MDOC)) + + +ifeq ($(SKIP_XFAIL),yes) +_HTMLMAN_MAN_set := $(filter-out $(_XFAIL_HTMLMAN_MAN_set), $(_HTMLMAN_MAN_set)) +endif + + +$(_HTMLMAN_MAN_set): %.html.set: %.eqn $(MK) | $$(@D)/ + $(info $(INFO_)TROFF $@) + ! ($(TROFF) -man -Thtml $(TROFFFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + +$(_HTMLMAN_MDOC_set): %.html.set: %.eqn $(MK) | $$(@D)/ + $(info $(INFO_)TROFF $@) + ! ($(TROFF) -mdoc -Thtml $(TROFFFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + + +.PHONY: build-html-troff-man +build-html-troff-man: $(_HTMLMAN_MAN_set); + +.PHONY: build-html-troff-mdoc +build-html-troff-mdoc: $(_HTMLMAN_MDOC_set); + +.PHONY: build-html-troff +build-html-troff: build-html-troff-man build-html-troff-mdoc; + + +endif # include guard diff --git a/share/mk/build/pdf.mk b/share/mk/build/pdf.mk deleted file mode 100644 index 380c6c6..0000000 --- a/share/mk/build/pdf.mk +++ /dev/null @@ -1,68 +0,0 @@ -######################################################################## -# Copyright 2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_BUILD_PDF_INCLUDED -MAKEFILE_BUILD_PDF_INCLUDED := 1 - - -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/build/groff.mk -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/src.mk - - -DEFAULT_GROPDFFLAGS := -EXTRA_GROPDFFLAGS := -GROPDFFLAGS := $(DEFAULT_GROPDFFLAGS) $(EXTRA_GROPDFFLAGS) -GROPDF := gropdf - - -_PDFMAN_troff := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.troff,$(NONSO_MAN) $(NONSO_MDOC)) -_PDFMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.set,$(NONSO_MAN)) -_PDFMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.set,$(NONSO_MDOC)) -_PDFMAN := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf,$(NONSO_MAN) $(NONSO_MDOC)) - - -$(_PDFMAN_troff): %.pdf.troff: %.eqn | $$(@D)/ - $(info EQN $@) - ! ($(EQN) -Tpdf $(EQNFLAGS) <$< 2>&1 >$@) \ - | $(GREP) ^ >&2 - -$(_PDFMAN_MAN_set): %.pdf.set: %.pdf.troff | $$(@D)/ - $(info TROFF $@) - ! ($(TROFF) -Tpdf $(TROFFFLAGS_MAN) <$< 2>&1 >$@) \ - | $(GREP) ^ >&2 - -$(_PDFMAN_MDOC_set): %.pdf.set: %.pdf.troff | $$(@D)/ - $(info TROFF $@) - ! ($(TROFF) -Tpdf $(TROFFFLAGS_MDOC) <$< 2>&1 >$@) \ - | $(GREP) ^ >&2 - -$(_PDFMAN): %.pdf: %.pdf.set | $$(@D)/ - $(info GROPDF $@) - $(GROPDF) $(GROPDFFLAGS) <$< >$@ - - -.PHONY: build-pdf-eqn -build-pdf-eqn: $(_PDFMAN_troff); - -.PHONY: build-pdf-troff-man -build-pdf-troff-man: $(_PDFMAN_MAN_set); - -.PHONY: build-pdf-troff-mdoc -build-pdf-troff-mdoc: $(_PDFMAN_MDOC_set); - -.PHONY: build-pdf-troff -build-pdf-troff: build-pdf-troff-man build-pdf-troff-mdoc; - -.PHONY: build-pdf-gropdf -build-pdf-gropdf: $(_PDFMAN); - -.PHONY: build-pdf -build-pdf: build-pdf-gropdf; - - -endif # include guard diff --git a/share/mk/build/pdf/_.mk b/share/mk/build/pdf/_.mk new file mode 100644 index 0000000..f6660aa --- /dev/null +++ b/share/mk/build/pdf/_.mk @@ -0,0 +1,13 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PDF_INCLUDED +MAKEFILE_BUILD_PDF_INCLUDED := 1 + + +.PHONY: build-pdf +build-pdf: build-pdf-gropdf; + + +endif # include guard diff --git a/share/mk/build/pdf/eqn.mk b/share/mk/build/pdf/eqn.mk new file mode 100644 index 0000000..bb0598b --- /dev/null +++ b/share/mk/build/pdf/eqn.mk @@ -0,0 +1,27 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PDF_EQN_INCLUDED +MAKEFILE_BUILD_PDF_EQN_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/pre/tbl.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk + + +_PDFMAN_troff := $(patsubst %.eqn,%.pdf.troff,$(_MAN_eqn)) + + +$(_PDFMAN_troff): %.pdf.troff: %.eqn $(MK) | $$(@D)/ + $(info $(INFO_)EQN $@) + ! ($(EQN) -Tpdf $(EQNFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + + +.PHONY: build-pdf-eqn +build-pdf-eqn: $(_PDFMAN_troff); + + +endif # include guard diff --git a/share/mk/build/pdf/gropdf.mk b/share/mk/build/pdf/gropdf.mk new file mode 100644 index 0000000..0913122 --- /dev/null +++ b/share/mk/build/pdf/gropdf.mk @@ -0,0 +1,25 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PDF_GROPDF_INCLUDED +MAKEFILE_BUILD_PDF_GROPDF_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/pdf/troff.mk +include $(MAKEFILEDIR)/configure/build-depends/groff.mk + + +_PDFMAN := $(patsubst %.pdf.set,%.pdf,$(_PDFMAN_MAN_set) $(_PDFMAN_MDOC_set)) + + +$(_PDFMAN): %.pdf: %.pdf.set $(MK) | $$(@D)/ + $(info $(INFO_)GROPDF $@) + $(GROPDF) $(GROPDFFLAGS) <$< >$@ + + +.PHONY: build-pdf-gropdf +build-pdf-gropdf: $(_PDFMAN); + + +endif # include guard diff --git a/share/mk/build/pdf/troff.mk b/share/mk/build/pdf/troff.mk new file mode 100644 index 0000000..5254d5d --- /dev/null +++ b/share/mk/build/pdf/troff.mk @@ -0,0 +1,75 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PDF_TROFF_INCLUDED +MAKEFILE_BUILD_PDF_TROFF_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/configure/xfail.mk +include $(MAKEFILEDIR)/src.mk + + +_XFAIL_PDFMAN_MAN_set := \ + $(_MANDIR)/man1/iconv.1.pdf.set \ + $(_MANDIR)/man2/fanotify_init.2.pdf.set \ + $(_MANDIR)/man2/syscall.2.pdf.set \ + $(_MANDIR)/man3/newlocale.3.pdf.set \ + $(_MANDIR)/man7/address_families.7.pdf.set \ + $(_MANDIR)/man7/armscii-8.7.pdf.set \ + $(_MANDIR)/man7/ascii.7.pdf.set \ + $(_MANDIR)/man7/bpf-helpers.7.pdf.set \ + $(_MANDIR)/man7/charsets.7.pdf.set \ + $(_MANDIR)/man7/cp1251.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-2.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-3.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-4.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-5.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-6.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-7.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-8.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-10.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-11.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-13.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-14.7.pdf.set \ + $(_MANDIR)/man7/iso_8859-16.7.pdf.set \ + $(_MANDIR)/man7/koi8-r.7.pdf.set \ + $(_MANDIR)/man7/koi8-u.7.pdf.set \ + $(_MANDIR)/man7/vdso.7.pdf.set + + +_PDFMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.set,$(NONSO_MAN)) +_PDFMAN_MDOC_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.pdf.set,$(NONSO_MDOC)) + + +ifeq ($(SKIP_XFAIL),yes) +_PDFMAN_MAN_set := $(filter-out $(_XFAIL_PDFMAN_MAN_set), $(_PDFMAN_MAN_set)) +endif + + +$(_PDFMAN_MAN_set): %.pdf.set: %.pdf.troff $(MK) | $$(@D)/ + $(info $(INFO_)TROFF $@) + ! ($(TROFF) -man -Tpdf $(TROFFFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + +$(_PDFMAN_MDOC_set): %.pdf.set: %.pdf.troff $(MK) | $$(@D)/ + $(info $(INFO_)TROFF $@) + ! ($(TROFF) -mdoc -Tpdf $(TROFFFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + + +.PHONY: build-pdf-troff-man +build-pdf-troff-man: $(_PDFMAN_MAN_set); + +.PHONY: build-pdf-troff-mdoc +build-pdf-troff-mdoc: $(_PDFMAN_MDOC_set); + +.PHONY: build-pdf-troff +build-pdf-troff: build-pdf-troff-man build-pdf-troff-mdoc; + + +endif # include guard diff --git a/share/mk/build/pre.mk b/share/mk/build/pre.mk deleted file mode 100644 index 4c458fa..0000000 --- a/share/mk/build/pre.mk +++ /dev/null @@ -1,47 +0,0 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_BUILD_PRE_INCLUDED -MAKEFILE_BUILD_PRE_INCLUDED := 1 - - -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/src.mk - - -DEFAULT_PRECONVFLAGS := -EXTRA_PRECONVFLAGS := -PRECONVFLAGS := $(DEFAULT_PRECONVFLAGS) $(EXTRA_PRECONVFLAGS) -PRECONV := preconv - -TBL := tbl - - -_MAN_tbl := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.tbl,$(NONSO_MAN) $(NONSO_MDOC)) -_MAN_eqn := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.eqn,$(NONSO_MAN) $(NONSO_MDOC)) - - -$(_MAN_tbl): $(_MANDIR)/%.tbl: $(MANDIR)/% | $$(@D)/ - $(info PRECONV $@) - $(PRECONV) $(PRECONVFLAGS) $< >$@ - -$(_MAN_eqn): %.eqn: %.tbl | $$(@D)/ - $(info TBL $@) - $(TBL) <$< >$@ - - -.PHONY: build-pre-preconv -build-pre-preconv: $(_MAN_tbl); - -.PHONY: build-pre-tbl -build-pre-tbl: $(_MAN_eqn); - -.PHONY: build-pre -build-pre: build-pre-tbl; - - -endif # include guard diff --git a/share/mk/build/pre/_.mk b/share/mk/build/pre/_.mk new file mode 100644 index 0000000..f0e86f4 --- /dev/null +++ b/share/mk/build/pre/_.mk @@ -0,0 +1,13 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PRE_INCLUDED +MAKEFILE_BUILD_PRE_INCLUDED := 1 + + +.PHONY: build-pre +build-pre: build-pre-tbl; + + +endif # include guard diff --git a/share/mk/build/pre/preconv.mk b/share/mk/build/pre/preconv.mk new file mode 100644 index 0000000..73aa1da --- /dev/null +++ b/share/mk/build/pre/preconv.mk @@ -0,0 +1,27 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PRE_PRECONV_INCLUDED +MAKEFILE_BUILD_PRE_PRECONV_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/src.mk + + +_MAN_tbl := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.tbl,$(NONSO_MAN) $(NONSO_MDOC)) + + +$(_MAN_tbl): $(_MANDIR)/%.tbl: $(MANDIR)/% $(MK) | $$(@D)/ + $(info $(INFO_)PRECONV $@) + $(PRECONV) $(PRECONVFLAGS) $< >$@ + + +.PHONY: build-pre-preconv +build-pre-preconv: $(_MAN_tbl); + + +endif # include guard diff --git a/share/mk/build/pre/tbl.mk b/share/mk/build/pre/tbl.mk new file mode 100644 index 0000000..24486f8 --- /dev/null +++ b/share/mk/build/pre/tbl.mk @@ -0,0 +1,25 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PRE_TBL_INCLUDED +MAKEFILE_BUILD_PRE_TBL_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/pre/preconv.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk + + +_MAN_eqn := $(patsubst %.tbl,%.eqn,$(_MAN_tbl)) + + +$(_MAN_eqn): %.eqn: %.tbl $(MK) | $$(@D)/ + $(info $(INFO_)TBL $@) + $(TBL) <$< >$@ + + +.PHONY: build-pre-tbl +build-pre-tbl: $(_MAN_eqn); + + +endif # include guard diff --git a/share/mk/build/ps.mk b/share/mk/build/ps.mk deleted file mode 100644 index 5b29dc1..0000000 --- a/share/mk/build/ps.mk +++ /dev/null @@ -1,68 +0,0 @@ -######################################################################## -# Copyright 2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_BUILD_PS_INCLUDED -MAKEFILE_BUILD_PS_INCLUDED := 1 - - -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/build/groff.mk -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/src.mk - - -DEFAULT_GROPSFLAGS := -EXTRA_GROPSFLAGS := -GROPSFLAGS := $(DEFAULT_GROPSFLAGS) $(EXTRA_GROPSFLAGS) -GROPS := grops - - -_PSMAN_troff := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.troff,$(NONSO_MAN) $(NONSO_MDOC)) -_PSMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.set,$(NONSO_MAN)) -_PSMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.set,$(NONSO_MDOC)) -_PSMAN := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps,$(NONSO_MAN) $(NONSO_MDOC)) - - -$(_PSMAN_troff): %.ps.troff: %.eqn | $$(@D)/ - $(info EQN $@) - ! ($(EQN) -Tps $(EQNFLAGS) <$< 2>&1 >$@) \ - | $(GREP) ^ >&2 - -$(_PSMAN_MAN_set): %.ps.set: %.ps.troff | $$(@D)/ - $(info TROFF $@) - ! ($(TROFF) -Tps $(TROFFFLAGS_MAN) <$< 2>&1 >$@) \ - | $(GREP) ^ >&2 - -$(_PSMAN_MDOC_set): %.ps.set: %.ps.troff | $$(@D)/ - $(info TROFF $@) - ! ($(TROFF) -Tps $(TROFFFLAGS_MDOC) <$< 2>&1 >$@) \ - | $(GREP) ^ >&2 - -$(_PSMAN): %.ps: %.ps.set | $$(@D)/ - $(info GROPS $@) - $(GROPS) $(GROPSFLAGS) <$< >$@ - - -.PHONY: build-ps-eqn -build-ps-eqn: $(_PSMAN_troff); - -.PHONY: build-ps-troff-man -build-ps-troff-man: $(_PSMAN_MAN_set); - -.PHONY: build-ps-troff-mdoc -build-ps-troff-mdoc: $(_PSMAN_MDOC_set); - -.PHONY: build-ps-troff -build-ps-troff: build-ps-troff-man build-ps-troff-mdoc; - -.PHONY: build-ps-grops -build-ps-grops: $(_PSMAN); - -.PHONY: build-ps -build-ps: build-ps-grops; - - -endif # include guard diff --git a/share/mk/build/ps/_.mk b/share/mk/build/ps/_.mk new file mode 100644 index 0000000..b92ebfc --- /dev/null +++ b/share/mk/build/ps/_.mk @@ -0,0 +1,13 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PS_INCLUDED +MAKEFILE_BUILD_PS_INCLUDED := 1 + + +.PHONY: build-ps +build-ps: build-ps-grops; + + +endif # include guard diff --git a/share/mk/build/ps/eqn.mk b/share/mk/build/ps/eqn.mk new file mode 100644 index 0000000..a4c921e --- /dev/null +++ b/share/mk/build/ps/eqn.mk @@ -0,0 +1,27 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PS_EQN_INCLUDED +MAKEFILE_BUILD_PS_EQN_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/pre/tbl.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk + + +_PSMAN_troff := $(patsubst %.eqn,%.ps.troff,$(_MAN_eqn)) + + +$(_PSMAN_troff): %.ps.troff: %.eqn $(MK) | $$(@D)/ + $(info $(INFO_)EQN $@) + ! ($(EQN) -Tps $(EQNFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + + +.PHONY: build-ps-eqn +build-ps-eqn: $(_PSMAN_troff); + + +endif # include guard diff --git a/share/mk/build/ps/grops.mk b/share/mk/build/ps/grops.mk new file mode 100644 index 0000000..cca9b44 --- /dev/null +++ b/share/mk/build/ps/grops.mk @@ -0,0 +1,25 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PS_GROPS_INCLUDED +MAKEFILE_BUILD_PS_GROPS_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/ps/troff.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk + + +_PSMAN := $(patsubst %.ps.set,%.ps,$(_PSMAN_MAN_set) $(_PSMAN_MDOC_set)) + + +$(_PSMAN): %.ps: %.ps.set $(MK) | $$(@D)/ + $(info $(INFO_)GROPS $@) + $(GROPS) $(GROPSFLAGS) <$< >$@ + + +.PHONY: build-ps-grops +build-ps-grops: $(_PSMAN); + + +endif # include guard diff --git a/share/mk/build/ps/troff.mk b/share/mk/build/ps/troff.mk new file mode 100644 index 0000000..1492821 --- /dev/null +++ b/share/mk/build/ps/troff.mk @@ -0,0 +1,75 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_BUILD_PS_TROFF_INCLUDED +MAKEFILE_BUILD_PS_TROFF_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/groff-base.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/configure/xfail.mk +include $(MAKEFILEDIR)/src.mk + + +_XFAIL_PSMAN_MAN_set := \ + $(_MANDIR)/man1/iconv.1.ps.set \ + $(_MANDIR)/man2/fanotify_init.2.ps.set \ + $(_MANDIR)/man2/syscall.2.ps.set \ + $(_MANDIR)/man3/newlocale.3.ps.set \ + $(_MANDIR)/man7/address_families.7.ps.set \ + $(_MANDIR)/man7/armscii-8.7.ps.set \ + $(_MANDIR)/man7/ascii.7.ps.set \ + $(_MANDIR)/man7/bpf-helpers.7.ps.set \ + $(_MANDIR)/man7/charsets.7.ps.set \ + $(_MANDIR)/man7/cp1251.7.ps.set \ + $(_MANDIR)/man7/iso_8859-2.7.ps.set \ + $(_MANDIR)/man7/iso_8859-3.7.ps.set \ + $(_MANDIR)/man7/iso_8859-4.7.ps.set \ + $(_MANDIR)/man7/iso_8859-5.7.ps.set \ + $(_MANDIR)/man7/iso_8859-6.7.ps.set \ + $(_MANDIR)/man7/iso_8859-7.7.ps.set \ + $(_MANDIR)/man7/iso_8859-8.7.ps.set \ + $(_MANDIR)/man7/iso_8859-10.7.ps.set \ + $(_MANDIR)/man7/iso_8859-11.7.ps.set \ + $(_MANDIR)/man7/iso_8859-13.7.ps.set \ + $(_MANDIR)/man7/iso_8859-14.7.ps.set \ + $(_MANDIR)/man7/iso_8859-16.7.ps.set \ + $(_MANDIR)/man7/koi8-r.7.ps.set \ + $(_MANDIR)/man7/koi8-u.7.ps.set \ + $(_MANDIR)/man7/vdso.7.ps.set + + +_PSMAN_MAN_set := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.set,$(NONSO_MAN)) +_PSMAN_MDOC_set:= $(patsubst $(MANDIR)/%,$(_MANDIR)/%.ps.set,$(NONSO_MDOC)) + + +ifeq ($(SKIP_XFAIL),yes) +_PSMAN_MAN_set := $(filter-out $(_XFAIL_PSMAN_MAN_set), $(_PSMAN_MAN_set)) +endif + + +$(_PSMAN_MAN_set): %.ps.set: %.ps.troff $(MK) | $$(@D)/ + $(info $(INFO_)TROFF $@) + ! ($(TROFF) -man -Tps $(TROFFFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + +$(_PSMAN_MDOC_set): %.ps.set: %.ps.troff $(MK) | $$(@D)/ + $(info $(INFO_)TROFF $@) + ! ($(TROFF) -mdoc -Tps $(TROFFFLAGS) <$< 2>&1 >$@) \ + | $(GREP) ^ >&2 + + +.PHONY: build-ps-troff-man +build-ps-troff-man: $(_PSMAN_MAN_set); + +.PHONY: build-ps-troff-mdoc +build-ps-troff-mdoc: $(_PSMAN_MDOC_set); + +.PHONY: build-ps-troff +build-ps-troff: build-ps-troff-man build-ps-troff-mdoc; + + +endif # include guard diff --git a/share/mk/build/src.mk b/share/mk/build/src.mk deleted file mode 100644 index 365c256..0000000 --- a/share/mk/build/src.mk +++ /dev/null @@ -1,117 +0,0 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_BUILD_SRC_INCLUDED -MAKEFILE_BUILD_SRC_INCLUDED := 1 - - -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/src.mk -include $(MAKEFILEDIR)/verbose.mk - - -PKGCONF_LIBS := libbsd-overlay - - -DEFAULT_CPPFLAGS := $(shell $(PKGCONF) --cflags $(PKGCONF_LIBS) $(HIDE_ERR)) -EXTRA_CPPFLAGS := -CPPFLAGS := $(DEFAULT_CPPFLAGS) $(EXTRA_CPPFLAGS) - -DEFAULT_CFLAGS := \ - -std=gnu17 \ - -Wall \ - -Wextra \ - -Wstrict-prototypes \ - -Wdeclaration-after-statement \ - -Werror \ - -Wno-error=unused-parameter \ - -Wno-error=sign-compare \ - -Wno-error=format \ - -Wno-error=uninitialized - #-Wno-error=declaration-after-statement -EXTRA_CFLAGS := -CFLAGS := $(DEFAULT_CFLAGS) $(EXTRA_CFLAGS) - -DEFAULT_LDFLAGS := \ - -Wl,--as-needed \ - -Wl,--no-allow-shlib-undefined \ - -Wl,--no-copy-dt-needed-entries \ - -Wl,--no-undefined \ - $(shell $(PKGCONF) --libs-only-L $(PKGCONF_LIBS) $(HIDE_ERR)) \ - $(shell $(PKGCONF) --libs-only-other $(PKGCONF_LIBS) $(HIDE_ERR)) -EXTRA_LDFLAGS := -LDFLAGS := $(DEFAULT_LDFLAGS) $(EXTRA_LDFLAGS) - -DEFAULT_LDLIBS := \ - -lc \ - $(shell $(PKGCONF) --libs-only-l $(PKGCONF_LIBS) $(HIDE_ERR)) -EXTRA_LDLIBS := -LDLIBS := $(DEFAULT_LDLIBS) $(EXTRA_LDLIBS) - - -CC := cc -LD := $(CC) $(CFLAGS) - - -_SRCPAGEDIRS := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.d/,$(NONSO_MAN)) - -_UNITS_src_src := $(patsubst $(MANDIR)/%,$(_MANDIR)/%,$(shell \ - $(FIND) $(MANDIR)/* -type f \ - | $(GREP) '$(MANEXT)' \ - | $(XARGS) $(GREP) -H '^\.\\" SRC BEGIN ' \ - | $(SED) 's,:\.\\" SRC BEGIN (,.d/,' \ - | $(SED) 's/)//' \ - | $(SORT) \ - | $(SED) 's,:,\\:,g')) -_UNITS_src_h := $(filter %.h,$(_UNITS_src_src)) -_UNITS_src_c := $(filter %.c,$(_UNITS_src_src)) -_UNITS_src_o := $(patsubst %.c,%.o,$(_UNITS_src_c)) -_UNITS_src_bin := $(patsubst %.c,%,$(_UNITS_src_c)) - - -$(_SRCPAGEDIRS): $(_MANDIR)/%.d/: $(MANDIR)/% - +$(info MKDIR $@) - +$(MKDIR) $@ - +touch $@ - -$(_UNITS_src_src): $$(patsubst $(_MANDIR)/%.d,$(MANDIR)/%,$$(@D)) | $$(@D)/ -$(_UNITS_src_c): $$(filter $$(@D)/%.h,$(_UNITS_src_h)) -$(_UNITS_src_src): - $(info SED $@) - <$< \ - $(SED) -n \ - -e '/^\.TH/,/^\.SH/{/^\.SH/!p}' \ - -e '/^\.SH EXAMPLES/p' \ - -e "/^\... SRC BEGIN ($(@F))$$/,/^\... SRC END$$/p" \ - | $(MANDOC) -Tutf8 \ - | $(SED) '/^[^ ]/d' \ - | $(SED) 's/^ //' \ - >$@ - -$(_UNITS_src_o): %.o: %.c - $(info CC $@) - $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< - -$(_UNITS_src_bin): %: %.o - $(info LD $@) - $(LD) $(LDFLAGS) -o $@ $< $(LDLIBS) - - -.PHONY: build-src-c -build-src-c: $(_UNITS_src_c); - -.PHONY: build-src-cc -build-src-cc: $(_UNITS_src_o); - -.PHONY: build-src-ld -build-src-ld: $(_UNITS_src_bin); - -.PHONY: build-src -build-src: build-src-ld - - -endif # include guard diff --git a/share/mk/check/_.mk b/share/mk/check/_.mk index 6326d1f..0a20317 100644 --- a/share/mk/check/_.mk +++ b/share/mk/check/_.mk @@ -1,18 +1,13 @@ -######################################################################## -# Copyright 2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception ifndef MAKEFILE_CHECK_INCLUDED MAKEFILE_CHECK_INCLUDED := 1 -check := check-catman - - .PHONY: check -check: $(check); +check: check-catman; endif # include guard diff --git a/share/mk/check/catman.mk b/share/mk/check/catman.mk deleted file mode 100644 index 8a0d3b6..0000000 --- a/share/mk/check/catman.mk +++ /dev/null @@ -1,51 +0,0 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_CHECK_CATMAN_INCLUDED -MAKEFILE_CHECK_CATMAN_INCLUDED := 1 - - -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/build/catman.mk -include $(MAKEFILEDIR)/check/_.mk -include $(MAKEFILEDIR)/src.mk - - -DEFAULT_COLFLAGS := \ - -b \ - -p \ - -x -EXTRA_COLFLAGS := -COLFLAGS := $(DEFAULT_COLFLAGS) $(EXTRA_COLFLAGS) -COL := col - - -_CHECK_catman_grep := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.cat.grep,$(NONSO_MAN) $(NONSO_MDOC)) -_CHECK_catman := $(patsubst $(MANDIR)/%,$(_MANDIR)/%.check-catman.touch,$(NONSO_MAN) $(NONSO_MDOC)) - - -$(_CHECK_catman_grep): %.grep: % | $$(@D)/ - $(info COL $@) - $(COL) $(COLFLAGS) <$< >$@ - -$(_CHECK_catman): %.check-catman.touch: %.cat.grep | $$(@D)/ - $(info GREP $@) - ! $(GREP) -n '.\{$(MANWIDTH)\}.' $< /dev/null >&2 - touch $@ - - -.PHONY: check-catman-col -check-catman-col: $(_CHECK_catman_grep); - -.PHONY: check-catman-grep -check-catman-grep: $(_CHECK_catman); - -.PHONY: check-catman -check-catman: check-catman-grep; - - -endif # include guard diff --git a/share/mk/check/catman/_.mk b/share/mk/check/catman/_.mk new file mode 100644 index 0000000..b9bf5a1 --- /dev/null +++ b/share/mk/check/catman/_.mk @@ -0,0 +1,13 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CHECK_CATMAN_INCLUDED +MAKEFILE_CHECK_CATMAN_INCLUDED := 1 + + +.PHONY: check-catman +check-catman: check-catman-grep; + + +endif # include guard diff --git a/share/mk/check/catman/col.mk b/share/mk/check/catman/col.mk new file mode 100644 index 0000000..59104fa --- /dev/null +++ b/share/mk/check/catman/col.mk @@ -0,0 +1,25 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CHECK_CATMAN_COL_INCLUDED +MAKEFILE_CHECK_CATMAN_COL_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/catman/grotty.mk +include $(MAKEFILEDIR)/configure/build-depends/bsdextrautils.mk + + +_CHECK_catman_grep := $(patsubst %.cat,%.cat.grep,$(_CATMAN)) + + +$(_CHECK_catman_grep): %.grep: % $(MK) | $$(@D)/ + $(info $(INFO_)COL $@) + $(COL) $(COLFLAGS) <$< >$@ + + +.PHONY: check-catman-col +check-catman-col: $(_CHECK_catman_grep); + + +endif # include guard diff --git a/share/mk/check/catman/grep.mk b/share/mk/check/catman/grep.mk new file mode 100644 index 0000000..fbf99bc --- /dev/null +++ b/share/mk/check/catman/grep.mk @@ -0,0 +1,50 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CHECK_CATMAN_GREP_INCLUDED +MAKEFILE_CHECK_CATMAN_GREP_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/man.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_CHECK_catman := \ + $(_MANDIR)/man1/memusage.1.check-catman.touch \ + $(_MANDIR)/man3/mallopt.3.check-catman.touch \ + $(_MANDIR)/man4/smartpqi.4.check-catman.touch \ + $(_MANDIR)/man4/veth.4.check-catman.touch \ + $(_MANDIR)/man5/proc_buddyinfo.5.check-catman.touch \ + $(_MANDIR)/man5/proc_pid_fdinfo.5.check-catman.touch \ + $(_MANDIR)/man5/proc_pid_maps.5.check-catman.touch \ + $(_MANDIR)/man5/proc_pid_mountinfo.5.check-catman.touch \ + $(_MANDIR)/man5/proc_pid_net.5.check-catman.touch \ + $(_MANDIR)/man5/proc_timer_stats.5.check-catman.touch \ + $(_MANDIR)/man5/proc_version.5.check-catman.touch \ + $(_MANDIR)/man5/slabinfo.5.check-catman.touch \ + $(_MANDIR)/man7/keyrings.7.check-catman.touch \ + $(_MANDIR)/man7/string_copying.7.check-catman.touch \ + $(_MANDIR)/man7/uri.7.check-catman.touch + + +_CHECK_catman := $(patsubst %.cat.grep,%.check-catman.touch,$(_CHECK_catman_grep)) +ifeq ($(SKIP_XFAIL),yes) +_CHECK_catman := $(filter-out $(_XFAIL_CHECK_catman), $(_CHECK_catman)) +endif + + +$(_CHECK_catman): %.check-catman.touch: %.cat.grep $(MK) | $$(@D)/ + $(info $(INFO_)GREP $@) + ! $(GREP) -n '.\{$(MANWIDTH)\}.' $< /dev/null >&2 + $(TOUCH) $@ + + +.PHONY: check-catman-grep +check-catman-grep: $(_CHECK_catman); + + +endif # include guard diff --git a/share/mk/clean.mk b/share/mk/clean.mk new file mode 100644 index 0000000..a0908fa --- /dev/null +++ b/share/mk/clean.mk @@ -0,0 +1,19 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CLEAN_INCLUDED +MAKEFILE_CLEAN_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk + + +.PHONY: clean +clean: + $(info $(INFO_)RM -rf $(builddir)) + $(RM) -rf $(builddir) + + +endif # include guard diff --git a/share/mk/cmd.mk b/share/mk/cmd.mk deleted file mode 100644 index aa7c07c..0000000 --- a/share/mk/cmd.mk +++ /dev/null @@ -1,40 +0,0 @@ -######################################################################## -# Copyright 2022, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_CMD_INCLUDED -MAKEFILE_CMD_INCLUDED := 1 - - -BZIP2 := bzip2 -CP := cp -ECHO := echo -EXPR := expr -FIND := find -GIT := git -GREP := grep -GZIP := gzip -HEAD := head -INSTALL := install -LN := ln -LOCALE := locale -LZIP := lzip -MANDOC := mandoc -PKGCONF := pkgconf -SED := sed -SORT := sort -SPONGE := sponge -TAC := tac -TAIL := tail -TAR := tar -TEST := test -XARGS := xargs -XZ := xz - -INSTALL_DATA := $(INSTALL) -m 644 -INSTALL_DIR := $(INSTALL) -m 755 -d - - -endif # include guard diff --git a/share/mk/compress.mk b/share/mk/compress.mk deleted file mode 100644 index 6502930..0000000 --- a/share/mk/compress.mk +++ /dev/null @@ -1,40 +0,0 @@ -######################################################################## -# Copyright 2023 Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_COMPRESS_INCLUDED -MAKEFILE_COMPRESS_INCLUDED := 1 - - -Z := -ifeq ($(Z),) -else ifeq ($(Z),.bz2) -else ifeq ($(Z),.gz) -else ifeq ($(Z),.lz) -else ifeq ($(Z),.xz) -else -$(warning "Z": "$(Z)") -$(error Valid values for "Z": ["", ".bz2", ".gz", ".lz", ".xz"]) -endif - - -DEFAULT_BZIP2FLAGS := -EXTRA_BZIP2FLAGS := -BZIP2FLAGS := $(DEFAULT_BZIP2FLAGS) $(EXTRA_BZIP2FLAGS) - -DEFAULT_GZIPFLAGS := -EXTRA_GZIPFLAGS := -GZIPFLAGS := $(DEFAULT_GZIPFLAGS) $(EXTRA_GZIPFLAGS) - -DEFAULT_LZIPFLAGS := -EXTRA_LZIPFLAGS := -LZIPFLAGS := $(DEFAULT_LZIPFLAGS) $(EXTRA_LZIPFLAGS) - -DEFAULT_XZFLAGS := -EXTRA_XZFLAGS := -XZFLAGS := $(DEFAULT_XZFLAGS) $(EXTRA_XZFLAGS) - - -endif # include guard diff --git a/share/mk/configure/build-depends/bsdextrautils.mk b/share/mk/configure/build-depends/bsdextrautils.mk new file mode 100644 index 0000000..347e4bc --- /dev/null +++ b/share/mk/configure/build-depends/bsdextrautils.mk @@ -0,0 +1,18 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_BSDEXTRAUTILS_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_BSDEXTRAUTILS_INCLUDED := 1 + + +DEFAULT_COLFLAGS := \ + -b \ + -p \ + -x +EXTRA_COLFLAGS := +COLFLAGS := $(DEFAULT_COLFLAGS) $(EXTRA_COLFLAGS) +COL := col + + +endif # include guard diff --git a/share/mk/configure/build-depends/bzip2.mk b/share/mk/configure/build-depends/bzip2.mk new file mode 100644 index 0000000..71e6366 --- /dev/null +++ b/share/mk/configure/build-depends/bzip2.mk @@ -0,0 +1,15 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_BZIP2_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_BZIP2_INCLUDED := 1 + + +DEFAULT_BZIP2FLAGS := +EXTRA_BZIP2FLAGS := +BZIP2FLAGS := $(DEFAULT_BZIP2FLAGS) $(EXTRA_BZIP2FLAGS) +BZIP2 := bzip2 + + +endif # include guard diff --git a/share/mk/configure/build-depends/cc.mk b/share/mk/configure/build-depends/cc.mk new file mode 100644 index 0000000..85470a4 --- /dev/null +++ b/share/mk/configure/build-depends/cc.mk @@ -0,0 +1,63 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CC_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_CC_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk + + +CC := gcc + + +CC_VENDOR := \ + $(shell \ + $(CC) -v 2>&1 \ + | $(SED) -n '1p;$$p' \ + | $(SED) '/gcc version/s/.*/gcc/' \ + | $(SED) '/clang version/s/.*/clang/' \ + | $(SED) '/Apple LLVM version/s/.*/clang/' \ + | $(GREP) -e '^gcc$$' -e '^clang$$' \ + || $(ECHO) unknown; \ + ) + + +COMMON_CFLAGS := \ + -O3 \ + -flto \ + -Wall \ + -Wextra \ + -Werror \ + -Wstrict-prototypes \ + -Wdeclaration-after-statement \ + -Wno-error=unused-parameter \ + -Wno-error=sign-compare \ + -Wno-error=format \ + -Wno-error=uninitialized + + +GCC_CFLAGS := -fanalyzer + + +CLANG_CFLAGS := \ + -Weverything \ + -Wno-unsafe-buffer-usage + + +DEFAULT_CFLAGS := $(COMMON_CFLAGS) + +ifeq ($(CC_VENDOR),gcc) +DEFAULT_CFLAGS += $(GCC_CFLAGS) +else ifeq ($(CC_VENDOR),clang) +DEFAULT_CFLAGS += $(CLANG_CFLAGS) +endif + +EXTRA_CFLAGS := +CFLAGS := $(DEFAULT_CFLAGS) $(EXTRA_CFLAGS) + + +endif # include guard diff --git a/share/mk/configure/build-depends/checkpatch.mk b/share/mk/configure/build-depends/checkpatch.mk new file mode 100644 index 0000000..0b29d9f --- /dev/null +++ b/share/mk/configure/build-depends/checkpatch.mk @@ -0,0 +1,19 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CHECKPATCH_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_CHECKPATCH_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/src.mk + + +CHECKPATCH_CONF := $(SYSCONFDIR)/checkpatch/checkpatch.conf +DEFAULT_CHECKPATCHFLAGS := +EXTRA_CHECKPATCHFLAGS := +CHECKPATCHFLAGS := $(DEFAULT_CHECKPATCHFLAGS) $(EXTRA_CHECKPATCHFLAGS) +CHECKPATCH := checkpatch + + +endif # include guard diff --git a/share/mk/configure/build-depends/clang-tidy.mk b/share/mk/configure/build-depends/clang-tidy.mk new file mode 100644 index 0000000..2d818f9 --- /dev/null +++ b/share/mk/configure/build-depends/clang-tidy.mk @@ -0,0 +1,22 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CLANG_TIDY_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_CLANG_TIDY_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/src.mk + + +CLANG_TIDY_CONF := $(SYSCONFDIR)/clang-tidy/config.yaml +DEFAULT_CLANG_TIDYFLAGS := \ + --config-file=$(CLANG_TIDY_CONF) \ + --quiet \ + --use-color +EXTRA_CLANG_TIDYFLAGS := +CLANG_TIDYFLAGS := $(DEFAULT_CLANG_TIDYFLAGS) $(EXTRA_CLANG_TIDYFLAGS) +CLANG_TIDY := clang-tidy + + +endif # include guard diff --git a/share/mk/configure/build-depends/clang.mk b/share/mk/configure/build-depends/clang.mk new file mode 100644 index 0000000..b44ccb5 --- /dev/null +++ b/share/mk/configure/build-depends/clang.mk @@ -0,0 +1,19 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CLANG_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_CLANG_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/cc.mk + + +DEFAULT_CLANGFLAGS := \ + $(COMMON_CFLAGS) \ + $(CLANG_CFLAGS) +EXTRA_CLANGFLAGS := +CLANGFLAGS := $(DEFAULT_CLANGFLAGS) $(EXTRA_CLANGFLAGS) + + +endif # include guard diff --git a/share/mk/configure/build-depends/coreutils.mk b/share/mk/configure/build-depends/coreutils.mk new file mode 100644 index 0000000..2fe97fe --- /dev/null +++ b/share/mk/configure/build-depends/coreutils.mk @@ -0,0 +1,32 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_COREUTILS_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_COREUTILS_INCLUDED := 1 + + +CAT := cat +CP := cp +ECHO := echo +EXPR := expr +HEAD := head +INSTALL := install +LN := ln +MKDIR := mkdir +REALPATH := realpath +RM := rm +SORT := sort +STAT := stat +TAC := tac +TAIL := tail +TEST := test +TOUCH := touch +TRUE := true + + +INSTALL_DATA := $(INSTALL) -m 644 +INSTALL_DIR := $(INSTALL) -m 755 -d + + +endif # include guard diff --git a/share/mk/configure/build-depends/cpp.mk b/share/mk/configure/build-depends/cpp.mk new file mode 100644 index 0000000..b720898 --- /dev/null +++ b/share/mk/configure/build-depends/cpp.mk @@ -0,0 +1,20 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPP_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPP_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/cc.mk +include $(MAKEFILEDIR)/configure/build-depends/pkgconf.mk +include $(MAKEFILEDIR)/configure/verbose.mk + + +DEFAULT_CPPFLAGS := $(shell $(PKGCONF_CMD) --cflags $(PKGCONF_LIBS) $(HIDE_ERR)) +EXTRA_CPPFLAGS := +CPPFLAGS := $(DEFAULT_CPPFLAGS) $(EXTRA_CPPFLAGS) +CPP := $(CC) $(CFLAGS) -E + + +endif # include guard diff --git a/share/mk/configure/build-depends/cppcheck.mk b/share/mk/configure/build-depends/cppcheck.mk new file mode 100644 index 0000000..93a9b75 --- /dev/null +++ b/share/mk/configure/build-depends/cppcheck.mk @@ -0,0 +1,24 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPPCHECK_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPPCHECK_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/src.mk + + +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 + + +endif # include guard diff --git a/share/mk/configure/build-depends/cpplint.mk b/share/mk/configure/build-depends/cpplint.mk new file mode 100644 index 0000000..586d646 --- /dev/null +++ b/share/mk/configure/build-depends/cpplint.mk @@ -0,0 +1,19 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPPLINT_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_CPPLINT_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/src.mk + + +CPPLINT_CONF := $(SYSCONFDIR)/cpplint/cpplint.cfg +DEFAULT_CPPLINTFLAGS := +EXTRA_CPPLINTFLAGS := +CPPLINTFLAGS := $(DEFAULT_CPPLINTFLAGS) $(EXTRA_CPPLINTFLAGS) +CPPLINT := cpplint + + +endif # include guard diff --git a/share/mk/configure/build-depends/diffoscope.mk b/share/mk/configure/build-depends/diffoscope.mk new file mode 100644 index 0000000..a9e48b3 --- /dev/null +++ b/share/mk/configure/build-depends/diffoscope.mk @@ -0,0 +1,12 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_DIFFOSCOPE_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_DIFFOSCOPE_INCLUDED := 1 + + +DIFFOSCOPE := diffoscope + + +endif # include guard diff --git a/share/mk/configure/build-depends/findutils.mk b/share/mk/configure/build-depends/findutils.mk new file mode 100644 index 0000000..536f921 --- /dev/null +++ b/share/mk/configure/build-depends/findutils.mk @@ -0,0 +1,13 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_FINDUTILS_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_FINDUTILS_INCLUDED := 1 + + +FIND := find +XARGS := xargs + + +endif # include guard diff --git a/share/mk/configure/build-depends/git.mk b/share/mk/configure/build-depends/git.mk new file mode 100644 index 0000000..a861bed --- /dev/null +++ b/share/mk/configure/build-depends/git.mk @@ -0,0 +1,12 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_GIT_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_GIT_INCLUDED := 1 + + +GIT := git + + +endif # include guard diff --git a/share/mk/configure/build-depends/grep.mk b/share/mk/configure/build-depends/grep.mk new file mode 100644 index 0000000..7d89691 --- /dev/null +++ b/share/mk/configure/build-depends/grep.mk @@ -0,0 +1,12 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_GREP_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_GREP_INCLUDED := 1 + + +GREP := grep + + +endif # include guard diff --git a/share/mk/configure/build-depends/groff-base.mk b/share/mk/configure/build-depends/groff-base.mk new file mode 100644 index 0000000..ab1f98d --- /dev/null +++ b/share/mk/configure/build-depends/groff-base.mk @@ -0,0 +1,72 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_GROFF_BASE_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_GROFF_BASE_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/libc-bin.mk +include $(MAKEFILEDIR)/configure/build-depends/man.mk + + +DEFAULT_PRECONVFLAGS := +EXTRA_PRECONVFLAGS := +PRECONVFLAGS := $(DEFAULT_PRECONVFLAGS) $(EXTRA_PRECONVFLAGS) +PRECONV := preconv + + +DEFAULT_PICFLAGS := +EXTRA_PICFLAGS := +PICFLAGS := $(DEFAULT_PICFLAGS) $(EXTRA_PICFLAGS) +PIC := pic + + +TBL := tbl + + +DEFAULT_EQNFLAGS := +EXTRA_EQNFLAGS := +EQNFLAGS := $(DEFAULT_EQNFLAGS) $(EXTRA_EQNFLAGS) +EQN := eqn + + +DEFAULT_TROFFFLAGS := -wbreak +EXTRA_TROFFFLAGS := +TROFFFLAGS := $(DEFAULT_TROFFFLAGS) $(EXTRA_TROFFFLAGS) +TROFF := troff + + +TROFF_CHECKSTYLE_LVL := 3 +NROFF_LINE_LENGTH := $(shell $(EXPR) $(MANWIDTH) - 2) +NROFF_OUT_DEVICE := \ + $(shell $(LOCALE) charmap \ + | $(GREP) -i 'utf-*8' >/dev/null \ + && $(ECHO) utf8 \ + || $(ECHO) ascii \ + ) + +DEFAULT_NROFFFLAGS := \ + -T$(NROFF_OUT_DEVICE) \ + -rLL=$(NROFF_LINE_LENGTH)n \ + -rCHECKSTYLE=$(TROFF_CHECKSTYLE_LVL) \ + -ww +EXTRA_NROFFFLAGS := +NROFFFLAGS := $(DEFAULT_NROFFFLAGS) $(EXTRA_NROFFFLAGS) + + +DEFAULT_GROTTYFLAGS := -c +EXTRA_GROTTYFLAGS := +GROTTYFLAGS := $(DEFAULT_GROTTYFLAGS) $(EXTRA_GROTTYFLAGS) +GROTTY := grotty + + +DEFAULT_GROPSFLAGS := +EXTRA_GROPSFLAGS := +GROPSFLAGS := $(DEFAULT_GROPSFLAGS) $(EXTRA_GROPSFLAGS) +GROPS := grops + + +endif # include guard diff --git a/share/mk/configure/build-depends/groff.mk b/share/mk/configure/build-depends/groff.mk new file mode 100644 index 0000000..ea0c7a3 --- /dev/null +++ b/share/mk/configure/build-depends/groff.mk @@ -0,0 +1,21 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_GROFF_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_GROFF_INCLUDED := 1 + + +DEFAULT_GROPDFFLAGS := +EXTRA_GROPDFFLAGS := +GROPDFFLAGS := $(DEFAULT_GROPDFFLAGS) $(EXTRA_GROPDFFLAGS) +GROPDF := gropdf + + +DEFAULT_POST_GROHTMLFLAGS := +EXTRA_POST_GROHTMLFLAGS := +POST_GROHTMLFLAGS := $(DEFAULT_POST_GROHTMLFLAGS) $(EXTRA_POST_GROHTMLFLAGS) +POST_GROHTML := post-grohtml + + +endif # include guard diff --git a/share/mk/configure/build-depends/gzip.mk b/share/mk/configure/build-depends/gzip.mk new file mode 100644 index 0000000..6633654 --- /dev/null +++ b/share/mk/configure/build-depends/gzip.mk @@ -0,0 +1,15 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_GZIP_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_GZIP_INCLUDED := 1 + + +DEFAULT_GZIPFLAGS := -n +EXTRA_GZIPFLAGS := +GZIPFLAGS := $(DEFAULT_GZIPFLAGS) $(EXTRA_GZIPFLAGS) +GZIP := gzip + + +endif # include guard diff --git a/share/mk/configure/build-depends/iwyu.mk b/share/mk/configure/build-depends/iwyu.mk new file mode 100644 index 0000000..bd5cf7f --- /dev/null +++ b/share/mk/configure/build-depends/iwyu.mk @@ -0,0 +1,17 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_IWYU_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_IWYU_INCLUDED := 1 + + +DEFAULT_IWYUFLAGS := \ + -Xiwyu --no_fwd_decls \ + -Xiwyu --error +EXTRA_IWYUFLAGS := +IWYUFLAGS := $(DEFAULT_IWYUFLAGS) $(EXTRA_IWYUFLAGS) +IWYU := iwyu + + +endif # include guard diff --git a/share/mk/configure/build-depends/ld.mk b/share/mk/configure/build-depends/ld.mk new file mode 100644 index 0000000..a78a189 --- /dev/null +++ b/share/mk/configure/build-depends/ld.mk @@ -0,0 +1,50 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_LD_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_LD_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/cc.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/pkgconf.mk +include $(MAKEFILEDIR)/configure/verbose.mk + + +LD := $(CC) $(CFLAGS) + + +LD_HAS_FUSE_LINKER_PLUGIN := \ + $(shell \ + $(ECHO) 'int main(void) {}' \ + | $(LD) -fuse-linker-plugin -x c -o /dev/null /dev/stdin $(HIDE_ERR) \ + && $(ECHO) yes \ + || $(ECHO) no; \ + ) + + +DEFAULT_LDFLAGS := \ + -Wl,--as-needed \ + -Wl,--no-allow-shlib-undefined \ + -Wl,--no-copy-dt-needed-entries \ + -Wl,--no-undefined \ + $(shell $(PKGCONF_CMD) --libs-only-L $(PKGCONF_LIBS) $(HIDE_ERR)) \ + $(shell $(PKGCONF_CMD) --libs-only-other $(PKGCONF_LIBS) $(HIDE_ERR)) + +ifeq ($(LD_HAS_FUSE_LINKER_PLUGIN),yes) +DEFAULT_LDFLAGS += -fuse-linker-plugin +endif + +EXTRA_LDFLAGS := +LDFLAGS := $(DEFAULT_LDFLAGS) $(EXTRA_LDFLAGS) + + +DEFAULT_LDLIBS := \ + -lc \ + $(shell $(PKGCONF_CMD) --libs-only-l $(PKGCONF_LIBS) $(HIDE_ERR)) +EXTRA_LDLIBS := +LDLIBS := $(DEFAULT_LDLIBS) $(EXTRA_LDLIBS) + + +endif # include guard diff --git a/share/mk/configure/build-depends/libc-bin.mk b/share/mk/configure/build-depends/libc-bin.mk new file mode 100644 index 0000000..281502b --- /dev/null +++ b/share/mk/configure/build-depends/libc-bin.mk @@ -0,0 +1,12 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_LIBC_BIN_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_LIBC_BIN_INCLUDED := 1 + + +LOCALE := locale + + +endif # include guard diff --git a/share/mk/configure/build-depends/lzip.mk b/share/mk/configure/build-depends/lzip.mk new file mode 100644 index 0000000..e18868f --- /dev/null +++ b/share/mk/configure/build-depends/lzip.mk @@ -0,0 +1,15 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_LZIP_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_LZIP_INCLUDED := 1 + + +DEFAULT_LZIPFLAGS := +EXTRA_LZIPFLAGS := +LZIPFLAGS := $(DEFAULT_LZIPFLAGS) $(EXTRA_LZIPFLAGS) +LZIP := lzip + + +endif # include guard diff --git a/share/mk/configure/build-depends/man.mk b/share/mk/configure/build-depends/man.mk new file mode 100644 index 0000000..5248d42 --- /dev/null +++ b/share/mk/configure/build-depends/man.mk @@ -0,0 +1,12 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_MAN_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_MAN_INCLUDED := 1 + + +MANWIDTH ?= 80 + + +endif # include guard diff --git a/share/mk/configure/build-depends/mandoc.mk b/share/mk/configure/build-depends/mandoc.mk new file mode 100644 index 0000000..87eccd6 --- /dev/null +++ b/share/mk/configure/build-depends/mandoc.mk @@ -0,0 +1,15 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_MANDOC_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_MANDOC_INCLUDED := 1 + + +DEFAULT_MANDOCFLAGS := -Tlint +EXTRA_MANDOCFLAGS := +MANDOCFLAGS := $(DEFAULT_MANDOCFLAGS) $(EXTRA_MANDOCFLAGS) +MANDOC := mandoc + + +endif # include guard diff --git a/share/mk/configure/build-depends/moreutils.mk b/share/mk/configure/build-depends/moreutils.mk new file mode 100644 index 0000000..69b60fa --- /dev/null +++ b/share/mk/configure/build-depends/moreutils.mk @@ -0,0 +1,12 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_MOREUTILS_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_MOREUTILS_INCLUDED := 1 + + +SPONGE := sponge + + +endif # include guard diff --git a/share/mk/configure/build-depends/pkgconf.mk b/share/mk/configure/build-depends/pkgconf.mk new file mode 100644 index 0000000..b7b5c3f --- /dev/null +++ b/share/mk/configure/build-depends/pkgconf.mk @@ -0,0 +1,27 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_PKGCONF_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_PKGCONF_INCLUDED := 1 + + +include $(MAKEFILEDIR)/src.mk +include $(MAKEFILEDIR)/configure/version.mk + + +# Compat +PKG_CONFIG := pkgconf + + +DEFAULT_PKGCONFFLAGS := +EXTRA_PKGCONFFLAGS := +PKGCONFFLAGS := $(DEFAULT_PKGCONFFLAGS) $(EXTRA_PKGCONFFLAGS) +PKGCONF := $(PKG_CONFIG) +PKGCONF_CMD := $(PKGCONF) $(PKGCONFFLAGS) + + +PKGCONF_LIBS := libbsd-overlay + + +endif # include guard diff --git a/share/mk/configure/build-depends/sed.mk b/share/mk/configure/build-depends/sed.mk new file mode 100644 index 0000000..3d1fcd8 --- /dev/null +++ b/share/mk/configure/build-depends/sed.mk @@ -0,0 +1,12 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_SED_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_SED_INCLUDED := 1 + + +SED := sed + + +endif # include guard diff --git a/share/mk/configure/build-depends/tar.mk b/share/mk/configure/build-depends/tar.mk new file mode 100644 index 0000000..3ea5537 --- /dev/null +++ b/share/mk/configure/build-depends/tar.mk @@ -0,0 +1,22 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_TAR_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_TAR_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/version.mk + + +DEFAULT_TARFLAGS := \ + --sort=name \ + --owner=root:0 \ + --group=root:0 \ + --mtime='$(DISTDATE)' +EXTRA_TARFLAGS := +TARFLAGS := $(DEFAULT_TARFLAGS) $(EXTRA_TARFLAGS) +TAR := tar + + +endif # include guard diff --git a/share/mk/configure/build-depends/xz-utils.mk b/share/mk/configure/build-depends/xz-utils.mk new file mode 100644 index 0000000..d00a3b7 --- /dev/null +++ b/share/mk/configure/build-depends/xz-utils.mk @@ -0,0 +1,15 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_BUILD_DEPENDS_XZ_UTILS_INCLUDED +MAKEFILE_CONFIGURE_BUILD_DEPENDS_XZ_UTILS_INCLUDED := 1 + + +DEFAULT_XZFLAGS := +EXTRA_XZFLAGS := +XZFLAGS := $(DEFAULT_XZFLAGS) $(EXTRA_XZFLAGS) +XZ := xz + + +endif # include guard diff --git a/share/mk/configure/directory_variables.mk b/share/mk/configure/directory_variables.mk new file mode 100644 index 0000000..e4ee616 --- /dev/null +++ b/share/mk/configure/directory_variables.mk @@ -0,0 +1,29 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_DIRECTORY_VARIABLES_INCLUDED +MAKEFILE_CONFIGURE_DIRECTORY_VARIABLES_INCLUDED := 1 + + +include $(MAKEFILEDIR)/src.mk + + +builddir := .tmp + + +DESTDIR := +prefix := /usr/local +datarootdir := $(prefix)/share +docdir := $(datarootdir)/doc +htmldir := $(docdir)/html/man +mandir := $(datarootdir)/man + + +$(foreach s, $(MANSECTIONS), \ + $(eval man$(s)dir := $(mandir)/man$(s))) +$(foreach s, $(MANSECTIONS), \ + $(eval man$(s)ext := .$(s))) + + +endif # include guard diff --git a/share/mk/configure/link_pages.mk b/share/mk/configure/link_pages.mk new file mode 100644 index 0000000..52136ef --- /dev/null +++ b/share/mk/configure/link_pages.mk @@ -0,0 +1,18 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_LINK_PAGES_INCLUDED +MAKEFILE_CONFIGURE_LINK_PAGES_INCLUDED := 1 + + +LINK_PAGES := .so +ifeq ($(LINK_PAGES),.so) +else ifeq ($(LINK_PAGES),symlink) +else +$(warning "LINK_PAGES": "$(LINK_PAGES)") +$(error Valid values for "LINK_PAGES": [".so", "symlink"]) +endif + + +endif # include guard diff --git a/share/mk/configure/src.mk b/share/mk/configure/src.mk new file mode 100644 index 0000000..2a24f4e --- /dev/null +++ b/share/mk/configure/src.mk @@ -0,0 +1,16 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_SRC_INCLUDED +MAKEFILE_CONFIGURE_SRC_INCLUDED := 1 + + +SYSCONFDIR := $(srcdir)/etc +MANDIR := $(srcdir) + + +MANSECTIONS := $(patsubst $(MANDIR)/man%/, %, $(wildcard $(MANDIR)/man*/)) + + +endif # include guard diff --git a/share/mk/configure/verbose.mk b/share/mk/configure/verbose.mk new file mode 100644 index 0000000..d6372db --- /dev/null +++ b/share/mk/configure/verbose.mk @@ -0,0 +1,12 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_VERBOSE_INCLUDED +MAKEFILE_CONFIGURE_VERBOSE_INCLUDED := 1 + + +HIDE_ERR := 2>/dev/null + + +endif # include guard diff --git a/share/mk/configure/version.mk b/share/mk/configure/version.mk new file mode 100644 index 0000000..cc89bae --- /dev/null +++ b/share/mk/configure/version.mk @@ -0,0 +1,43 @@ +# Copyright 2022-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_VERSION_INCLUDED +MAKEFILE_CONFIGURE_VERSION_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/findutils.mk +include $(MAKEFILEDIR)/configure/build-depends/git.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/verbose.mk + + +DISTNAME := man-pages-6.7 +DISTVERSION := 6.7 + + +DISTFILESCMD := \ + $(FIND) $(srcdir) -not -type d \ + | $(GREP) -v '^$(srcdir)/.git$$' \ + | $(GREP) -v '^$(srcdir)/.git/' \ + | $(GREP) -v '^$(srcdir)/.tmp/' \ + | $(GREP) -v '^$(srcdir)/.checkpatch-camelcase.' \ + | $(SORT) + +DISTDATECMD := \ + $(ECHO) '$(DISTVERSION)' \ + | if $(GREP) -- '-dirty$$' >/dev/null; then \ + $(DISTFILESCMD) \ + | $(XARGS) $(STAT) -c %y \ + | $(SORT) -n \ + | $(TAIL) -n1; \ + else \ + $(GIT) log -1 --format='%cD'; \ + fi; + + +DISTDATE := Tue, 19 Mar 2024 19:07:13 +0100 + + +endif # include guard diff --git a/share/mk/configure/xfail.mk b/share/mk/configure/xfail.mk new file mode 100644 index 0000000..44e4ede --- /dev/null +++ b/share/mk/configure/xfail.mk @@ -0,0 +1,18 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_XFAIL_INCLUDED +MAKEFILE_CONFIGURE_XFAIL_INCLUDED := 1 + + +SKIP_XFAIL := yes +ifeq ($(SKIP_XFAIL),yes) +else ifeq ($(SKIP_XFAIL),no) +else +$(warning "SKIP_XFAIL": "$(SKIP_XFAIL)") +$(error Valid values for "SKIP_XFAIL": ["yes", "no"]) +endif + + +endif # include guard diff --git a/share/mk/configure/z.mk b/share/mk/configure/z.mk new file mode 100644 index 0000000..2eec437 --- /dev/null +++ b/share/mk/configure/z.mk @@ -0,0 +1,21 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_CONFIGURE_Z_INCLUDED +MAKEFILE_CONFIGURE_Z_INCLUDED := 1 + + +Z := +ifeq ($(Z),) +else ifeq ($(Z),.bz2) +else ifeq ($(Z),.gz) +else ifeq ($(Z),.lz) +else ifeq ($(Z),.xz) +else +$(warning "Z": "$(Z)") +$(error Valid values for "Z": ["", ".bz2", ".gz", ".lz", ".xz"]) +endif + + +endif # include guard diff --git a/share/mk/dist.mk b/share/mk/dist.mk deleted file mode 100644 index b18197d..0000000 --- a/share/mk/dist.mk +++ /dev/null @@ -1,96 +0,0 @@ -######################################################################## -# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_DIST_INCLUDED -MAKEFILE_DIST_INCLUDED := 1 - - -include $(MAKEFILEDIR)/build/_.mk -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/compress.mk -include $(MAKEFILEDIR)/install/_.mk -include $(MAKEFILEDIR)/version.mk -include $(MAKEFILEDIR)/verbose.mk - - -_DISTDIR := $(builddir)/dist - - -DEFAULT_TARFLAGS := \ - --sort=name \ - --owner=root:0 \ - --group=root:0 \ - --mtime='$(DISTDATE)' -EXTRA_TARFLAGS := -TARFLAGS := $(DEFAULT_TARFLAGS) $(EXTRA_TARFLAGS) - - -DISTFILES := $(shell $(GIT) ls-files $(HIDE_ERR) \ - | $(SED) 's,^,$(srcdir)/,' \ - | $(SED) 's,:,\\:,g') -_DISTFILES := $(patsubst $(srcdir)/%,$(_DISTDIR)/%,$(DISTFILES)) -_DISTPAGES := $(filter $(_DISTDIR)/man%,$(_DISTFILES)) -_DISTOTHERS := $(filter-out $(_DISTDIR)/man%,$(_DISTFILES)) - -DISTFILE := $(builddir)/$(DISTNAME).tar -compression := bz2 gz lz xz -dist := $(foreach x,$(compression),dist-$(x)) - - -$(builddir)/dist/%/: - +$(info INSTALL $@) - +$(INSTALL_DIR) $@ - - -$(_DISTPAGES): $(_DISTDIR)/man%: $(srcdir)/man% | $$(@D)/ - $(info INSTALL $@) - $(INSTALL_DATA) -T $< $@ - $(SED) -i '/^.TH/s/(unreleased)/$(DISTVERSION)/' $@ - $(SED) -i "/^.TH/s/(date)/$$(git log --format=%cs -1 -- $< $(HIDE_ERR))/" $@ - -$(_DISTOTHERS): $(_DISTDIR)/%: $(srcdir)/% | $$(@D)/ - $(info CP $@) - $(CP) -T $< $@ - - -$(DISTFILE): $(_DISTFILES) | $$(@D)/ - $(info TAR $@) - $(TAR) $(TARFLAGS) -cf $@ -T /dev/null - $(GIT) ls-files \ - | $(SED) 's,^,$(_DISTDIR)/,' \ - | $(XARGS) $(TAR) $(TARFLAGS) -rf $@ -C $(srcdir) \ - --transform 's,^$(_DISTDIR),$(DISTNAME),' - -$(DISTFILE).bz2: %.bz2: % | $$(@D)/ - $(info BZIP2 $@) - $(BZIP2) $(BZIP2FLAGS) -kf $< - touch $@ - -$(DISTFILE).gz: %.gz: % | $$(@D)/ - $(info GZIP $@) - $(GZIP) $(GZIPFLAGS) -knf $< - -$(DISTFILE).lz: %.lz: % | $$(@D)/ - $(info LZIP $@) - $(LZIP) $(LZIPFLAGS) -kf $< - touch $@ - -$(DISTFILE).xz: %.xz: % | $$(@D)/ - $(info XZ $@) - $(XZ) $(XZFLAGS) -kf $< - - -.PHONY: dist-tar -dist-tar: $(DISTFILE); - -.PHONY: $(dist) -$(dist): dist-%: $(DISTFILE).%; - -.PHONY: dist -dist: $(dist); - - -endif # include guard diff --git a/share/mk/dist/_.mk b/share/mk/dist/_.mk new file mode 100644 index 0000000..f6d8669 --- /dev/null +++ b/share/mk/dist/_.mk @@ -0,0 +1,25 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_INCLUDED +MAKEFILE_DIST_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk + + +_DISTDIR := $(builddir)/dist + + +$(builddir)/dist/%/: + +$(info $(INFO_)MKDIR $@) + +$(INSTALL_DIR) $@ + + +.PHONY: dist +dist: dist-tar dist-z; + + +endif # include guard diff --git a/share/mk/dist/check/_.mk b/share/mk/dist/check/_.mk new file mode 100644 index 0000000..a24b8f8 --- /dev/null +++ b/share/mk/dist/check/_.mk @@ -0,0 +1,41 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_CHECK_INCLUDED +MAKEFILE_DIST_CHECK_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk +include $(MAKEFILEDIR)/configure/version.mk + + +_DISTCHECKDIR := $(shell $(REALPATH) -m $(builddir)/distcheck) +_DISTCHECKSRCDIR := $(_DISTCHECKDIR)/$(DISTNAME) +_DISTCHECKBUILDDIR := $(_DISTCHECKDIR)/$(DISTNAME)_builddir +_DISTCHECKDESTDIR := $(_DISTCHECKDIR)/$(DISTNAME)_destdir +_DISTCHECK_MANDIR := $(_DISTCHECKBUILDDIR)/man + + +_MAKE_OPTS = \ + -C $< \ + 'builddir=$(_DISTCHECKBUILDDIR)' \ + 'DESTDIR=$(_DISTCHECKDESTDIR)' + + +distcheck-%: $(_DISTCHECKSRCDIR) $(MK) | $$(@D)/ + $(info $(INFO_)MAKE $@) + $(MAKE) $(_MAKE_OPTS) $* \ + 'INFO_= $*: ' + + +.PHONY: distcheck +distcheck: distcheck-diffoscope +distcheck: $(_DISTCHECKSRCDIR) $(MK) + $(info $(INFO_)MAKE lint build check install dist) + $(MAKE) $(_MAKE_OPTS) lint build check install dist \ + 'INFO_= distcheck: ' + + +endif # include guard diff --git a/share/mk/dist/check/diffoscope.mk b/share/mk/dist/check/diffoscope.mk new file mode 100644 index 0000000..33bcf30 --- /dev/null +++ b/share/mk/dist/check/diffoscope.mk @@ -0,0 +1,26 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_CHECK_DIFFOSCOPE_INCLUDED +MAKEFILE_DIST_CHECK_DIFFOSCOPE_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/diffoscope.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk +include $(MAKEFILEDIR)/dist/check/dist.mk +include $(MAKEFILEDIR)/dist/tar.mk + + +$(builddir)/distcheck.diffoscope.touch: $(_DISTFILE) $(REDIST) | $$(@D)/ + $(info $(INFO_)DIFFOSCOPE $^) + $(DIFFOSCOPE) $^ + $(TOUCH) $@ + + +.PHONY: distcheck-diffoscope +distcheck-diffoscope: $(builddir)/distcheck.diffoscope.touch; + + +endif # include guard diff --git a/share/mk/dist/check/dist.mk b/share/mk/dist/check/dist.mk new file mode 100644 index 0000000..ecd565b --- /dev/null +++ b/share/mk/dist/check/dist.mk @@ -0,0 +1,28 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_CHECK_DIST_INCLUDED +MAKEFILE_DIST_CHECK_DIST_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/version.mk +include $(MAKEFILEDIR)/dist/check/_.mk +include $(MAKEFILEDIR)/dist/check/tar.mk + + +REDIST := $(_DISTCHECKBUILDDIR)/$(DISTNAME).tar + + +$(REDIST): $(_DISTCHECKSRCDIR) $(MK) | $$(@D)/ + $(info $(INFO_)MAKE dist-tar) + $(MAKE) $(_MAKE_OPTS) dist-tar \ + 'INFO_= dist-tar: ' + + +.PHONY: distcheck-dist-tar +distcheck-dist-tar: $(REDIST); + + +endif # include guard diff --git a/share/mk/dist/check/tar.mk b/share/mk/dist/check/tar.mk new file mode 100644 index 0000000..bd28ce5 --- /dev/null +++ b/share/mk/dist/check/tar.mk @@ -0,0 +1,32 @@ +# Copyright 2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_CHECK_TAR_INCLUDED +MAKEFILE_DIST_CHECK_TAR_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/tar.mk +include $(MAKEFILEDIR)/configure/version.mk +include $(MAKEFILEDIR)/dist/check/_.mk +include $(MAKEFILEDIR)/dist/tar.mk + + +$(_DISTCHECKDIR)/$(DISTFILE): $(_DISTFILE) $(MK) | $$(@D)/ + $(info $(INFO_)CP $@) + $(CP) -T $< $@ + +$(_DISTCHECKSRCDIR): %: %.tar $(MK) | $$(@D)/ + $(info $(INFO_)TAR xf $<) + $(RM) -rf $@ + cd $(dir $<) \ + && $(TAR) xf $(notdir $<) + $(TOUCH) $@ + + +.PHONY: distcheck-tar +distcheck-tar: $(_DISTCHECKSRCDIR); + + +endif # include guard diff --git a/share/mk/dist/files.mk b/share/mk/dist/files.mk new file mode 100644 index 0000000..bc3f7ff --- /dev/null +++ b/share/mk/dist/files.mk @@ -0,0 +1,62 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_FILES_INCLUDED +MAKEFILE_DIST_FILES_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/git.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/verbose.mk +include $(MAKEFILEDIR)/configure/version.mk +include $(MAKEFILEDIR)/dist/_.mk + + +DISTFILES := $(shell $(DISTFILESCMD) | $(SED) 's,:,\\:,g') +_DISTFILES := $(patsubst $(srcdir)/%,$(_DISTDIR)/%,$(DISTFILES)) +_DISTPAGES := $(filter $(_DISTDIR)/man%,$(_DISTFILES)) +_DISTVERSION := $(_DISTDIR)/share/mk/configure/version.mk +_DISTOTHERS := $(filter-out $(_DISTPAGES) $(_DISTVERSION), $(_DISTFILES)) + + +FORCE_DISTVERSION := \ + $(shell \ + if $(TEST) -f $(_DISTVERSION); then \ + <$(_DISTVERSION) \ + $(GREP) \ + -e '^DISTVERSION :=' \ + -e '^DISTNAME :=' \ + -e '^DISTDATE :=' \ + | $(SED) '/^DISTVERSION := $(DISTVERSION)$$/d' \ + | $(SED) '/^DISTNAME := $(DISTNAME)$$/d' \ + | $(SED) '/^DISTDATE := $(DISTDATE)$$/d' \ + | $(GREP) ^ $(HIDE_ERR) >&2 \ + && $(ECHO) FORCE; \ + fi; \ + ) + + +$(_DISTPAGES): $(_DISTDIR)/man%: $(srcdir)/man% $(MK) | $$(@D)/ + $(info $(INFO_)SED $@) + <$< \ + $(SED) "/^.TH/s/(date)/$$($(GIT) log --format=%cs -1 -- $< $(HIDE_ERR))/" \ + | $(SED) '/^.TH/s/(unreleased)/$(DISTVERSION)/' \ + | $(INSTALL_DATA) -T /dev/stdin $@ + +$(_DISTVERSION): $(MAKEFILEDIR)/configure/version.mk $(MK) $(FORCE_DISTVERSION) | $$(@D)/ + $(info $(INFO_)SED $@) + <$< \ + $(SED) 's/^DISTVERSION *:=.*/DISTVERSION := $(DISTVERSION)/' \ + | $(SED) 's/^DISTNAME *:=.*/DISTNAME := $(DISTNAME)/' \ + | $(SED) 's/^DISTDATE *:=.*/DISTDATE := $(DISTDATE)/' \ + | $(INSTALL_DATA) -T /dev/stdin $@ + +$(_DISTOTHERS): $(_DISTDIR)/%: $(srcdir)/% $(MK) | $$(@D)/ + $(info $(INFO_)CP $@) + $(CP) -dT $< $@ + + +endif # include guard diff --git a/share/mk/dist/tar.mk b/share/mk/dist/tar.mk new file mode 100644 index 0000000..a87557f --- /dev/null +++ b/share/mk/dist/tar.mk @@ -0,0 +1,37 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_TAR_INCLUDED +MAKEFILE_DIST_TAR_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/findutils.mk +include $(MAKEFILEDIR)/configure/build-depends/git.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/build-depends/tar.mk +include $(MAKEFILEDIR)/configure/version.mk +include $(MAKEFILEDIR)/dist/_.mk +include $(MAKEFILEDIR)/dist/files.mk + + +DISTFILE := $(DISTNAME).tar +_DISTFILE := $(builddir)/$(DISTFILE) + + +$(_DISTFILE): $(_DISTFILES) $(MK) | $$(@D)/ + $(info $(INFO_)TAR $@) + $(TAR) $(TARFLAGS) -cf $@ -T /dev/null + $(DISTFILESCMD) \ + | $(SED) 's,^$(srcdir)/,$(_DISTDIR)/,' \ + | $(SORT) \ + | $(XARGS) $(TAR) $(TARFLAGS) -rf $@ -C $(srcdir) \ + --transform 's,^$(patsubst /%,%,$(_DISTDIR)),$(DISTNAME),' + + +.PHONY: dist-tar +dist-tar: $(_DISTFILE); + + +endif # include guard diff --git a/share/mk/dist/z.mk b/share/mk/dist/z.mk new file mode 100644 index 0000000..b4b34fc --- /dev/null +++ b/share/mk/dist/z.mk @@ -0,0 +1,44 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_DIST_Z_INCLUDED +MAKEFILE_DIST_Z_INCLUDED := 1 + + +include $(MAKEFILEDIR)/configure/build-depends/bzip2.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/gzip.mk +include $(MAKEFILEDIR)/configure/build-depends/lzip.mk +include $(MAKEFILEDIR)/configure/build-depends/xz-utils.mk +include $(MAKEFILEDIR)/dist/tar.mk + + +compression := bz2 gz lz xz + + +define _DISTFILE_z_rule +$(_DISTFILE).$(2): %.$(2): % $(MK) | $$$$(@D)/ + $$(info $(INFO_)$(1) $$@) + $($(1)) $($(1)FLAGS) -kf $$< + $(TOUCH) $$@ +endef + + +$(eval $(call _DISTFILE_z_rule,BZIP2,bz2)) +$(eval $(call _DISTFILE_z_rule,GZIP,gz)) +$(eval $(call _DISTFILE_z_rule,LZIP,lz)) +$(eval $(call _DISTFILE_z_rule,XZ,xz)) + + +$(foreach z, $(compression), \ + $(eval .PHONY: dist-z-$(z))) +$(foreach z, $(compression), \ + $(eval dist-z-$(z): $(_DISTFILE).$(z);)) + + +.PHONY: dist-z +dist-z: $(foreach z, $(compression), dist-z-$(z)); + + +endif # include guard diff --git a/share/mk/install/_.mk b/share/mk/install/_.mk index 751ab97..bb39de3 100644 --- a/share/mk/install/_.mk +++ b/share/mk/install/_.mk @@ -1,29 +1,20 @@ -######################################################################## -# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception ifndef MAKEFILE_INSTALL_INCLUDED MAKEFILE_INSTALL_INCLUDED := 1 -include $(MAKEFILEDIR)/cmd.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk -DESTDIR := -prefix := /usr/local - -datarootdir := $(prefix)/share -docdir := $(datarootdir)/doc - - -$(DESTDIR)%/: - +$(info INSTALL $@) +%/: + +$(info $(INFO_)MKDIR $@) +$(INSTALL_DIR) $@ %-rm: - $(info RM $*) + $(info $(INFO_)RM $*) $(RM) $* diff --git a/share/mk/install/html.mk b/share/mk/install/html.mk index 97e00ce..047df90 100644 --- a/share/mk/install/html.mk +++ b/share/mk/install/html.mk @@ -1,28 +1,27 @@ -######################################################################## -# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception ifndef MAKEFILE_INSTALL_HTML_INCLUDED MAKEFILE_INSTALL_HTML_INCLUDED := 1 -include $(MAKEFILEDIR)/build/html.mk +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/html/post-grohtml.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk include $(MAKEFILEDIR)/install/_.mk -htmldir := $(docdir) -htmldir_ := $(htmldir)/man -_htmldir := $(DESTDIR)$(htmldir_) +_htmldir := $(DESTDIR)$(htmldir) -_htmlpages := $(patsubst $(_HTMLDIR)/%,$(_htmldir)/%,$(_HTMLPAGES)) +_htmlpages := $(patsubst $(_MANDIR)/%,$(_htmldir)/%,$(_HTMLMAN)) _htmlpages_rm := $(addsuffix -rm,$(wildcard $(_htmlpages))) -$(_htmlpages): $(_htmldir)/%: $(_HTMLDIR)/% | $$(@D)/ - $(info INSTALL $@) +$(_htmlpages): $(_htmldir)/%: $(_MANDIR)/% $(MK) | $$(@D)/ + $(info $(INFO_)INSTALL $@) $(INSTALL_DATA) -T $< $@ diff --git a/share/mk/install/man.mk b/share/mk/install/man.mk index a135788..65c1ea5 100644 --- a/share/mk/install/man.mk +++ b/share/mk/install/man.mk @@ -1,139 +1,60 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception ifndef MAKEFILE_INSTALL_MAN_INCLUDED MAKEFILE_INSTALL_MAN_INCLUDED := 1 -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/compress.mk +include $(MAKEFILEDIR)/configure/build-depends/bzip2.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/findutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/gzip.mk +include $(MAKEFILEDIR)/configure/build-depends/lzip.mk +include $(MAKEFILEDIR)/configure/build-depends/moreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/build-depends/xz-utils.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk +include $(MAKEFILEDIR)/configure/z.mk include $(MAKEFILEDIR)/install/_.mk include $(MAKEFILEDIR)/src.mk -LINK_PAGES := .so -ifeq ($(LINK_PAGES),.so) -else ifeq ($(LINK_PAGES),symlink) -else -$(warning "LINK_PAGES": "$(LINK_PAGES)") -$(error Valid values for "LINK_PAGES": [".so", "symlink"]) -endif +_mandir := $(DESTDIR)$(mandir) +$(foreach s, $(MANSECTIONS), \ + $(eval _man$(s)dir := $(DESTDIR)$(man$(s)dir))) + +$(foreach s, $(MANSECTIONS), \ + $(eval _man$(s)pages := \ + $(patsubst $(MAN$(s)DIR)/%.$(s), $(_man$(s)dir)/%$(man$(s)ext)$(Z), \ + $(MAN$(s)PAGES)))) +$(foreach s, $(MANSECTIONS), \ + $(eval _man$(s)intropage := \ + $(patsubst $(MAN$(s)DIR)/%.$(s), $(_man$(s)dir)/%$(man$(s)ext)$(Z), \ + $(MAN$(s)INTROPAGE)))) +_manintropages := $(foreach s, $(MANSECTIONS), $(_man$(s)intropage)) +_manpages := $(_manintropages) $(foreach s, $(MANSECTIONS), $(_man$(s)pages)) + +_manintropages_rm := $(addsuffix -rm, $(wildcard $(_manintropages))) +$(foreach s, $(MANSECTIONS), \ + $(eval _man$(s)pages_rm := \ + $(addsuffix -rm, \ + $(wildcard $(_man$(s)pages))))) -mandir := $(datarootdir)/man -man1dir := $(mandir)/man1 -man2dir := $(mandir)/man2 -man2typedir := $(mandir)/man2type -man3dir := $(mandir)/man3 -man3constdir:= $(mandir)/man3const -man3headdir := $(mandir)/man3head -man3typedir := $(mandir)/man3type -man4dir := $(mandir)/man4 -man5dir := $(mandir)/man5 -man6dir := $(mandir)/man6 -man7dir := $(mandir)/man7 -man8dir := $(mandir)/man8 -man1ext := .1$(Z) -man2ext := .2$(Z) -man2typeext := .2type$(Z) -man3ext := .3$(Z) -man3constext:= .3const$(Z) -man3headext := .3head$(Z) -man3typeext := .3type$(Z) -man4ext := .4$(Z) -man5ext := .5$(Z) -man6ext := .6$(Z) -man7ext := .7$(Z) -man8ext := .8$(Z) - - -_mandir := $(DESTDIR)$(mandir) -_man1dir := $(DESTDIR)$(man1dir) -_man2dir := $(DESTDIR)$(man2dir) -_man2typedir := $(DESTDIR)$(man2typedir) -_man3dir := $(DESTDIR)$(man3dir) -_man3constdir := $(DESTDIR)$(man3constdir) -_man3headdir := $(DESTDIR)$(man3headdir) -_man3typedir := $(DESTDIR)$(man3typedir) -_man4dir := $(DESTDIR)$(man4dir) -_man5dir := $(DESTDIR)$(man5dir) -_man6dir := $(DESTDIR)$(man6dir) -_man7dir := $(DESTDIR)$(man7dir) -_man8dir := $(DESTDIR)$(man8dir) - -_man1pages := $(patsubst $(MANDIR)/man1/%,$(_man1dir)/%$(Z),$(MAN1PAGES)) -_man2pages := $(patsubst $(MANDIR)/man2/%,$(_man2dir)/%$(Z),$(MAN2PAGES)) -_man2typepages := $(patsubst $(MANDIR)/man2type/%,$(_man2typedir)/%$(Z),$(MAN2TYPEPAGES)) -_man3pages := $(patsubst $(MANDIR)/man3/%,$(_man3dir)/%$(Z),$(MAN3PAGES)) -_man3constpages := $(patsubst $(MANDIR)/man3const/%,$(_man3constdir)/%$(Z),$(MAN3CONSTPAGES)) -_man3headpages := $(patsubst $(MANDIR)/man3head/%,$(_man3headdir)/%$(Z),$(MAN3HEADPAGES)) -_man3typepages := $(patsubst $(MANDIR)/man3type/%,$(_man3typedir)/%$(Z),$(MAN3TYPEPAGES)) -_man4pages := $(patsubst $(MANDIR)/man4/%,$(_man4dir)/%$(Z),$(MAN4PAGES)) -_man5pages := $(patsubst $(MANDIR)/man5/%,$(_man5dir)/%$(Z),$(MAN5PAGES)) -_man6pages := $(patsubst $(MANDIR)/man6/%,$(_man6dir)/%$(Z),$(MAN6PAGES)) -_man7pages := $(patsubst $(MANDIR)/man7/%,$(_man7dir)/%$(Z),$(MAN7PAGES)) -_man8pages := $(patsubst $(MANDIR)/man8/%,$(_man8dir)/%$(Z),$(MAN8PAGES)) -_manpages := $(_man1pages) \ - $(_man2pages) $(_man2typepages) \ - $(_man3pages) $(_man3constpages) $(_man3headpages) $(_man3typepages) \ - $(_man4pages) \ - $(_man5pages) \ - $(_man6pages) \ - $(_man7pages) \ - $(_man8pages) - -_man1pages_rm := $(addsuffix -rm,$(wildcard $(_man1pages))) -_man2pages_rm := $(addsuffix -rm,$(wildcard $(_man2pages))) -_man2typepages_rm := $(addsuffix -rm,$(wildcard $(_man2typepages))) -_man3pages_rm := $(addsuffix -rm,$(wildcard $(_man3pages))) -_man3constpages_rm:= $(addsuffix -rm,$(wildcard $(_man3constpages))) -_man3headpages_rm := $(addsuffix -rm,$(wildcard $(_man3headpages))) -_man3typepages_rm := $(addsuffix -rm,$(wildcard $(_man3typepages))) -_man4pages_rm := $(addsuffix -rm,$(wildcard $(_man4pages))) -_man5pages_rm := $(addsuffix -rm,$(wildcard $(_man5pages))) -_man6pages_rm := $(addsuffix -rm,$(wildcard $(_man6pages))) -_man7pages_rm := $(addsuffix -rm,$(wildcard $(_man7pages))) -_man8pages_rm := $(addsuffix -rm,$(wildcard $(_man8pages))) - -MAN_SECTIONS := 1 2 2type 3 3const 3head 3type 4 5 6 7 8 -install_manX := $(foreach x,$(MAN_SECTIONS),install-man$(x)) -uninstall_manX := $(foreach x,$(MAN_SECTIONS),uninstall-man$(x)) - - -$(_man1pages): $(_man1dir)/%$(Z): $(MANDIR)/man1/% | $$(@D)/ -$(_man2pages): $(_man2dir)/%$(Z): $(MANDIR)/man2/% | $$(@D)/ -$(_man2typepages): $(_man2typedir)/%$(Z): $(MANDIR)/man2type/% | $$(@D)/ -$(_man3pages): $(_man3dir)/%$(Z): $(MANDIR)/man3/% | $$(@D)/ -$(_man3constpages): $(_man3constdir)/%$(Z): $(MANDIR)/man3const/% | $$(@D)/ -$(_man3headpages): $(_man3headdir)/%$(Z): $(MANDIR)/man3head/% | $$(@D)/ -$(_man3typepages): $(_man3typedir)/%$(Z): $(MANDIR)/man3type/% | $$(@D)/ -$(_man4pages): $(_man4dir)/%$(Z): $(MANDIR)/man4/% | $$(@D)/ -$(_man5pages): $(_man5dir)/%$(Z): $(MANDIR)/man5/% | $$(@D)/ -$(_man6pages): $(_man6dir)/%$(Z): $(MANDIR)/man6/% | $$(@D)/ -$(_man7pages): $(_man7dir)/%$(Z): $(MANDIR)/man7/% | $$(@D)/ -$(_man8pages): $(_man8dir)/%$(Z): $(MANDIR)/man8/% | $$(@D)/ +$(foreach s, $(MANSECTIONS), \ + $(eval $(_man$(s)pages) $(_man$(s)intropage): \ + $(_man$(s)dir)/%$(man$(s)ext)$(Z): \ + $(MAN$(s)DIR)/%.$(s) $(MK) | $$$$(@D)/)) $(_manpages): - $(info INSTALL $@) - $(INSTALL_DATA) -T $< $@ - $(SED) -i \ - -e '/^\.so /s, man1/\(.*\)\.1$$, $(notdir $(man1dir))/\1$(man1ext),' \ - -e '/^\.so /s, man2/\(.*\)\.2$$, $(notdir $(man2dir))/\1$(man2ext),' \ - -e '/^\.so /s, man2type/\(.*\)\.2type$$, $(notdir $(man2typedir))/\1$(man2typeext),' \ - -e '/^\.so /s, man3/\(.*\)\.3$$, $(notdir $(man3dir))/\1$(man3ext),' \ - -e '/^\.so /s, man3const/\(.*\)\.3const$$, $(notdir $(man3constdir))/\1$(man3constext),' \ - -e '/^\.so /s, man3head/\(.*\)\.3head$$, $(notdir $(man3headdir))/\1$(man3headext),' \ - -e '/^\.so /s, man3type/\(.*\)\.3type$$, $(notdir $(man3typedir))/\1$(man3typeext),' \ - -e '/^\.so /s, man4/\(.*\)\.4$$, $(notdir $(man4dir))/\1$(man4ext),' \ - -e '/^\.so /s, man5/\(.*\)\.5$$, $(notdir $(man5dir))/\1$(man5ext),' \ - -e '/^\.so /s, man6/\(.*\)\.6$$, $(notdir $(man6dir))/\1$(man6ext),' \ - -e '/^\.so /s, man7/\(.*\)\.7$$, $(notdir $(man7dir))/\1$(man7ext),' \ - -e '/^\.so /s, man8/\(.*\)\.8$$, $(notdir $(man8dir))/\1$(man8ext),' \ - $@ + $(info $(INFO_)INSTALL $@) + <$< \ + $(SED) $(foreach s, $(MANSECTIONS), \ + -e '/^\.so /s, man$(s)/\(.*\)\.$(s)$$, $(notdir $(man$(s)dir))/\1$(man$(s)ext)$(Z),') \ + | $(INSTALL_DATA) -T /dev/stdin $@ ifeq ($(LINK_PAGES),symlink) if $(GREP) '^\.so ' <$@ >/dev/null; then \ $(GREP) '^\.so ' <$@ \ @@ -148,55 +69,39 @@ ifeq ($(Z),.bz2) fi else ifeq ($(Z),.gz) if ! $(TEST) -L $@; then \ - $(GZIP) $(GZIPFLAGS) - <$@ \ + $(GZIP) $(GZIPFLAGS) <$@ \ | $(SPONGE) $@; \ fi else ifeq ($(Z),.lz) if ! $(TEST) -L $@; then \ - $(LZIP) $(LZIPFLAGS) - <$@ \ + $(LZIP) $(LZIPFLAGS) <$@ \ | $(SPONGE) $@; \ fi else ifeq ($(Z),.xz) if ! $(TEST) -L $@; then \ - $(XZ) $(XZFLAGS) - <$@ \ + $(XZ) $(XZFLAGS) <$@ \ | $(SPONGE) $@; \ fi endif -.PHONY: install-man1 -install-man1: $(_man1pages); -.PHONY: install-man2 -install-man2: $(_man2pages); -.PHONY: install-man2type -install-man2type: $(_man2typepages); -.PHONY: install-man3 -install-man3: $(_man3pages); -.PHONY: install-man3const -install-man3const: $(_man3constpages); -.PHONY: install-man3head -install-man3head: $(_man3headpages); -.PHONY: install-man3type -install-man3type: $(_man3typepages); -.PHONY: install-man4 -install-man4: $(_man4pages); -.PHONY: install-man5 -install-man5: $(_man5pages); -.PHONY: install-man6 -install-man6: $(_man6pages); -.PHONY: install-man7 -install-man7: $(_man7pages); -.PHONY: install-man8 -install-man8: $(_man8pages); - +.PHONY: install-manintro +install-manintro: $(_manintropages); +$(foreach s, $(MANSECTIONS), \ + $(eval .PHONY: install-man$(s))) +$(foreach s, $(MANSECTIONS), \ + $(eval install-man$(s): $(_man$(s)pages);)) .PHONY: install-man -install-man: $(install_manX); - -.PHONY: $(uninstall_manX) -$(uninstall_manX): uninstall-man%: $$(_man%pages_rm); - +install-man: install-manintro $(foreach s, $(MANSECTIONS), install-man$(s)); + +.PHONY: uninstall-manintro +uninstall-manintro: $(_manintropages_rm); +$(foreach s, $(MANSECTIONS), \ + $(eval .PHONY: uninstall-man$(s))) +$(foreach s, $(MANSECTIONS), \ + $(eval uninstall-man$(s): $(_man$(s)pages_rm);)) .PHONY: uninstall-man -uninstall-man: $(uninstall_manX); +uninstall-man: uninstall-manintro $(foreach s, $(MANSECTIONS), uninstall-man$(s)); endif # include guard diff --git a/share/mk/lint/_.mk b/share/mk/lint/_.mk index 9d93bd3..48d02fa 100644 --- a/share/mk/lint/_.mk +++ b/share/mk/lint/_.mk @@ -1,18 +1,13 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception ifndef MAKEFILE_LINT_INCLUDED MAKEFILE_LINT_INCLUDED := 1 -lint := lint-c lint-man lint-mdoc - - .PHONY: lint -lint: $(lint); +lint: lint-c lint-man lint-mdoc; endif # include guard diff --git a/share/mk/lint/c.mk b/share/mk/lint/c.mk deleted file mode 100644 index b7d80a9..0000000 --- a/share/mk/lint/c.mk +++ /dev/null @@ -1,102 +0,0 @@ -######################################################################## -# 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/c/_.mk b/share/mk/lint/c/_.mk new file mode 100644 index 0000000..dc2f3e2 --- /dev/null +++ b/share/mk/lint/c/_.mk @@ -0,0 +1,18 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_INCLUDED +MAKEFILE_LINT_C_INCLUDED := 1 + + +.PHONY: lint-c +lint-c: \ + lint-c-checkpatch \ + lint-c-clang-tidy \ + lint-c-cppcheck \ + lint-c-cpplint \ + lint-c-iwyu + + +endif # include guard diff --git a/share/mk/lint/c/checkpatch.mk b/share/mk/lint/c/checkpatch.mk new file mode 100644 index 0000000..7777a10 --- /dev/null +++ b/share/mk/lint/c/checkpatch.mk @@ -0,0 +1,35 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_CHECKPATCH_INCLUDED +MAKEFILE_LINT_C_CHECKPATCH_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/checkpatch.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_LINT_c_checkpatch := $(_MANDIR)/man2/bpf.2.d/bpf.lint-c.checkpatch.touch + + +_LINT_c_checkpatch := $(patsubst %.c, %.lint-c.checkpatch.touch, $(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_c_checkpatch := $(filter-out $(_XFAIL_LINT_c_checkpatch), $(_LINT_c_checkpatch)) +endif + + +$(_LINT_c_checkpatch): %.lint-c.checkpatch.touch: %.c $(CHECKPATCH_CONF) $(MK) + $(info $(INFO_)CHECKPATCH $@) + $(CHECKPATCH) $(CHECKPATCHFLAGS) -f $< >&2 + $(TOUCH) $@ + + +.PHONY: lint-c-checkpatch +lint-c-checkpatch: $(_LINT_c_checkpatch); + + +endif # include guard diff --git a/share/mk/lint/c/clang-tidy.mk b/share/mk/lint/c/clang-tidy.mk new file mode 100644 index 0000000..fd2e536 --- /dev/null +++ b/share/mk/lint/c/clang-tidy.mk @@ -0,0 +1,188 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_CLANG_TIDY_INCLUDED +MAKEFILE_LINT_C_CLANG_TIDY_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/clang.mk +include $(MAKEFILEDIR)/configure/build-depends/clang-tidy.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/cpp.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_LINT_c_clang_tidy := \ + $(_MANDIR)/man2/add_key.2.d/add_key.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/bpf.2.d/bpf.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/chown.2.d/chown.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/clone.2.d/clone.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/close_range.2.d/close_range.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/copy_file_range.2.d/copy_file_range.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/eventfd.2.d/eventfd.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/execve.2.d/execve.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/execve.2.d/myecho.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/futex.2.d/futex.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/getdents.2.d/getdents.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/getrlimit.2.d/getrlimit.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_fat.2.d/display_fat_volume_id.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_fat.2.d/ioctl_fat.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_fat.2.d/toggle_fat_archive_flag.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_ns.2.d/ns_show.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/ioctl_tty.2.d/tcgets.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/kcmp.2.d/kcmp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/keyctl.2.d/key_instantiate.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/listxattr.2.d/listxattr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/membarrier.2.d/membarrier.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/memfd_create.2.d/t_get_seals.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/memfd_create.2.d/t_memfd_create.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/mmap.2.d/mmap.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/mount_setattr.2.d/mount_setattr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/mprotect.2.d/mprotect.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/msgop.2.d/msgop.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/open_by_handle_at.2.d/t_name_to_handle_at.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/open_by_handle_at.2.d/t_open_by_handle_at.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/perf_event_open.2.d/perf_event_open.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/pidfd_open.2.d/pidfd_open.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/pidfd_send_signal.2.d/pidfd_send_signal.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/pipe.2.d/pipe.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/pivot_root.2.d/pivot_root.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/poll.2.d/poll_input.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/process_vm_readv.2.d/process_vm_readv.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/readlink.2.d/readlink.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/recvmmsg.2.d/recvmmsg.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/request_key.2.d/t_request_key.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/sched_setaffinity.2.d/sched_setaffinity.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/seccomp.2.d/seccomp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/seccomp_unotify.2.d/seccomp_unotify.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/select_tut.2.d/select.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/semget.2.d/t_semget.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/sendmmsg.2.d/sendmmsg.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/setns.2.d/setns.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/shmop.2.d/svshm_string_read.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/shmop.2.d/svshm_string_write.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/sigaction.2.d/sigaction.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/spu_run.2.d/spu_run.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/stat.2.d/stat.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/_syscall.2.d/_syscall.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/syscall.2.d/syscall.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/sysctl.2.d/sysctl.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/tee.2.d/tee.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/timer_create.2.d/timer_create.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/timerfd_create.2.d/timerfd_create.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/unshare.2.d/unshare.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/userfaultfd.2.d/userfaultfd.lint-c.clang-tidy.touch \ + $(_MANDIR)/man2/wait.2.d/wait.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/atexit.3.d/atexit.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/backtrace.3.d/backtrace.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/bsearch.3.d/bsearch.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/bswap.3.d/bswap.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/cacos.3.d/cacos.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/cacosh.3.d/cacosh.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/catan.3.d/catan.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/catanh.3.d/catanh.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/circleq.3.d/circleq.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/clock_getcpuclockid.3.d/clock_getcpuclockid.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/CPU_SET.3.d/CPU_SET.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/dlinfo.3.d/dlinfo.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/duplocale.3.d/duplocale.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/encrypt.3.d/encrypt.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/end.3.d/end.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/endian.3.d/endian.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/envz_add.3.d/envz_add.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/fmemopen.3.d/fmemopen.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/fopencookie.3.d/fopencookie.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/fread.3.d/fread.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/frexp.3.d/frexp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/ftw.3.d/ftw.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/_Generic.3.d/_Generic.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getaddrinfo.3.d/client.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getaddrinfo.3.d/server.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getaddrinfo_a.3.d/async.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getaddrinfo_a.3.d/sync.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getdate.3.d/getdate.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getgrent_r.3.d/getgrent_r.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getgrouplist.3.d/getgrouplist.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getline.3.d/getline.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getopt.3.d/getopt.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getopt.3.d/getopt_long.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getprotoent_r.3.d/getprotoent_r.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getpwnam.3.d/getpwnam.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getservent_r.3.d/getservent_r.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getsubopt.3.d/getsubopt.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/getutent.3.d/getutent.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/hsearch.3.d/hsearch.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/if_nameindex.3.d/if_nameindex.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/inet.3.d/inet.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/inet_net_pton.3.d/inet_net_pton.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/inet_pton.3.d/inet_pton.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/insque.3.d/insque.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/list.3.d/list.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mallinfo.3.d/mallinfo.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/malloc_info.3.d/malloc_info.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mallopt.3.d/mallopt.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/matherr.3.d/matherr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/MAX.3.d/MAX.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mbstowcs.3.d/mbstowcs.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mq_getattr.3.d/mq_getattr.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/mq_notify.3.d/mq_notify.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/newlocale.3.d/newlocale.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/offsetof.3.d/offsetof.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/posix_spawn.3.d/posix_spawn.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/__ppc_get_timebase.3.d/__ppc_get_timebase.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_attr_init.3.d/pthread_attr_init.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_cleanup_push.3.d/pthread_cleanup_push.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_create.3.d/pthread_create.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_getattr_np.3.d/pthread_getattr_np.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_setname_np.3.d/pthread_setname_np.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/pthread_setschedparam.3.d/pthreads_sched_test.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/qsort.3.d/qsort.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/rand.3.d/rand.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/rpmatch.3.d/rpmatch.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/rtime.3.d/rtime.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/scandir.3.d/scandir.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/sem_wait.3.d/sem_wait.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/setbuf.3.d/setbuf.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_bounce.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_send.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/slist.3.d/slist.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/stailq.3.d/stailq.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/static_assert.3.d/must_be.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/stpncpy.3.d/stpncpy.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strcmp.3.d/string_comp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strcpy.3.d/strcpy.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strftime.3.d/strftime.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strsep.3.d/strsep.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strtok.3.d/strtok.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strtol.3.d/strtol.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/strverscmp.3.d/strverscmp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/tailq.3.d/tailq.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/tsearch.3.d/tsearch.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3/wordexp.3.d/wordexp.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3const/EXIT_SUCCESS.3const.d/EXIT_SUCCESS.lint-c.clang-tidy.touch \ + $(_MANDIR)/man3head/printf.h.3head.d/register_printf_specifier.lint-c.clang-tidy.touch + + +_LINT_c_clang_tidy := $(patsubst %.c, %.lint-c.clang-tidy.touch, $(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_c_clang_tidy := $(filter-out $(_XFAIL_LINT_c_clang_tidy), $(_LINT_c_clang_tidy)) +endif + + +$(_LINT_c_clang_tidy): %.lint-c.clang-tidy.touch: %.c $(CLANG_TIDY_CONF) $(MK) + $(info $(INFO_)CLANG_TIDY $@) + $(CLANG_TIDY) $(CLANG_TIDYFLAGS) $< -- $(CPPFLAGS) $(CLANGFLAGS) 2>&1 \ + | $(SED) '/generated\.$$/d' >&2 + $(TOUCH) $@ + + +.PHONY: lint-c-clang-tidy +lint-c-clang-tidy: $(_LINT_c_clang_tidy); + + +endif # include guard diff --git a/share/mk/lint/c/cppcheck.mk b/share/mk/lint/c/cppcheck.mk new file mode 100644 index 0000000..5fa74ac --- /dev/null +++ b/share/mk/lint/c/cppcheck.mk @@ -0,0 +1,74 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_CPPCHECK_INCLUDED +MAKEFILE_LINT_C_CPPCHECK_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/cppcheck.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_LINT_c_cppcheck := \ + $(_MANDIR)/man2/chown.2.d/chown.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/close_range.2.d/close_range.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/kcmp.2.d/kcmp.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/keyctl.2.d/key_instantiate.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/memfd_create.2.d/t_memfd_create.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/msgop.2.d/msgop.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/open_by_handle_at.2.d/t_open_by_handle_at.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/shmop.2.d/svshm_string_read.lint-c.cppcheck.touch \ + $(_MANDIR)/man2/unshare.2.d/unshare.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/bsearch.3.d/bsearch.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/dlopen.3.d/dlopen.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/encrypt.3.d/encrypt.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/envz_add.3.d/envz_add.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/getaddrinfo_a.3.d/async.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/getdate.3.d/getdate.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/getgrouplist.3.d/getgrouplist.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/hsearch.3.d/hsearch.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/malloc_info.3.d/malloc_info.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/mallopt.3.d/mallopt.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/matherr.3.d/matherr.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/mcheck.3.d/mcheck.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/mtrace.3.d/t_mtrace.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/newlocale.3.d/newlocale.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_attr_init.3.d/pthread_attr_init.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_create.3.d/pthread_create.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_getattr_np.3.d/pthread_getattr_np.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_getcpuclockid.3.d/pthread_getcpuclockid.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/pthread_setschedparam.3.d/pthreads_sched_test.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/setaliasent.3.d/setaliasent.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/setbuf.3.d/setbuf.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_send.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/stpncpy.3.d/stpncpy.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strftime.3.d/strftime.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strncat.3.d/strncat.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strsep.3.d/strsep.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strtok.3.d/strtok.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/strtol.3.d/strtol.lint-c.cppcheck.touch \ + $(_MANDIR)/man3/tsearch.3.d/tsearch.lint-c.cppcheck.touch + + +_LINT_c_cppcheck := $(patsubst %.c, %.lint-c.cppcheck.touch, $(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_c_cppcheck := $(filter-out $(_XFAIL_LINT_c_cppcheck), $(_LINT_c_cppcheck)) +endif + + +$(_LINT_c_cppcheck): %.lint-c.cppcheck.touch: %.c $(CPPCHECK_SUPPRESS) $(MK) + $(info $(INFO_)CPPCHECK $@) + $(CPPCHECK) $(CPPCHECKFLAGS) $< + $(TOUCH) $@ + + +.PHONY: lint-c-cppcheck +lint-c-cppcheck: $(_LINT_c_cppcheck); + + +endif # include guard diff --git a/share/mk/lint/c/cpplint.mk b/share/mk/lint/c/cpplint.mk new file mode 100644 index 0000000..8eb3984 --- /dev/null +++ b/share/mk/lint/c/cpplint.mk @@ -0,0 +1,27 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_CPPLINT_INCLUDED +MAKEFILE_LINT_C_CPPLINT_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/cpplint.mk + + +_LINT_c_cpplint := $(patsubst %.c, %.lint-c.cpplint.touch, $(_UNITS_ex_c)) + + +$(_LINT_c_cpplint): %.lint-c.cpplint.touch: %.c $(CPPLINT_CONF) $(MK) + $(info $(INFO_)CPPLINT $@) + $(CPPLINT) $(CPPLINTFLAGS) $< >/dev/null + $(TOUCH) $@ + + +.PHONY: lint-c-cpplint +lint-c-cpplint: $(_LINT_c_cpplint); + + +endif # include guard diff --git a/share/mk/lint/c/iwyu.mk b/share/mk/lint/c/iwyu.mk new file mode 100644 index 0000000..32c2c07 --- /dev/null +++ b/share/mk/lint/c/iwyu.mk @@ -0,0 +1,109 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_C_IWYU_INCLUDED +MAKEFILE_LINT_C_IWYU_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/build/examples/src.mk +include $(MAKEFILEDIR)/configure/build-depends/clang.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/cpp.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/iwyu.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/xfail.mk + + +_XFAIL_LINT_c_iwyu := \ + $(_MANDIR)/man2/clock_getres.2.d/clock_getres.lint-c.iwyu.touch \ + $(_MANDIR)/man2/getrlimit.2.d/getrlimit.lint-c.iwyu.touch \ + $(_MANDIR)/man2/listxattr.2.d/listxattr.lint-c.iwyu.touch \ + $(_MANDIR)/man2/mount_setattr.2.d/mount_setattr.lint-c.iwyu.touch \ + $(_MANDIR)/man2/recvmmsg.2.d/recvmmsg.lint-c.iwyu.touch \ + $(_MANDIR)/man2/seccomp.2.d/seccomp.lint-c.iwyu.touch \ + $(_MANDIR)/man2/seccomp_unotify.2.d/seccomp_unotify.lint-c.iwyu.touch \ + $(_MANDIR)/man2/select.2.d/select.lint-c.iwyu.touch \ + $(_MANDIR)/man2/semget.2.d/t_semget.lint-c.iwyu.touch \ + $(_MANDIR)/man2/sendmmsg.2.d/sendmmsg.lint-c.iwyu.touch \ + $(_MANDIR)/man2/_syscall.2.d/_syscall.lint-c.iwyu.touch \ + $(_MANDIR)/man2/timer_create.2.d/timer_create.lint-c.iwyu.touch \ + $(_MANDIR)/man2/userfaultfd.2.d/userfaultfd.lint-c.iwyu.touch \ + $(_MANDIR)/man3/backtrace.3.d/backtrace.lint-c.iwyu.touch \ + $(_MANDIR)/man3/bsearch.3.d/bsearch.lint-c.iwyu.touch \ + $(_MANDIR)/man3/bswap.3.d/bswap.lint-c.iwyu.touch \ + $(_MANDIR)/man3/cacos.3.d/cacos.lint-c.iwyu.touch \ + $(_MANDIR)/man3/cacosh.3.d/cacosh.lint-c.iwyu.touch \ + $(_MANDIR)/man3/catan.3.d/catan.lint-c.iwyu.touch \ + $(_MANDIR)/man3/catanh.3.d/catanh.lint-c.iwyu.touch \ + $(_MANDIR)/man3/clock_getcpuclockid.3.d/clock_getcpuclockid.lint-c.iwyu.touch \ + $(_MANDIR)/man3/CPU_SET.3.d/CPU_SET.lint-c.iwyu.touch \ + $(_MANDIR)/man3/dl_iterate_phdr.3.d/dl_iterate_phdr.lint-c.iwyu.touch \ + $(_MANDIR)/man3/dlinfo.3.d/dlinfo.lint-c.iwyu.touch \ + $(_MANDIR)/man3/duplocale.3.d/duplocale.lint-c.iwyu.touch \ + $(_MANDIR)/man3/endian.3.d/endian.lint-c.iwyu.touch \ + $(_MANDIR)/man3/envz_add.3.d/envz_add.lint-c.iwyu.touch \ + $(_MANDIR)/man3/fopencookie.3.d/fopencookie.lint-c.iwyu.touch \ + $(_MANDIR)/man3/frexp.3.d/frexp.lint-c.iwyu.touch \ + $(_MANDIR)/man3/ftw.3.d/ftw.lint-c.iwyu.touch \ + $(_MANDIR)/man3/_Generic.3.d/_Generic.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getaddrinfo.3.d/client.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getaddrinfo.3.d/server.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getgrouplist.3.d/getgrouplist.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getline.3.d/getline.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getopt.3.d/getopt_long.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getprotoent_r.3.d/getprotoent_r.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getservent_r.3.d/getservent_r.lint-c.iwyu.touch \ + $(_MANDIR)/man3/getsubopt.3.d/getsubopt.lint-c.iwyu.touch \ + $(_MANDIR)/man3/if_nameindex.3.d/if_nameindex.lint-c.iwyu.touch \ + $(_MANDIR)/man3/inet.3.d/inet.lint-c.iwyu.touch \ + $(_MANDIR)/man3/inet_net_pton.3.d/inet_net_pton.lint-c.iwyu.touch \ + $(_MANDIR)/man3/inet_pton.3.d/inet_pton.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mallinfo.3.d/mallinfo.lint-c.iwyu.touch \ + $(_MANDIR)/man3/malloc_info.3.d/malloc_info.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mbstowcs.3.d/mbstowcs.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mq_getattr.3.d/mq_getattr.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mq_notify.3.d/mq_notify.lint-c.iwyu.touch \ + $(_MANDIR)/man3/mtrace.3.d/t_mtrace.lint-c.iwyu.touch \ + $(_MANDIR)/man3/newlocale.3.d/newlocale.lint-c.iwyu.touch \ + $(_MANDIR)/man3/posix_spawn.3.d/posix_spawn.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_attr_init.3.d/pthread_attr_init.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_cleanup_push.3.d/pthread_cleanup_push.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_getattr_default_np.3.d/pthread_getattr_default_np.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_getattr_np.3.d/pthread_getattr_np.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_getcpuclockid.3.d/pthread_getcpuclockid.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_setaffinity_np.3.d/pthread_setaffinity_np.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_setname_np.3.d/pthread_setname_np.lint-c.iwyu.touch \ + $(_MANDIR)/man3/pthread_setschedparam.3.d/pthreads_sched_test.lint-c.iwyu.touch \ + $(_MANDIR)/man3/sem_wait.3.d/sem_wait.lint-c.iwyu.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_bounce.lint-c.iwyu.touch \ + $(_MANDIR)/man3/shm_open.3.d/pshm_ucase_send.lint-c.iwyu.touch \ + $(_MANDIR)/man3/slist.3.d/slist.lint-c.iwyu.touch + + +_LINT_c_iwyu := $(patsubst %.c, %.lint-c.iwyu.touch, $(_UNITS_ex_c)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_c_iwyu := $(filter-out $(_XFAIL_LINT_c_iwyu), $(_LINT_c_iwyu)) +endif + + +$(_LINT_c_iwyu): %.lint-c.iwyu.touch: %.c $(MK) + $(info $(INFO_)IWYU $@) + ! ($(IWYU) $(IWYUFLAGS) $(CPPFLAGS) $(CLANGFLAGS) $< 2>&1 \ + | $(SED) -n '/should add these lines:/,$$p' \ + | $(TAC) \ + | $(SED) '/correct/{N;d}' \ + | $(TAC) \ + || $(TRUE); \ + ) \ + | $(GREP) ^ >&2 + $(TOUCH) $@ + + +.PHONY: lint-c-iwyu +lint-c-iwyu: $(_LINT_c_iwyu); + + +endif # include guard diff --git a/share/mk/lint/man/_.mk b/share/mk/lint/man/_.mk index 8bbc01c..67ff4b8 100644 --- a/share/mk/lint/man/_.mk +++ b/share/mk/lint/man/_.mk @@ -1,16 +1,13 @@ -######################################################################## -# Copyright 2021-2023, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception ifndef MAKEFILE_LINT_MAN_INCLUDED MAKEFILE_LINT_MAN_INCLUDED := 1 -DEFAULT_MANDOCFLAGS := -Tlint -EXTRA_MANDOCFLAGS := -MANDOCFLAGS := $(DEFAULT_MANDOCFLAGS) $(EXTRA_MANDOCFLAGS) +.PHONY: lint-man +lint-man: lint-man-mandoc lint-man-tbl; endif # include guard diff --git a/share/mk/lint/man/man.mk b/share/mk/lint/man/man.mk deleted file mode 100644 index cb1bf53..0000000 --- a/share/mk/lint/man/man.mk +++ /dev/null @@ -1,69 +0,0 @@ -######################################################################## -# 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/lint/mandoc/man.ignore.grep b/share/mk/lint/man/mandoc.ignore.grep index a2f91bc..a2f91bc 100644 --- a/share/lint/mandoc/man.ignore.grep +++ b/share/mk/lint/man/mandoc.ignore.grep diff --git a/share/mk/lint/man/mandoc.mk b/share/mk/lint/man/mandoc.mk new file mode 100644 index 0000000..efa69ab --- /dev/null +++ b/share/mk/lint/man/mandoc.mk @@ -0,0 +1,53 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_MAN_MANDOC_INCLUDED +MAKEFILE_LINT_MAN_MANDOC_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/mandoc.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/configure/xfail.mk +include $(MAKEFILEDIR)/lint/man/_.mk +include $(MAKEFILEDIR)/src.mk + + +_XFAIL_LINT_man_mandoc := \ + $(_MANDIR)/man3/pthread_cond_init.3.lint-man.mandoc.touch \ + $(_MANDIR)/man3/pthread_key_create.3.lint-man.mandoc.touch \ + $(_MANDIR)/man3/pthread_mutex_init.3.lint-man.mandoc.touch \ + $(_MANDIR)/man5/dir_colors.5.lint-man.mandoc.touch \ + $(_MANDIR)/man7/bpf-helpers.7.lint-man.mandoc.touch \ + $(_MANDIR)/man7/uri.7.lint-man.mandoc.touch \ + $(_MANDIR)/man8/zic.8.lint-man.mandoc.touch + + +_LINT_man_mandoc := \ + $(patsubst $(MANDIR)/%, $(_MANDIR)/%.lint-man.mandoc.touch, $(NONSO_MAN)) +ifeq ($(SKIP_XFAIL),yes) +_LINT_man_mandoc := $(filter-out $(_XFAIL_LINT_man_mandoc), $(_LINT_man_mandoc)) +endif + + +mandoc_man_ignore_grep := $(MAKEFILEDIR)/lint/man/mandoc.ignore.grep + + +$(_LINT_man_mandoc): $(_MANDIR)/%.lint-man.mandoc.touch: $(MANDIR)/% $(mandoc_man_ignore_grep) $(MK) | $$(@D)/ + $(info $(INFO_)MANDOC $@) + ! ($(MANDOC) -man $(MANDOCFLAGS) $< 2>&1 \ + | $(GREP) -v -f '$(mandoc_man_ignore_grep)' \ + || $(TRUE); \ + ) \ + | $(GREP) ^ >&2 + $(TOUCH) $@ + + +.PHONY: lint-man-mandoc +lint-man-mandoc: $(_LINT_man_mandoc); + + +endif # include guard diff --git a/share/mk/lint/man/mdoc.mk b/share/mk/lint/man/mdoc.mk deleted file mode 100644 index 9b5f5b4..0000000 --- a/share/mk/lint/man/mdoc.mk +++ /dev/null @@ -1,44 +0,0 @@ -######################################################################## -# 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 diff --git a/share/mk/lint/man/tbl.mk b/share/mk/lint/man/tbl.mk new file mode 100644 index 0000000..23e6eda --- /dev/null +++ b/share/mk/lint/man/tbl.mk @@ -0,0 +1,48 @@ +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_MAN_TBL_INCLUDED +MAKEFILE_LINT_MAN_TBL_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/src.mk +include $(MAKEFILEDIR)/lint/man/_.mk +include $(MAKEFILEDIR)/src.mk + + +_LINT_man_tbl := \ + $(patsubst $(MANDIR)/%, $(_MANDIR)/%.lint-man.tbl.touch, $(NONSO_MAN)) + + +$(_LINT_man_tbl): $(_MANDIR)/%.lint-man.tbl.touch: $(MANDIR)/% $(MK) | $$(@D)/ + $(info $(INFO_)GREP $@) + 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-tbl +lint-man-tbl: $(_LINT_man_tbl); + + +endif # include guard diff --git a/share/mk/lint/mdoc/_.mk b/share/mk/lint/mdoc/_.mk new file mode 100644 index 0000000..0f51ee2 --- /dev/null +++ b/share/mk/lint/mdoc/_.mk @@ -0,0 +1,31 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_MDOC_INCLUDED +MAKEFILE_LINT_MDOC_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/directory_variables.mk +include $(MAKEFILEDIR)/src.mk + + +linters_mdoc := mandoc + + +$(foreach l, $(linters_mdoc), \ + $(eval _LINT_mdoc_$(l) := \ + $(patsubst $(MANDIR)/%, $(_MANDIR)/%.lint-mdoc.$(l).touch, \ + $(NONSO_MDOC)))) + + +$(foreach l, $(linters_mdoc), \ + $(eval .PHONY: lint-mdoc-$(l))) +$(foreach l, $(linters_mdoc), \ + $(eval lint-mdoc-$(l): $(_LINT_mdoc_$(l));)) +.PHONY: lint-mdoc +lint-mdoc: $(foreach l, $(linters_mdoc), lint-mdoc-$(l)); + + +endif # include guard diff --git a/share/mk/lint/mdoc/mandoc.ignore.grep b/share/mk/lint/mdoc/mandoc.ignore.grep new file mode 100644 index 0000000..4c73c59 --- /dev/null +++ b/share/mk/lint/mdoc/mandoc.ignore.grep @@ -0,0 +1,5 @@ +STYLE: legacy man(7) date format: Dd +STYLE: lower case character in document title: Dt +STYLE: operating system explicitly specified: Os +STYLE: referenced manual not found: Xr +WARNING: cross reference to self: Xr diff --git a/share/mk/lint/mdoc/mandoc.mk b/share/mk/lint/mdoc/mandoc.mk new file mode 100644 index 0000000..8b209b8 --- /dev/null +++ b/share/mk/lint/mdoc/mandoc.mk @@ -0,0 +1,30 @@ +# Copyright 2023-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception + + +ifndef MAKEFILE_LINT_MDOC_MANDOC_INCLUDED +MAKEFILE_LINT_MDOC_MANDOC_INCLUDED := 1 + + +include $(MAKEFILEDIR)/build/_.mk +include $(MAKEFILEDIR)/configure/build-depends/coreutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/mandoc.mk +include $(MAKEFILEDIR)/lint/mdoc/_.mk +include $(MAKEFILEDIR)/src.mk + + +mandoc_mdoc_ignore_grep := $(MAKEFILEDIR)/lint/mdoc/mandoc.ignore.grep + + +$(_LINT_mdoc_mandoc): $(_MANDIR)/%.lint-mdoc.mandoc.touch: $(MANDIR)/% $(mandoc_mdoc_ignore_grep) | $$(@D)/ + $(info $(INFO_)MANDOC $@) + ! ($(MANDOC) -mdoc $(MANDOCFLAGS) $< 2>&1 \ + | $(GREP) -v -f '$(mandoc_mdoc_ignore_grep)' \ + || $(TRUE); \ + ) \ + | $(GREP) ^ >&2 + $(TOUCH) $@ + + +endif # include guard diff --git a/share/mk/src.mk b/share/mk/src.mk index 65825b5..20c0037 100644 --- a/share/mk/src.mk +++ b/share/mk/src.mk @@ -1,37 +1,62 @@ -######################################################################## -# Copyright 2021-2022, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## +# Copyright 2021-2024, Alejandro Colomar <alx@kernel.org> +# SPDX-License-Identifier: LGPL-3.0-only WITH LGPL-3.0-linking-exception ifndef MAKEFILE_SRC_INCLUDED MAKEFILE_SRC_INCLUDED := 1 -include $(MAKEFILEDIR)/cmd.mk +include $(MAKEFILEDIR)/configure/build-depends/findutils.mk +include $(MAKEFILEDIR)/configure/build-depends/grep.mk +include $(MAKEFILEDIR)/configure/build-depends/sed.mk +include $(MAKEFILEDIR)/configure/src.mk -MANDIR := $(srcdir) -MANEXT := \.[0-9]\w*\(\.man\)\?\(\.in\)\?$ +SORTMAN := $(srcdir)/scripts/sortman + + +MANEXT := \(\.[[:digit:]]\([[:alpha:]][[:alnum:]]*\)\?\>\|\.man\)\+\(\.man\|\.in\)*$ MANPAGES := $(shell $(FIND) $(MANDIR)/* -type f \ | $(GREP) '$(MANEXT)' \ - | $(SORT) \ + | $(SORTMAN) \ | $(SED) 's,:,\\:,g') -MAN1PAGES := $(filter $(MANDIR)/man1/%,$(filter %.1,$(MANPAGES))) -MAN2PAGES := $(filter $(MANDIR)/man2/%,$(filter %.2,$(MANPAGES))) -MAN2TYPEPAGES := $(filter $(MANDIR)/man2type/%,$(filter %.2type,$(MANPAGES))) -MAN3PAGES := $(filter $(MANDIR)/man3/%,$(filter %.3,$(MANPAGES))) -MAN3CONSTPAGES := $(filter $(MANDIR)/man3const/%,$(filter %.3const,$(MANPAGES))) -MAN3HEADPAGES := $(filter $(MANDIR)/man3head/%,$(filter %.3head,$(MANPAGES))) -MAN3TYPEPAGES := $(filter $(MANDIR)/man3type/%,$(filter %.3type,$(MANPAGES))) -MAN4PAGES := $(filter $(MANDIR)/man4/%,$(filter %.4,$(MANPAGES))) -MAN5PAGES := $(filter $(MANDIR)/man5/%,$(filter %.5,$(MANPAGES))) -MAN6PAGES := $(filter $(MANDIR)/man6/%,$(filter %.6,$(MANPAGES))) -MAN7PAGES := $(filter $(MANDIR)/man7/%,$(filter %.7,$(MANPAGES))) -MAN8PAGES := $(filter $(MANDIR)/man8/%,$(filter %.8,$(MANPAGES))) + +MANINTROPAGES := $(shell $(FIND) $(MANDIR)/* -type f \ + | $(GREP) '$(MANEXT)' \ + | $(GREP) '/intro$(MANEXT)' \ + | $(SORTMAN) \ + | $(SED) 's,:,\\:,g') + + +$(foreach s, $(MANSECTIONS), \ + $(eval MAN$(s)DIR := $(MANDIR)/man$(s))) + +$(foreach s, $(MANSECTIONS), \ + $(eval MAN$(s)PAGES := \ + $(filter-out $(MANINTROPAGES), \ + $(filter $(MANDIR)/man$(s)/%, \ + $(filter %.$(s), \ + $(MANPAGES)))))) +$(foreach s, $(MANSECTIONS), \ + $(eval MAN$(s)INTROPAGE := \ + $(filter $(MANDIR)/man$(s)/%, \ + $(filter %.$(s), \ + $(MANINTROPAGES))))) + + +NONSO_MAN := $(shell $(FIND) $(MANDIR)/* -type f \ + | $(GREP) '$(MANEXT)' \ + | $(XARGS) $(GREP) -l '^\.TH ' \ + | $(SORTMAN) \ + | $(SED) 's,:,\\:,g') +NONSO_MDOC := $(shell $(FIND) $(MANDIR)/* -type f \ + | $(GREP) '$(MANEXT)' \ + | $(XARGS) $(GREP) -l '^\.Dt ' \ + | $(SORTMAN) \ + | $(SED) 's,:,\\:,g') endif # include guard diff --git a/share/mk/verbose.mk b/share/mk/verbose.mk deleted file mode 100644 index 2cc4450..0000000 --- a/share/mk/verbose.mk +++ /dev/null @@ -1,19 +0,0 @@ -######################################################################## -# Copyright 2022, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_VERBOSE_INCLUDED -MAKEFILE_VERBOSE_INCLUDED := 1 - - -ifdef V -HIDE_ERR := -else -HIDE_ERR := 2>/dev/null -.SILENT: -endif - - -endif # include guard diff --git a/share/mk/version.mk b/share/mk/version.mk deleted file mode 100644 index af3c0cb..0000000 --- a/share/mk/version.mk +++ /dev/null @@ -1,20 +0,0 @@ -######################################################################## -# Copyright 2022, Alejandro Colomar <alx@kernel.org> -# SPDX-License-Identifier: GPL-3.0-or-later -######################################################################## - - -ifndef MAKEFILE_VERSION_INCLUDED -MAKEFILE_VERSION_INCLUDED := 1 - - -include $(MAKEFILEDIR)/cmd.mk -include $(MAKEFILEDIR)/verbose.mk - - -DISTNAME := $(shell $(GIT) describe $(HIDE_ERR)) -DISTVERSION := $(patsubst man-pages-%,%,$(DISTNAME)) -DISTDATE := $(shell $(GIT) log -1 --format='%aD') - - -endif # include guard |