From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> Extend the build files under man/ to also generate man pages for gpio-manager, gpiocli and each of the former's sub-commands. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> --- Makefile.am | 8 ++++++- man/Makefile.am | 72 +++++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 67 insertions(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index c824dc4..d310e17 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ endif if WITH_TOOLS -SUBDIRS += tools man +SUBDIRS += tools endif @@ -44,6 +44,12 @@ SUBDIRS += dbus endif +if WITH_MANPAGES + +SUBDIRS += man + +endif + if HAS_DOXYGEN doc: Doxyfile diff --git a/man/Makefile.am b/man/Makefile.am index ddd0628..8d8bc46 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,22 +1,70 @@ # SPDX-License-Identifier: GPL-2.0-or-later # SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@xxxxxxxxx> +# SPDX-FileCopyrightText: 2025 Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx> -if WITH_MANPAGES +MAN_ENTRIES = +MAN_DEPS = -dist_man1_MANS = \ - gpiodetect.man \ - gpioinfo.man \ - gpioget.man \ - gpioset.man \ - gpiomon.man \ - gpionotify.man +if WITH_TOOLS -%.man: $(top_builddir)/tools/$(*F) - $(AM_V_GEN)help2man $(top_builddir)/tools/$(*F) --include=$(srcdir)/template --output=$(builddir)/$@ --no-info +TOOLS = \ + gpiodetect \ + gpioinfo \ + gpioget \ + gpioset \ + gpiomon \ + gpionotify + +MAN_ENTRIES += $(TOOLS) +MAN_DEPS += $(foreach dep,$(TOOLS),$(top_builddir)/tools/$(dep)) + +endif + +if WITH_DBUS + +GPIOCLI_CMDS = \ + detect \ + find \ + info \ + get \ + monitor \ + notify \ + reconfigure \ + release \ + request \ + requests \ + set \ + wait + +MAN_ENTRIES += \ + gpio-manager \ + gpiocli \ + $(foreach cmd,$(GPIOCLI_CMDS),gpiocli-$(cmd)) + +MAN_DEPS += \ + $(top_builddir)/dbus/manager/gpio-manager + $(top_builddir)/dbus/client/gpiocli + +endif + +dist_man1_MANS := $(foreach entry,$(MAN_ENTRIES),$(entry).man) + +%.man: $(MAN_DEPS) + $(AM_V_GEN)export PATH=$(top_builddir)/dbus/manager/:$(top_builddir)/dbus/client/:$(top_builddir)/tools/:$$PATH; \ + if [ "$(*F)" = "gpio-manager" ]; then \ + EXEC=$(*F); \ + NAME="libgpiod D-Bus daemon"; \ + HELP=--help-option=--help; \ + else \ + EXEC=$(if $(findstring -,$(*F)),$(word 1,$(subst -, ,$(*F))),$(*F)); \ + NAME=$(if $(findstring -,$(*F)),$(word 2,$(subst -, ,$(*F))),"libgpiod command-line utility"); \ + HELP=$(if $(findstring -,$(*F)),--help-option="$(word 2,$(subst -, ,$(*F))) --help",--help-option=--help); \ + fi; \ + help2man $$EXEC \ + --include=$(srcdir)/template --output=$(builddir)/$@ --no-info \ + --name="$$NAME" "$$HELP" --manual=$(*F) clean-local: rm -f $(dist_man1_MANS) -endif - EXTRA_DIST = template -- 2.45.2