From 7e3b23fe131e693472124fa68140e2cd5f745c63 Mon Sep 17 00:00:00 2001
From: Aki Tuomi <aki.tuomi@open-xchange.com>
Date: Mon, 26 Aug 2024 15:30:56 +0300
Subject: [PATCH] configure: Fix asset URL generation

---
 configure.ac    | 14 +++++++++++---
 doc/Makefile.am |  2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index adfa386e7..ba24a322e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,9 +15,6 @@ AC_CONFIG_SRCDIR([src])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([build-aux])
 
-PIGEONHOLE_ASSET_VERSION=regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\)], [\1.\2])
-AC_SUBST(PIGEONHOLE_ASSET_VERSION)
-
 # Autoheader is not needed and does more harm than good for this package. However, it is
 # tightly integrated in autoconf/automake and therefore it is difficult not to use it. As
 # a workaround we give autoheader a dummy config header to chew on and we handle the
@@ -52,6 +49,17 @@ AC_SUBST(BINARY_CFLAGS)
 AC_SUBST(BINARY_LDFLAGS)
 AC_SUBST(LIBDOVECOT_INCLUDE)
 
+AC_SUBST(PIGEONHOLE_ASSET_VERSION, regexp(AC_PACKAGE_VERSION, [^\([0-9]+\)\.\([0-9]+\).\([0-9]+\)], [\1.\2.\3]))
+AS_IF([test $PIGEONHOLE_ASSET_VERSION = "0.0.0"], [
+   AC_SUBST([PIGEONHOLE_ASSET_VERSION], "main")
+])
+
+AS_IF([test $DOVECOT_PRO_BUILD = "1"], [
+  AC_SUBST(PIGEONHOLE_ASSET_URL, "doc.dovecotpro.com")
+], [
+  AC_SUBST(PIGEONHOLE_ASSET_URL, "doc.dovecot.org")
+])
+
 # Define Sieve documentation install dir
 #
 
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 3d41505f3..f462210ed 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -14,7 +14,7 @@ endif
 
 BUILT_SOURCES = pigeonhole-man
 
-MAN_URL=https://doc.dovecot.org/assets/$(PIGEONHOLE_ASSET_VERSION)/pigeonhole.txz
+MAN_URL=https://$(PIGEONHOLE_ASSET_URL)/$(PIGEONHOLE_ASSET_VERSION)/pigeonhole.txz
 
 AM_V_Q = $(am__v_Q_$(V))
 am__v_Q_ = $(am__v_Q_$(AM_DEFAULT_VERBOSITY))
-- 
GitLab