From ce09215a7638919a71d35ebef036de09a1caefbe Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Mon, 10 Dec 2018 11:09:20 -0700
Subject: [PATCH] Add freeciv (WIP), fixes for sdl libtool files

---
 recipes/freeciv/01_redox.patch | 18 +++++++++++++
 recipes/freeciv/recipe.sh      | 48 ++++++++++++++++++++++++++++++++++
 recipes/sdl_gfx/recipe.sh      |  2 ++
 recipes/sdl_image/recipe.sh    |  4 +++
 recipes/sdl_mixer/recipe.sh    |  2 ++
 recipes/sdl_ttf/recipe.sh      |  4 +++
 recipes/sopwith/recipe.sh      |  3 +--
 7 files changed, 79 insertions(+), 2 deletions(-)
 create mode 100644 recipes/freeciv/01_redox.patch
 create mode 100644 recipes/freeciv/recipe.sh

diff --git a/recipes/freeciv/01_redox.patch b/recipes/freeciv/01_redox.patch
new file mode 100644
index 000000000..00725263c
--- /dev/null
+++ b/recipes/freeciv/01_redox.patch
@@ -0,0 +1,18 @@
+diff -ruw source/client/servers.c source-new/client/servers.c
+--- source/client/servers.c	2018-07-21 15:42:11.000000000 -0600
++++ source-new/client/servers.c	2018-12-10 09:31:49.817815930 -0700
+@@ -80,6 +80,14 @@
+ 
+ #include "gui_main_g.h"
+ 
++// Redox patches
++#define IP_ADD_MEMBERSHIP 35
++#define IP_MULTICAST_TTL 33
++struct ip_mreq {
++  struct in_addr imr_multiaddr;   /* IP multicast address of group */
++  struct in_addr imr_interface;   /* local IP address of interface */
++};
++
+ struct server_scan {
+   enum server_scan_type type;
+   ServerScanErrorFunc error_func;
diff --git a/recipes/freeciv/recipe.sh b/recipes/freeciv/recipe.sh
new file mode 100644
index 000000000..7916cb422
--- /dev/null
+++ b/recipes/freeciv/recipe.sh
@@ -0,0 +1,48 @@
+VERSION=2.6.0
+TAR=http://files.freeciv.org/stable/freeciv-$VERSION.tar.bz2
+BUILD_DEPENDS=(curl freetype libiconv liborbital libpng sdl sdl_gfx sdl_image sdl_mixer sdl_ttf zlib)
+
+function recipe_version {
+    echo "$VERSION"
+    skip=1
+}
+
+function recipe_update {
+    echo "skipping update"
+    skip=1
+}
+
+function recipe_build {
+    wget -O bootstrap/config.sub http://git.savannah.gnu.org/cgit/config.git/plain/config.sub
+    sysroot="$(realpath ../sysroot)"
+    export CFLAGS="-I$sysroot/include"
+    export LDFLAGS="-L$sysroot/lib"
+    export LIBS="-lpthread"
+    ./configure \
+        --host="$HOST" \
+        --prefix='' \
+        --disable-server \
+        --enable-client=sdl \
+        --enable-fcmp=cli \
+        --with-sdl-prefix="$sysroot" \
+        ac_cv_lib_SDL_image_IMG_Load=yes \
+        ac_cv_lib_SDL_ttf_TTF_OpenFont=yes
+    make -j"$(nproc)" V=1
+    skip=1
+}
+
+function recipe_test {
+    echo "skipping test"
+    skip=1
+}
+
+function recipe_clean {
+    make clean
+    skip=1
+}
+
+function recipe_stage {
+    dest="$(realpath $1)"
+    make DESTDIR="$dest" install
+    skip=1
+}
diff --git a/recipes/sdl_gfx/recipe.sh b/recipes/sdl_gfx/recipe.sh
index 1392fbe87..bf8bc274f 100644
--- a/recipes/sdl_gfx/recipe.sh
+++ b/recipes/sdl_gfx/recipe.sh
@@ -34,6 +34,8 @@ function recipe_clean {
 
 function recipe_stage {
     dest="$(realpath $1)"
+    sysroot="$(realpath ../sysroot)"
     make DESTDIR="$dest" install
+    sed -i -e "s%//lib/libSDL.la%$sysroot/lib/libSDL.la%" "$dest/lib/"*.la
     skip=1
 }
diff --git a/recipes/sdl_image/recipe.sh b/recipes/sdl_image/recipe.sh
index ea07b351a..cb5ff8d24 100644
--- a/recipes/sdl_image/recipe.sh
+++ b/recipes/sdl_image/recipe.sh
@@ -34,6 +34,10 @@ function recipe_clean {
 
 function recipe_stage {
     dest="$(realpath $1)"
+    sysroot="$(realpath ../sysroot)"
     make DESTDIR="$dest" install
+    sed -i -e "s%//lib/libpng.la%$sysroot/lib/libpng.la%" "$dest/lib/"*.la
+    sed -i -e "s%//lib/libjpeg.la%$sysroot/lib/libjpeg.la%" "$dest/lib/"*.la
+    sed -i -e "s%//lib/libSDL.la%$sysroot/lib/libSDL.la%" "$dest/lib/"*.la
     skip=1
 }
diff --git a/recipes/sdl_mixer/recipe.sh b/recipes/sdl_mixer/recipe.sh
index 9ae3444af..1ffab835a 100644
--- a/recipes/sdl_mixer/recipe.sh
+++ b/recipes/sdl_mixer/recipe.sh
@@ -34,6 +34,8 @@ function recipe_clean {
 
 function recipe_stage {
     dest="$(realpath $1)"
+    sysroot="$(realpath ../sysroot)"
     make DESTDIR="$dest" install
+    sed -i -e "s%//lib/libSDL.la%$sysroot/lib/libSDL.la%" "$dest/lib/"*.la
     skip=1
 }
diff --git a/recipes/sdl_ttf/recipe.sh b/recipes/sdl_ttf/recipe.sh
index 14e082a8d..3e3e2c6a5 100644
--- a/recipes/sdl_ttf/recipe.sh
+++ b/recipes/sdl_ttf/recipe.sh
@@ -38,6 +38,10 @@ function recipe_clean {
 
 function recipe_stage {
     dest="$(realpath $1)"
+    sysroot="$(realpath ../sysroot)"
     make DESTDIR="$dest" install
+    sed -i -e "s%//lib/libfreetype.la%$sysroot/lib/libfreetype.la%" "$dest/lib/"*.la
+    sed -i -e "s%//lib/libpng16.la%$sysroot/lib/libpng16.la%" "$dest/lib/"*.la
+    sed -i -e "s%//lib/libSDL.la%$sysroot/lib/libSDL.la%" "$dest/lib/"*.la
     skip=1
 }
diff --git a/recipes/sopwith/recipe.sh b/recipes/sopwith/recipe.sh
index 9f75db60e..432c5f715 100644
--- a/recipes/sopwith/recipe.sh
+++ b/recipes/sopwith/recipe.sh
@@ -17,9 +17,8 @@ function recipe_build {
     sysroot="${PWD}/../sysroot"
     export CFLAGS="-I$sysroot/include -I$sysroot/include/SDL"
     export LDFLAGS="-L$sysroot/lib"
-
     ./configure --host=${HOST} --prefix='' --with-sdl-prefix="$sysroot"
-    make
+    make -j"$(nproc)"
     skip=1
 }
 
-- 
GitLab