speed-dreams: add darwin support
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
diff --git a/src/ssg/ssgLoadFLT.cxx b/src/ssg/ssgLoadFLT.cxx
|
||||
--- a/src/ssg/ssgLoadFLT.cxx
|
||||
+++ b/src/ssg/ssgLoadFLT.cxx
|
||||
@@ -112,6 +112,10 @@
|
||||
# include <sys/stat.h>
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
+#if defined(__APPLE__)
|
||||
+typedef unsigned int uint;
|
||||
+typedef unsigned short ushort;
|
||||
+#endif
|
||||
#ifdef UL_MSVC
|
||||
# include <io.h>
|
||||
#endif
|
||||
@@ -37,9 +37,15 @@ stdenv.mkDerivation rec {
|
||||
url = "https://sources.debian.org/data/main/p/plib/1.8.5-13/debian/patches/08_CVE-2021-38714.patch";
|
||||
sha256 = "sha256-3f1wZn0QqK/hPWCg1KEzbB95IGoxBjLZoCOFlW98t5w=";
|
||||
})
|
||||
./darwin-ssgloadflt-uint.patch
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
configureFlags = lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
"--disable-sl"
|
||||
"--disable-pw"
|
||||
];
|
||||
|
||||
propagatedBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [
|
||||
libGLU
|
||||
libGL
|
||||
libglut
|
||||
@@ -70,6 +76,6 @@ stdenv.mkDerivation rec {
|
||||
license = lib.licenses.lgpl2Plus;
|
||||
|
||||
homepage = "https://plib.sourceforge.net/";
|
||||
platforms = lib.platforms.linux;
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
diff --git a/src/libs/tgfclient/guiscreen.cpp b/src/libs/tgfclient/guiscreen.cpp
|
||||
--- a/src/libs/tgfclient/guiscreen.cpp
|
||||
+++ b/src/libs/tgfclient/guiscreen.cpp
|
||||
@@ -426,9 +426,9 @@ bool GfScrInitSDL2(int nWinWidth, int nWinHeight, int nFullScreen)
|
||||
|
||||
#ifdef __APPLE__
|
||||
// Version d'OpenGL
|
||||
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
- SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
||||
#else
|
||||
// Version d'OpenGL
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
@@ -29,15 +29,52 @@
|
||||
cmake,
|
||||
pkg-config,
|
||||
libvorbis,
|
||||
runtimeShell,
|
||||
curl,
|
||||
fetchgit,
|
||||
cjson,
|
||||
minizip,
|
||||
rhash,
|
||||
copyDesktopItems,
|
||||
makeWrapper,
|
||||
}:
|
||||
|
||||
let
|
||||
glLibs = lib.optionals stdenv.isLinux [
|
||||
libGL
|
||||
libGLU
|
||||
libglut
|
||||
];
|
||||
runtimeLibs = glLibs ++ [
|
||||
libX11
|
||||
plib
|
||||
openal
|
||||
freealut
|
||||
libXrandr
|
||||
libXext
|
||||
libSM
|
||||
libICE
|
||||
libXi
|
||||
libXt
|
||||
libXrender
|
||||
libXxf86vm
|
||||
openscenegraph
|
||||
expat
|
||||
libpng12
|
||||
zlib
|
||||
SDL2
|
||||
SDL2_mixer
|
||||
enet
|
||||
libjpeg
|
||||
libvorbis
|
||||
curl
|
||||
cjson
|
||||
minizip
|
||||
rhash
|
||||
stdenv.cc.cc.lib
|
||||
];
|
||||
runtimeLibPath = lib.makeLibraryPath runtimeLibs;
|
||||
libPathVar = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
version = "2.4.2";
|
||||
pname = "speed-dreams";
|
||||
@@ -50,58 +87,29 @@ stdenv.mkDerivation rec {
|
||||
};
|
||||
NIX_CFLAGS_COMPILE = "-I${src}/src/libs/tgf -I${src}/src/libs/tgfdata -I${src}/src/interfaces -I${src}/src/libs/math -I${src}/src/libs/portability";
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p "$out/bin"
|
||||
# Wrapper for main executable
|
||||
cat > "$out/bin/speed-dreams" <<EOF
|
||||
#!${runtimeShell}
|
||||
export LD_LIBRARY_PATH="$out/lib/games/speed-dreams-2/lib:$out/lib:${
|
||||
lib.makeLibraryPath [
|
||||
libGL
|
||||
libGLU
|
||||
libglut
|
||||
libX11
|
||||
plib
|
||||
openal
|
||||
freealut
|
||||
libXrandr
|
||||
libXext
|
||||
libSM
|
||||
libICE
|
||||
libXi
|
||||
libXt
|
||||
libXrender
|
||||
libXxf86vm
|
||||
openscenegraph
|
||||
expat
|
||||
libpng12
|
||||
zlib
|
||||
SDL2
|
||||
SDL2_mixer
|
||||
enet
|
||||
libjpeg
|
||||
libvorbis
|
||||
curl
|
||||
cjson
|
||||
minizip
|
||||
rhash
|
||||
stdenv.cc.cc.lib
|
||||
]
|
||||
}"
|
||||
if [ -e "${libGL}/lib/libGL.so.1" ]; then
|
||||
export LD_PRELOAD="${libGL}/lib/libGL.so.1''${LD_PRELOAD:+:$LD_PRELOAD}"
|
||||
fi
|
||||
export SDL_VIDEODRIVER="x11"
|
||||
exec "$out/games/speed-dreams-2" "$@"
|
||||
EOF
|
||||
chmod a+x "$out/bin/speed-dreams"
|
||||
patches = [
|
||||
./darwin-gl-compat.patch
|
||||
];
|
||||
|
||||
# Symlink for desktop icon
|
||||
mkdir -p $out/share/pixmaps/
|
||||
ln -s "$out/share/games/speed-dreams-2/data/icons/icon.png" "$out/share/pixmaps/speed-dreams-2.png"
|
||||
postInstall = ''
|
||||
substituteInPlace "$out/share/applications/speed-dreams.desktop" \
|
||||
--replace-fail "Exec=$out/games/speed-dreams-2" "Exec=$out/bin/speed-dreams" \
|
||||
--replace-fail "Icon=/build/speed-dreams-code/speed-dreams-data/data/data/icons/icon.png" "Icon=$out/share/pixmaps/speed-dreams-2.png"
|
||||
--replace-fail "Exec=$out/games/speed-dreams-2" "Exec=$out/bin/speed-dreams"
|
||||
${lib.optionalString stdenv.isLinux ''
|
||||
# Symlink for desktop icon
|
||||
mkdir -p $out/share/pixmaps/
|
||||
ln -s "$out/share/games/speed-dreams-2/data/icons/icon.png" "$out/share/pixmaps/speed-dreams-2.png"
|
||||
substituteInPlace "$out/share/applications/speed-dreams.desktop" \
|
||||
--replace-fail "Icon=/build/speed-dreams-code/speed-dreams-data/data/data/icons/icon.png" "Icon=$out/share/pixmaps/speed-dreams-2.png"
|
||||
''}
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
mkdir -p "$out/bin"
|
||||
makeWrapperArgs=(
|
||||
--prefix ${libPathVar} : "$out/lib/games/speed-dreams-2/lib:$out/lib:${runtimeLibPath}"
|
||||
)
|
||||
${lib.optionalString stdenv.isLinux ''makeWrapperArgs+=(--set SDL_VIDEODRIVER x11)''}
|
||||
makeWrapper "$out/games/speed-dreams-2" "$out/bin/speed-dreams" "''${makeWrapperArgs[@]}"
|
||||
'';
|
||||
|
||||
# RPATH of binary /nix/store/.../lib64/games/speed-dreams-2/drivers/shadow_sc/shadow_sc.so contains a forbidden reference to /build/
|
||||
@@ -113,13 +121,11 @@ stdenv.mkDerivation rec {
|
||||
pkg-config
|
||||
cmake
|
||||
copyDesktopItems
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
libpng12
|
||||
libGLU
|
||||
libGL
|
||||
libglut
|
||||
libX11
|
||||
plib
|
||||
openal
|
||||
@@ -146,6 +152,11 @@ stdenv.mkDerivation rec {
|
||||
cjson
|
||||
minizip
|
||||
rhash
|
||||
]
|
||||
++ lib.optionals stdenv.isLinux [
|
||||
libGL
|
||||
libGLU
|
||||
libglut
|
||||
];
|
||||
|
||||
meta = {
|
||||
@@ -156,7 +167,7 @@ stdenv.mkDerivation rec {
|
||||
raskin
|
||||
mio
|
||||
];
|
||||
platforms = lib.platforms.linux;
|
||||
platforms = lib.platforms.linux ++ lib.platforms.darwin;
|
||||
mainProgram = "speed-dreams";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user