From 8d343adb8dda5eac30ec6301f524176c7401de0d Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 28 Jul 2026 14:12:36 +0300
Subject: [PATCH 38/38] build_tolua.sh: Add

See RM #2099

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 Makefile.am            |  1 +
 scripts/build_tolua.sh | 47 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)
 create mode 100755 scripts/build_tolua.sh

diff --git a/Makefile.am b/Makefile.am
index f895871333..5b367be8ca 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -98,6 +98,7 @@ EXTRA_DIST =	autogen.sh 			\
 		m4/testmatic.m4			\
 		meson.build			\
 		meson_options.txt		\
+		scripts/build_tolua.sh		\
 		scripts/generate_doc.sh		\
 		scripts/mapimg2anim		\
 		scripts/setup_auth_server.sh	\
diff --git a/scripts/build_tolua.sh b/scripts/build_tolua.sh
new file mode 100755
index 0000000000..b0f886bd97
--- /dev/null
+++ b/scripts/build_tolua.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+#/***********************************************************************
+# Freeciv - Copyright (C) 2026
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 2, or (at your option)
+#   any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#***********************************************************************/
+
+srcdir="$(dirname "$0")"
+top_srcdir="$(cd "$srcdir/.." && pwd)"
+
+if test "$1" = "-h" || test "$1" = "--help" ; then
+  echo "Usage: $0 [bin dir]"
+  exit
+fi
+
+if test "$1" != "" ; then
+  bindir="$1"
+  if ! test -d "$1" ; then
+    echo "bin dir \"$1\" does not exist!" >&2
+    exit 1
+  fi
+fi
+
+if ! meson setup -Dserver=disabled -Dclients=[] -Dfcmp=[] -Dtools=[] \
+     -Daudio=none "${top_srcdir}" ||
+   ! ninja ; then
+  echo "Tolua build failed!" >&2
+  exit 1
+fi
+
+if test "${bindir}" != "" ; then
+  if ! cp tolua "${bindir}/" ; then
+    echo "Copying tolua to \"${bindir}\" failed!" >&2
+    exit 1
+  fi
+  echo "tolua is at \"${bindir}\""
+else
+  echo "tolua is at \"$(pwd)\""
+fi
-- 
2.53.0

