From fd3763b71a3cafe2d7e683973d0d796bbde850f0 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 31 Oct 2024 07:20:11 +0200
Subject: [PATCH 7/8] Generate langstat files to the build directory

See RM #703

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 bootstrap/Makefile.am                                       | 3 ---
 bootstrap/generate_langstat.sh                              | 6 +++---
 .../windows/installer_cross/create-freeciv-gtk-qt-nsi.sh    | 6 +++---
 .../windows/installer_cross/create-freeciv-ruledit-nsi.sh   | 6 +++---
 .../windows/installer_cross/create-freeciv-sdl2-nsi.sh      | 6 +++---
 platforms/windows/installer_cross/meson-installer_build.sh  | 2 ++
 platforms/windows/installer_msys2/Makefile.meson            | 2 ++
 .../windows/installer_msys2/create-freeciv-gtk-qt-nsi.sh    | 6 +++---
 .../windows/installer_msys2/create-freeciv-ruledit-nsi.sh   | 6 +++---
 .../windows/installer_msys2/create-freeciv-sdl2-nsi.sh      | 6 +++---
 10 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/bootstrap/Makefile.am b/bootstrap/Makefile.am
index d1f2c2d94c..d16f0de7c4 100644
--- a/bootstrap/Makefile.am
+++ b/bootstrap/Makefile.am
@@ -19,9 +19,6 @@ EXTRA_DIST =	freeciv.project		\
 		generate_langstat.sh	\
 		generate_meson_run.sh	\
 		generate_metainfo.sh	\
-		langstat_core.txt	\
-		langstat_nations.txt	\
-		langstat_ruledit.txt	\
 		org.freeciv.gtk322.desktop	\
 		org.freeciv.gtk4.desktop	\
 		org.freeciv.gtk4x.desktop	\
diff --git a/bootstrap/generate_langstat.sh b/bootstrap/generate_langstat.sh
index 101170abbc..fed062f7de 100755
--- a/bootstrap/generate_langstat.sh
+++ b/bootstrap/generate_langstat.sh
@@ -24,9 +24,9 @@ fi
         echo "$CODE $PRCT $NLANG"
     done ) > "$3/langstat_${1}.txt.tmp"
 
-if ! test -f "$2/bootstrap/langstat_${1}.txt" ||
-   ! cmp "$2/bootstrap/langstat_${1}.txt" "$3/langstat_${1}.txt.tmp" ; then
-    mv "$3/langstat_${1}.txt.tmp" "$2/bootstrap/langstat_${1}.txt"
+if ! test -f "$3/langstat_${1}.txt" ||
+   ! cmp "$3/langstat_${1}.txt" "$3/langstat_${1}.txt.tmp" ; then
+    mv "$3/langstat_${1}.txt.tmp" "$3/langstat_${1}.txt"
 else
     rm -f "$3/langstat_${1}.txt.tmp"
 fi
diff --git a/platforms/windows/installer_cross/create-freeciv-gtk-qt-nsi.sh b/platforms/windows/installer_cross/create-freeciv-gtk-qt-nsi.sh
index 81018e4aa2..7404301898 100755
--- a/platforms/windows/installer_cross/create-freeciv-gtk-qt-nsi.sh
+++ b/platforms/windows/installer_cross/create-freeciv-gtk-qt-nsi.sh
@@ -234,7 +234,7 @@ SectionGroup "Additional languages (translation %)"
 
 EOF
 
-cat ../../../bootstrap/langstat_core.txt |
+cat $1/doc/freeciv/installer/langstat_core.txt |
 sort -k 1 |
 while read -r code prct name
 do
@@ -295,7 +295,7 @@ Start Menu shortcut properties."
   \${NSD_CB_AddString} \$DefaultLanguageDropList "US English (en_US)"
 EOF
 
-  cat ../../../bootstrap/langstat_core.txt |
+  cat $1/doc/freeciv/installer/langstat_core.txt |
   sort -k 1 |
   while read -r code prct name
   do
