From c0d9ce265c6ca627039845d9544ebbdf87a00f7f Mon Sep 17 00:00:00 2001
From: Timo Kokkonen <timo.t.kokkonen@iki.fi>
Date: Mon, 11 Jul 2022 20:41:12 +0300
Subject: [PATCH] docs: man: upsd: Fix driver list when building only some of
 drivers

There are two issues that come up in man page generation when only
some of the drivers are built.

First is that during configure phase DRIVER_MAN_LIST is collected by
searching any .8 files matching the driver names. This does not work
very well as during the first configure call these files don't exist
yet as none of them are compiled yet. Searching the .txt files where
they are built from works better.

Second issue is that SRC_DRIVERS_PAGES list needs to contain the
source files where the driver list is generated from. If only some
drivers are built, this needs to be populated from the list of files
we collected to DRIVER_MAN_LIST during configure phase.

Adding these entries will ensure manpage generation will not fail if
only some of the drivers are built

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
---
 configure.ac         | 4 ++--
 docs/man/Makefile.am | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3aa26c24e..a49ca4417 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1745,8 +1745,8 @@ if test "${WITH_MANS}" = "yes"; then
 	else
 		DRIVER_MAN_LIST=""
 		for i in ${DRIVER_BUILD_LIST}; do
-			if test -f ${srcdir}/docs/man/$i.8; then
-				DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.8"
+			if test -f ${srcdir}/docs/man/$i.txt; then
+				DRIVER_MAN_LIST="${DRIVER_MAN_LIST} $i.txt"
 			fi
 		done
 		AC_MSG_RESULT(${DRIVER_MAN_LIST})
diff --git a/docs/man/Makefile.am b/docs/man/Makefile.am
index 0d693a355..a7345264b 100644
--- a/docs/man/Makefile.am
+++ b/docs/man/Makefile.am
@@ -695,6 +695,12 @@ SRC_DRIVERS_PAGES = \
 	$(SRC_MODBUS_PAGES) \
 	$(SRC_LINUX_I2C_PAGES)
 
+if SOME_DRIVERS
+SRC_DRIVERS_PAGES += \
+	$(DRIVER_MAN_LIST)
+endif
+
+
 # distribute everything, even those not installed by default
 # Note that 'dist' target requires AsciiDoc!
 SRC_ALL_PAGES = \
-- 
2.35.1

