Unverified Commit 38f21343 authored by Tom van Dijk's avatar Tom van Dijk
Browse files

tome4: fix build

parent 7389da9a
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
From e0c17a8665250b3e3e7f4938f7b256ff50b78fc8 Mon Sep 17 00:00:00 2001
From: Tom van Dijk <18gatenmaker6@gmail.com>
Date: Thu, 23 Oct 2025 15:01:01 +0200
Subject: [PATCH 1/3] web missing include

---
 src/web.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/web.c b/src/web.c
index f12eebb..940aaf9 100644
--- a/src/web.c
+++ b/src/web.c
@@ -32,6 +32,7 @@
 #include "te4web.h"
 #include "web-external.h"
 #include "lua_externs.h"
+#include <unistd.h>
 
 /*
  * Grab web browser methods -- availabe only here
-- 
2.51.0
+24 −0
Original line number Diff line number Diff line
From a14890a8a7080c73cac10ff31365833b179c0464 Mon Sep 17 00:00:00 2001
From: Tom van Dijk <18gatenmaker6@gmail.com>
Date: Thu, 23 Oct 2025 15:45:03 +0200
Subject: [PATCH 2/3] zlib missing include

---
 src/zlib/gzguts.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/zlib/gzguts.h b/src/zlib/gzguts.h
index 990a4d2..7c89751 100644
--- a/src/zlib/gzguts.h
+++ b/src/zlib/gzguts.h
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include "zlib.h"
 #ifdef STDC
+#  include <unistd.h>
 #  include <string.h>
 #  include <stdlib.h>
 #  include <limits.h>
-- 
2.51.0
+71 −0
Original line number Diff line number Diff line
From ed9f9819c3a0d6b8e92f66aafa6324eb4b310282 Mon Sep 17 00:00:00 2001
From: Tom van Dijk <18gatenmaker6@gmail.com>
Date: Thu, 23 Oct 2025 15:53:06 +0200
Subject: [PATCH 3/3] incompatible pointer types

---
 src/display_sdl.c                  | 2 +-
 src/physfs/archivers/bind_physfs.c | 2 +-
 src/physfs/physfs.c                | 3 ++-
 src/tgl.h                          | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/display_sdl.c b/src/display_sdl.c
index 61b2f0e..c533c8b 100644
--- a/src/display_sdl.c
+++ b/src/display_sdl.c
@@ -78,5 +78,5 @@ GLuint gl_c_shader = 0;
 int nb_draws = 0;
 int gl_c_vertices_nb = 0, gl_c_texcoords_nb = 0, gl_c_colors_nb = 0;
 GLfloat *gl_c_vertices_ptr = NULL;
-GLfloat *gl_c_texcoords_ptr = NULL;
+void *gl_c_texcoords_ptr = NULL;
 GLfloat *gl_c_colors_ptr = NULL;
diff --git a/src/physfs/archivers/bind_physfs.c b/src/physfs/archivers/bind_physfs.c
index d02d323..c0d77c1 100644
--- a/src/physfs/archivers/bind_physfs.c
+++ b/src/physfs/archivers/bind_physfs.c
@@ -222,7 +222,7 @@ static fvoid *doOpen(dvoid *opaque, const char *name,
 
 static fvoid *BIND_PHYSFS_openRead(dvoid *opaque, const char *fnm, int *exist)
 {
-	return(doOpen(opaque, fnm, PHYSFS_openRead, exist));
+	return(doOpen(opaque, fnm, (void * (*)(const char *)) PHYSFS_openRead, exist));
 } /* BIND_PHYSFS_openRead */
 
 
diff --git a/src/physfs/physfs.c b/src/physfs/physfs.c
index 03eb86d..32e2c91 100644
--- a/src/physfs/physfs.c
+++ b/src/physfs/physfs.c
@@ -68,12 +68,13 @@ extern const PHYSFS_Archiver       __PHYSFS_Archiver_MVL;
 extern const PHYSFS_ArchiveInfo    __PHYSFS_ArchiveInfo_WAD;
 extern const PHYSFS_Archiver       __PHYSFS_Archiver_WAD;
 extern const PHYSFS_Archiver       __PHYSFS_Archiver_DIR;