@@ -319,7 +319,7 @@ EOF
   echo "    StrCpy \$DefaultLanguageCode \"en_US\""
   echo "  \${EndIf}"
 
-  cat ../../../bootstrap/langstat_core.txt |
+  cat $1/doc/freeciv/installer/langstat_core.txt |
   while read -r code prct name
   do
     echo "  \${If} \$LangName == \"$name ($code) $prct\""
diff --git a/platforms/windows/installer_cross/create-freeciv-ruledit-nsi.sh b/platforms/windows/installer_cross/create-freeciv-ruledit-nsi.sh
index c83b6031f5..72b7aa5793 100755
--- a/platforms/windows/installer_cross/create-freeciv-ruledit-nsi.sh
+++ b/platforms/windows/installer_cross/create-freeciv-ruledit-nsi.sh
@@ -206,7 +206,7 @@ SectionGroup "Additional languages (translation %)"
 
 EOF
 
-cat ../../../bootstrap/langstat_ruledit.txt |
+cat $1/doc/freeciv/installer/langstat_ruledit.txt |
 sort -k 1 |
 while read -r code prct name
 do
@@ -267,7 +267,7 @@ Start Menu shortcut properties."
   \${NSD_CB_AddString} \$DefaultLanguageDropList "US English (en_US)"
 EOF
 
-  cat ../../../bootstrap/langstat_ruledit.txt |
+  cat $1/doc/freeciv/installer/langstat_ruledit.txt |
   sort -k 1 |
   while read -r code prct name
   do
@@ -291,7 +291,7 @@ EOF
   echo "    StrCpy \$DefaultLanguageCode \"en_US\""
   echo "  \${EndIf}"
 
-  cat ../../../bootstrap/langstat_ruledit.txt |
+  cat $1/doc/freeciv/installer/langstat_ruledit.txt |
   while read -r code prct name
   do
     echo "  \${If} \$LangName == \"$name ($code) $prct\""
diff --git a/platforms/windows/installer_cross/create-freeciv-sdl2-nsi.sh b/platforms/windows/installer_cross/create-freeciv-sdl2-nsi.sh
index ae85a610be..d72cb21aed 100755
--- a/platforms/windows/installer_cross/create-freeciv-sdl2-nsi.sh
+++ b/platforms/windows/installer_cross/create-freeciv-sdl2-nsi.sh
@@ -220,7 +220,7 @@ SectionGroup "Additional languages (translation %)"
 
 EOF
 
-cat ../../../bootstrap/langstat_core.txt |
+cat $1/doc/freeciv/installer/langstat_core.txt |
 sort -k 1 |
 while read -r code prct name
 do
@@ -299,7 +299,7 @@ Start Menu shortcut properties."
   \${NSD_CB_AddString} \$DefaultLanguageDropList "US English (en_US)"
 EOF
 
-  cat ../../../bootstrap/langstat_core.txt |
+  cat $1/doc/freeciv/installer/langstat_core.txt |
   sort -k 1 |
   while read -r code prct name
   do
@@ -323,7 +323,7 @@ EOF
   echo "    StrCpy \$DefaultLanguageCode \"en_US\""
   echo "  \${EndIf}"
 
-  cat ../../../bootstrap/langstat_core.txt |
+  cat $1/doc/freeciv/installer/langstat_core.txt |
   while read -r code prct name
   do
     echo "  \${If} \$LangName == \"$name ($code) $prct\""
diff --git a/platforms/windows/installer_cross/meson-installer_build.sh b/platforms/windows/installer_cross/meson-installer_build.sh
index 47ca7f5e98..6eab7fd5f9 100755
--- a/platforms/windows/installer_cross/meson-installer_build.sh
+++ b/platforms/windows/installer_cross/meson-installer_build.sh
@@ -197,6 +197,8 @@ if ! mv "${INSTDIR}/bin/"* "${INSTDIR}/" ||
    ! mkdir -p "${INSTDIR}/doc/freeciv/installer" ||
    ! cat licenses/header.txt "${SRC_ROOT}/COPYING" \
      > "${INSTDIR}/doc/freeciv/installer/COPYING.installer" ||
