summaryrefslogtreecommitdiffstats
path: root/share/mk/src.mk
diff options
context:
space:
mode:
Diffstat (limited to 'share/mk/src.mk')
-rw-r--r--share/mk/src.mk65
1 files changed, 45 insertions, 20 deletions
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