@@ -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
@@ -1,22 +1,70 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2017-2021 Bartosz Golaszewski <bartekgola@gmail.com>
+# SPDX-FileCopyrightText: 2025 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
-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