+   ! cp "${BUILD_ROOT}/meson/build/${SETUP}-${GUI}/langstat_"*.txt \
+       "${INSTDIR}/doc/freeciv/installer/" ||
    ! rm -Rf "${INSTDIR}/lib" ||
    ! cp Freeciv.url "${INSTDIR}/"
 then
diff --git a/platforms/windows/installer_msys2/Makefile.meson b/platforms/windows/installer_msys2/Makefile.meson
index 94806953e0..cdd75c0ccf 100644
--- a/platforms/windows/installer_msys2/Makefile.meson
+++ b/platforms/windows/installer_msys2/Makefile.meson
@@ -147,6 +147,7 @@ install-freeciv-common: clean-install-client-arch
 	mv $(INST_DIR)/$(WINARCH)-client-$(GUI)/share/doc $(INST_DIR)/$(WINARCH)-client-$(GUI)/
 	mkdir -p $(INST_DIR)/$(WINARCH)-client-$(GUI)/doc/freeciv/installer
 	cat licenses/header.txt $(SRC_ROOT)/COPYING > $(INST_DIR)/$(WINARCH)-client-$(GUI)/doc/freeciv/installer/COPYING.installer
+	cp $(BUILD_DIR)/$(WINARCH)-client-$(GUI)/langstat_*.txt $(INST_DIR)/$(WINARCH)-client-$(GUI)/doc/freeciv/installer/
 	cp freeciv-server.cmd freeciv-mp-$(FCMP).cmd freeciv-$(CLIENT).cmd Freeciv.url $(INST_DIR)/$(WINARCH)-client-$(GUI)/
 
 install-ruledit-common: clean-ruledit-install-arch
@@ -163,6 +164,7 @@ install-ruledit-common: clean-ruledit-install-arch
 	mv $(INST_DIR)/$(WINARCH)-ruledit-$(GUI)/share/doc $(INST_DIR)/$(WINARCH)-ruledit-$(GUI)/
 	mkdir -p $(INST_DIR)/$(WINARCH)-ruledit-$(GUI)/doc/freeciv/installer
 	cat licenses/header.txt $(SRC_ROOT)/COPYING > $(INST_DIR)/$(WINARCH)-ruledit-$(GUI)/doc/freeciv/installer/COPYING.installer
+	cp $(BUILD_DIR)/$(WINARCH)-ruledit-$(GUI)/langstat_*.txt $(INST_DIR)/$(WINARCH)-ruledit-$(GUI)/doc/freeciv/installer/
 	cp freeciv-ruledit.cmd Freeciv.url $(INST_DIR)/$(WINARCH)-ruledit-$(GUI)/
 
 SOUND_DLLS := \
diff --git a/platforms/windows/installer_msys2/create-freeciv-gtk-qt-nsi.sh b/platforms/windows/installer_msys2/create-freeciv-gtk-qt-nsi.sh
index 7903790dee..b5af7dd036 100644
--- a/platforms/windows/installer_msys2/create-freeciv-gtk-qt-nsi.sh
+++ b/platforms/windows/installer_msys2/create-freeciv-gtk-qt-nsi.sh
@@ -230,7 +230,7 @@ SectionGroup "Additional languages (translation %)"
 
 EOF
 
-cat ../../../bootstrap/langstat_core.txt |
+cat $1/doc/freeciv/installer/langstat_core.txt |
 sort -k 1 |
 iconv -f UTF-8 -t ISO-8859-1 |
 while read -r code prct name
@@ -291,7 +291,7 @@ Start Menu shortcut properties."
   \${NSD_CB_AddString} \$DefaultLanguageDropList "US English (en_US)"
 EOF
 
