From 2690defc60f6b0ead7b77767aed35dd98912a8a9 Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Fri, 19 Aug 2022 23:51:53 +0200
Subject: [PATCH] Add pre-generated docs to the source tarball.

This adds all generated markdown and html docs for all target systems in
packages/gendoc to the self-contained distribution tarball (`make
dist`), so that no special tools like python-markdown are required to
build the package.
---
 Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Makefile b/Makefile
index 5f7ddd3ee..3cc51bd07 100644
--- a/Makefile
+++ b/Makefile
@@ -243,6 +243,8 @@ submodules = $(sort $(shell test -d .git && (git config --file .gitmodules --get
 
 dist: $(debsrc)
 
+# Determine the version number of this build. We get this from m_pd.h.
+PD_L2ORK_VERSION := $(shell grep PD_L2ORK_VERSION pd/src/m_pd.h | sed 's|^.define *PD_L2ORK_VERSION *"\(.*\)".*|\1|')
 # Determine the build version which needs git to be computed, so we can't do
 # it in a stand-alone build from a tarball.
 PD_BUILD_VERSION := $(shell test -d .git && (git log -1 --format=%cd --date=short | sed -e 's/-//g'))-rev.$(shell test -d .git && git rev-parse --short HEAD)
@@ -259,6 +261,12 @@ $(debsrc):
 # Pre-generate and put s_version.h into the tarball (see above; the build
 # version is generated using git which can't be done outside the git repo).
 	sed 's|^\(#define PD_BUILD_VERSION "\).*"|\1$(PD_BUILD_VERSION)"|' pd/src/s_version.h.in > $(debdist)/pd/src/s_version.h
+# Pre-generate the markdown and html docs so that they will be included in the
+# source. This means that we don't need any special tools as a build
+# dependency, which makes live a lot easier.
+	make -C packages/gendoc version="$(PD_L2ORK_VERSION)" build_version="$(PD_BUILD_VERSION)"
+	mv packages/gendoc/{ReadMe,Welcome}-*.{md,html} $(debdist)/packages/gendoc
+	make -C packages/gendoc clean
 # Create the source tarball.
 	tar cfz $(debsrc) $(debdist)
 	rm -rf $(debdist)
-- 
GitLab