+extern const PHYSFS_ArchiveInfo    __PHYSFS_ArchiveInfo_BIND_PHYSFS;
 extern const PHYSFS_Archiver       __PHYSFS_Archiver_BIND_PHYSFS;
 
 
 static const PHYSFS_ArchiveInfo *supported_types[] =
 {
-    &__PHYSFS_Archiver_BIND_PHYSFS,
+    &__PHYSFS_ArchiveInfo_BIND_PHYSFS,
 #if (defined PHYSFS_SUPPORTS_ZIP)
     &__PHYSFS_ArchiveInfo_SUBZIP,
     &__PHYSFS_ArchiveInfo_ZIP,
diff --git a/src/tgl.h b/src/tgl.h
index e2ec026..f905033 100644
--- a/src/tgl.h
+++ b/src/tgl.h
@@ -71,7 +71,7 @@ extern int nb_draws;
 
 extern int gl_c_vertices_nb, gl_c_texcoords_nb, gl_c_colors_nb;
 extern GLfloat *gl_c_vertices_ptr;
-extern GLfloat *gl_c_texcoords_ptr;
+extern void *gl_c_texcoords_ptr;
 extern GLfloat *gl_c_colors_ptr;
 #define glVertexPointer(nb, t, v, p) \
 { \
-- 
2.51.0
+35 −5
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
  lib,
  stdenv,
  fetchFromGitLab,
  fetchpatch2,
  copyDesktopItems,
  makeDesktopItem,
  makeWrapper,
@@ -13,8 +14,17 @@
  SDL2,
  SDL2_image,
  SDL2_ttf,
  xorg,
}:

let
  sdlInputs = [
    SDL2
    SDL2_ttf
    SDL2_image
  ];
in

stdenv.mkDerivation (finalAttrs: {
  pname = "tome4";
  version = "1.7.6";
@@ -34,6 +44,19 @@ stdenv.mkDerivation (finalAttrs: {
      --replace-fail "#include <GL/glext.h>" ""
  '';

  patches = [
    # https://forums.te4.org/viewtopic.php?f=69&t=39859&p=168681&hilit=luaopen_shaders#p168681
    (fetchpatch2 {
      url = "https://gist.githubusercontent.com/hasufell/cb3b10f834e891d90f83/raw/cb4adda13868f6b94585575db4f8df70877ae45a/tome4-1.1.3-fix-implicit-declaration.patch";
      hash = "sha256-g47N/bi2/DDKqaEkfTaGp9ItS57QVnObzMDWXqrCjWE=";
    })
    # unistd required for execv
    ./0001-web-missing-include.patch
    # unistd required for read and close
    ./0002-zlib-missing-include.patch
    ./0003-incompatible-pointer-types.patch
  ];

  nativeBuildInputs = [
    copyDesktopItems
    makeWrapper
@@ -47,15 +70,22 @@ stdenv.mkDerivation (finalAttrs: {
    openal
    libpng
    libvorbis
    SDL2
    SDL2_ttf
    SDL2_image
  ];
    xorg.libX11
    xorg.xorgproto
  ]
  ++ sdlInputs;

  # disable parallel building as it caused sporadic build failures
  enableParallelBuilding = false;

  env.NIX_CFLAGS_COMPILE = "-I${lib.getInclude SDL2}/include/SDL2 -I${SDL2_image}/include/SDL2 -I${SDL2_ttf}/include/SDL2";
  env = {
    NIX_CFLAGS_COMPILE =
      lib.concatMapStringsSep " " (i: "-I${lib.getInclude i}/include/SDL2") sdlInputs
      + " "
      + lib.concatMapStringsSep " " (i: "-I${lib.getInclude i}") finalAttrs.buildInputs;

    NIX_CFLAGS_LINK = lib.concatMapStringsSep " " (i: "-L${lib.getLib i}/lib") finalAttrs.buildInputs;
  };

  makeFlags = [ "config=release" ];