From ce629be41795a2501cbe0df3a4d5062c46afe7aa Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 22 May 2025 19:12:32 +0300
Subject: [PATCH 65/65] Doxygen: Include generated sources from builddir

See RM #1423

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 doc/freeciv.doxygen     | 38 ++++++++++++++++++++++++++++++--------
 scripts/generate_doc.sh | 14 ++++++++++----
 2 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/doc/freeciv.doxygen b/doc/freeciv.doxygen
index abc249cc28..46b039028d 100644
--- a/doc/freeciv.doxygen
+++ b/doc/freeciv.doxygen
@@ -933,13 +933,35 @@ WARN_LOGFILE           =
 # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = $(doxy_srcdir)utility \
-                         $(doxy_srcdir)common \
-                         $(doxy_srcdir)server \
-                         $(doxy_srcdir)client \
-                         $(doxy_srcdir)ai \
-                         $(doxy_srcdir)tools \
-                         $(doxy_srcdir)doc/doxygen.md
+INPUT                  = $(doxy_srcdir)/utility \
+                         $(doxy_srcdir)/common \
+                         $(doxy_srcdir)/server \
+                         $(doxy_srcdir)/client \
+                         $(doxy_srcdir)/ai \
+                         $(doxy_srcdir)/tools \
+                         $(doxy_builddir)/actions_enums_gen.h \
+                         $(doxy_builddir)/city_enums_gen.h \
+                         $(doxy_builddir)/effects_enums_gen.h \
+                         $(doxy_builddir)/fc_types_enums_gen.h \
+                         $(doxy_builddir)/hand_gen.c \
+                         $(doxy_builddir)/hand_gen.h \
+                         $(doxy_builddir)/manual_enums_gen.h \
+                         $(doxy_builddir)/packets_gen.c \
+                         $(doxy_builddir)/packets_gen.h \
+                         $(doxy_builddir)/packhand_gen.c \
+                         $(doxy_builddir)/packhand_gen.h \
+                         $(doxy_builddir)/specenum_gen.h \
+                         $(doxy_builddir)/terrain_enums_gen.h \
+                         $(doxy_builddir)/version_gen.h \
+                         $(doxy_builddir)/tolua_common_a_gen.c \
+                         $(doxy_builddir)/tolua_common_a_gen.h \
+                         $(doxy_builddir)/tolua_common_z_gen.c \
+                         $(doxy_builddir)/tolua_common_z_gen.h \
+                         $(doxy_builddir)/tolua_game_gen.c \
+                         $(doxy_builddir)/tolua_game_gen.h \
+                         $(doxy_builddir)/tolua_signal_gen.c \
+                         $(doxy_builddir)/tolua_signal_gen.h \
+                         $(doxy_srcdir)/doc/doxygen.md
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -1105,7 +1127,7 @@ FILTER_SOURCE_PATTERNS =
 # (index.html). This can be useful if you have a project on for instance GitHub
 # and want to reuse the introduction page also for the doxygen output.
 
-USE_MDFILE_AS_MAINPAGE = $(doxy_srcdir)doc/doxygen.md
+USE_MDFILE_AS_MAINPAGE = $(doxy_srcdir)/doc/doxygen.md
 
 # The Fortran standard specifies that for fixed formatted Fortran code all
 # characters from position 72 are to be considered as comment. A common
diff --git a/scripts/generate_doc.sh b/scripts/generate_doc.sh
index 41621bf6e8..d35dff186b 100755
--- a/scripts/generate_doc.sh
+++ b/scripts/generate_doc.sh
@@ -11,13 +11,13 @@
 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #  GNU General Public License for more details.
 
-if test "$1" = "" ; then
-  echo "Needs freeciv source directory as a parameter!" >&2
+if test "$1" = "" || test "$2" = "" ; then
+  echo "Needs freeciv source and build directories as parameters!" >&2
   exit 1
 fi
 
 if test "$1" = "-h" || test "$1" = "--help" ; then
-  echo "Usage: $0 <freeciv source directory>"
+  echo "Usage: $0 <freeciv source directory> <freeciv build directory>"
   exit
 fi
 
@@ -26,6 +26,11 @@ if ! test -x "$1/fc_version" ; then
   exit 1
 fi
 
+if ! test -f "$2/version_gen.h" ; then
+  echo "\"$2\" is not a build directory with generated files (lacking version_gen.h)" >&2
+  exit 1
+fi
+
 if ! mkdir -p doc ; then
   echo "Failed to create output doc directory!" >&2
   exit 1
@@ -33,4 +38,5 @@ fi
 
 VERSION_SCRIPT_SILENT=yes . "$1/fc_version"
 
-doxy_srcdir="$1/" doxy_version="-${MAIN_VERSION}" doxygen "$1/doc/freeciv.doxygen"
+doxy_srcdir="$1/" doxy_builddir="$2" doxy_version="-${MAIN_VERSION}" \
+           doxygen "$1/doc/freeciv.doxygen"
-- 
2.47.2

