From 924710ab831e4d51b2cc2b73da67a64ea6596838 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 16 May 2026 08:22:11 +0300
Subject: [PATCH 40/40] AppImage: Build gtk4 modpack installer

See RM #1870

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 platforms/appimage/build_appimages.sh | 43 +++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)

diff --git a/platforms/appimage/build_appimages.sh b/platforms/appimage/build_appimages.sh
index 99df96db30..a63b6244b6 100755
--- a/platforms/appimage/build_appimages.sh
+++ b/platforms/appimage/build_appimages.sh
@@ -2,7 +2,7 @@
 
 # build_appimages.sh: Build freeciv AppImages
 #
-# (c) 2024-2025 Freeciv team
+# (c) 2024-2026 Freeciv team
 #
 # This script is licensed under Gnu General Public License version 2 or later.
 # See COPYING available from the same location you got this script.
@@ -29,7 +29,7 @@ fi
 # $4 - Extra configure options
 client_appimage() {
   if ! mkdir "AppDir/client-$1" || ! mkdir "build/client-$1" ; then
-    echo "Failed to create $1 directories!" >&2
+    echo "Failed to create client-$1 directories!" >&2
     return 1
   fi
 
@@ -58,6 +58,40 @@ client_appimage() {
   fi
 }
 
+# $1 - FCMP type
+# $2 - FCMP configuration name
+# $3 - FCMP part of the AppImage name as produced by linuxdeploy
+# $4 - Extra configure options
+fcmp_appimage() {
+  if ! mkdir "AppDir/fcmp-$1" || ! mkdir "build/fcmp-$1" ; then
+    echo "Failed to create fcmp-$1 directories!" >&2
+    return 1
+  fi
+
+  cd "build/fcmp-$1"
+  if ! meson setup -Dappimage=true -Dprefix=/usr -Ddefault_library=static -Dserver=disabled  -Dclients=[] -Dfcmp=$2 -Dtools=[] $4 "${SRC_ROOT}"
+  then
+    echo "fcmp-$1 setup with meson failed!" >&2
+    return 1
+  fi
+
+  if ! DESTDIR="${BUILD_ROOT}/AppDir/fcmp-$1" ninja install ; then
+    echo "fcmp-$1 build with ninja failed!" >&2
+    return 1
+  fi
+
+  cd "${BUILD_ROOT}"
+  if ! tools/linuxdeploy-x86_64.AppImage --appdir "AppDir/fcmp-$1" --output appimage
+  then
+    echo "fcmp-$1 image build with linuxdeploy failed!" >&2
+    return 1
+  fi
+  if ! mv "Freeciv_modpack_installer$3-x86_64.AppImage" "Freeciv-fcmp-$1-${FCVER}-x86_64.AppImage" ; then
+    echo "fcmp-$1 appimage rename failed!" >&2
+    return 1
+  fi
+}
+
 # $1 - Qtver
 ruledit_appimage() {
   if ! mkdir "AppDir/ruledit-$1" || ! mkdir "build/ruledit-$1" ; then
@@ -150,3 +184,8 @@ if ! ruledit_appimage qt6
 then
   exit 1
 fi
+
+if ! fcmp_appimage gtk4    gtk4    "_(gtk4)"
+then
+  exit 1
+fi
-- 
2.53.0