-  cat ../../../bootstrap/langstat_core.txt |
+  cat $1/doc/freeciv/installer/langstat_core.txt |
   sort -k 1 |
   iconv -f UTF-8 -t ISO-8859-1 |
   while read -r code prct name
@@ -316,7 +316,7 @@ EOF
   echo "    StrCpy \$DefaultLanguageCode \"en_US\""
   echo "  \${EndIf}"
 
-  cat ../../../bootstrap/langstat_core.txt |
+  cat $1/doc/freeciv/installer/langstat_core.txt |
   iconv -f UTF-8 -t ISO-8859-1 |
   while read -r code prct name
   do
diff --git a/platforms/windows/installer_msys2/create-freeciv-ruledit-nsi.sh b/platforms/windows/installer_msys2/create-freeciv-ruledit-nsi.sh
index d3166c09d3..955295408d 100644
--- a/platforms/windows/installer_msys2/create-freeciv-ruledit-nsi.sh
+++ b/platforms/windows/installer_msys2/create-freeciv-ruledit-nsi.sh
@@ -207,7 +207,7 @@ SectionGroup "Additional languages (translation %)"
 
 EOF
 
-cat ../../../bootstrap/langstat_ruledit.txt |
+cat $1/doc/freeciv/installer/langstat_ruledit.txt |
 sort -k 1 |
 iconv -f UTF-8 -t ISO-8859-1 |
 while read -r code prct name
@@ -268,7 +268,7 @@ Start Menu shortcut properties."
   \${NSD_CB_AddString} \$DefaultLanguageDropList "US English (en_US)"
 EOF
 
-  cat ../../../bootstrap/langstat_ruledit.txt |
+  cat $1/doc/freeciv/installer/langstat_ruledit.txt |
   sort -k 1 |
   iconv -f UTF-8 -t ISO-8859-1 |
   while read -r code prct name
@@ -293,7 +293,7 @@ EOF
   echo "    StrCpy \$DefaultLanguageCode \"en_US\""
   echo "  \${EndIf}"
 
-  cat ../../../bootstrap/langstat_ruledit.txt |
+  cat $1/doc/freeciv/installer/langstat_ruledit.txt |
   iconv -f UTF-8 -t ISO-8859-1 |
   while read -r code prct name
   do
diff --git a/platforms/windows/installer_msys2/create-freeciv-sdl2-nsi.sh b/platforms/windows/installer_msys2/create-freeciv-sdl2-nsi.sh
index d4f06f2089..4830de3c7b 100644
--- a/platforms/windows/installer_msys2/create-freeciv-sdl2-nsi.sh
+++ b/platforms/windows/installer_msys2/create-freeciv-sdl2-nsi.sh
@@ -216,7 +216,7 @@ SectionGroup "Additional languages (translation %)"
 
 EOF
 
-cat ../../../bootstrap/langstat_core.txt |
+cat $1/doc/freeciv/installer/langstat_core.txt |
 sort -k 1 |
 iconv -f UTF-8 -t ISO-8859-1 |
 while read -r code prct name
@@ -295,7 +295,7 @@ Start Menu shortcut properties."
   \${NSD_CB_AddString} \$DefaultLanguageDropList "US English (en_US)"
 EOF
 
-  cat ../../../bootstrap/langstat_core.txt |
+  cat $1/doc/freeciv/installer/langstat_core.txt |
   sort -k 1 |
   iconv -f UTF-8 -t ISO-8859-1 |
   while read -r code prct name
@@ -320,7 +320,7 @@ EOF
   echo "    StrCpy \$DefaultLanguageCode \"en_US\""
   echo "  \${EndIf}"
 
-  cat ../../../bootstrap/langstat_core.txt |
+  cat $1/doc/freeciv/installer/langstat_core.txt |
   iconv -f UTF-8 -t ISO-8859-1 |
   while read -r code prct name
   do
-- 
2.45.2

