about summary refs log tree commit diff
path: root/pkgs/misc/emulators
diff options
context:
space:
mode:
authorMathijs Kwik <mathijs@bluescreen303.nl>2013-10-09 08:15:39 +0200
committerMathijs Kwik <mathijs@bluescreen303.nl>2013-10-11 01:10:41 +0200
commitef3cc83d1e2cd391f1d75c4ba642a45d91738775 (patch)
treeaad839984efb9c304ec9f10abefa9a0d0c19c13d /pkgs/misc/emulators
parent1772bcebc1cda290fb6079391dcef3a3e0f2912d (diff)
downloadnixlib-ef3cc83d1e2cd391f1d75c4ba642a45d91738775.tar
nixlib-ef3cc83d1e2cd391f1d75c4ba642a45d91738775.tar.gz
nixlib-ef3cc83d1e2cd391f1d75c4ba642a45d91738775.tar.bz2
nixlib-ef3cc83d1e2cd391f1d75c4ba642a45d91738775.tar.lz
nixlib-ef3cc83d1e2cd391f1d75c4ba642a45d91738775.tar.xz
nixlib-ef3cc83d1e2cd391f1d75c4ba642a45d91738775.tar.zst
nixlib-ef3cc83d1e2cd391f1d75c4ba642a45d91738775.zip
zsnes: patches for modern gcc & libpng
builds fine on stdenv-updates now
needs gcc 4.8+, so keep this commit on stdenv-updates until merge
Diffstat (limited to 'pkgs/misc/emulators')
-rw-r--r--pkgs/misc/emulators/zsnes/default.nix32
-rw-r--r--pkgs/misc/emulators/zsnes/zsnes-1.51-libpng15.patch12
-rw-r--r--pkgs/misc/emulators/zsnes/zsnes.patch80
3 files changed, 105 insertions, 19 deletions
diff --git a/pkgs/misc/emulators/zsnes/default.nix b/pkgs/misc/emulators/zsnes/default.nix
index 0b34fc0f9fec..a2896e70d174 100644
--- a/pkgs/misc/emulators/zsnes/default.nix
+++ b/pkgs/misc/emulators/zsnes/default.nix
@@ -2,33 +2,27 @@
 
 stdenv.mkDerivation {
   name = "zsnes-1.51";
-  
+
   src = fetchurl {
     url = mirror://sourceforge/zsnes/zsnes151src.tar.bz2;
     sha256 = "08s64qsxziv538vmfv38fg1rfrz5k95dss5zdkbfxsbjlbdxwmi8";
   };
 
-  buildInputs = [ nasm SDL zlib libpng ncurses mesa ];
-  
+  # copied from arch linux, fixes gcc-4.8 compatibility
+  patches = [ ./zsnes.patch ];
+
+  postPatch = ''
+    patch -p0 < ${./zsnes-1.51-libpng15.patch}
+  '';
+
   preConfigure = ''
     cd src
-    
-    # Fix for undefined strncasecmp()
-    echo '#include <strings.h>' > tmp.cpp 
-    cat tmp.cpp tools/strutil.h > tools/strutil.h.new
-    mv tools/strutil.h.new tools/strutil.h
-    
-    # Fix for undefined system()
-    echo '#include <stdlib.h>' > tmp.cpp
-    cat tmp.cpp tools/depbuild.cpp > tools/depbuild.cpp.new
-    mv tools/depbuild.cpp.new tools/depbuild.cpp
-    
-    # Fix for lots of undefined strcmp, strncmp etc.
-    echo '#include <string.h>' > tmp.cpp 
-    cat tmp.cpp parsegen.cpp > parsegen.cpp.new
-    mv parsegen.cpp.new parsegen.cpp
   '';
-  
+
+  buildInputs = [ nasm SDL zlib libpng ncurses mesa ];
+
+  configureFlags = "--enable-release";
+
   meta = {
     description = "A Super Nintendo Entertainment System Emulator";
     license = "GPLv2+";
diff --git a/pkgs/misc/emulators/zsnes/zsnes-1.51-libpng15.patch b/pkgs/misc/emulators/zsnes/zsnes-1.51-libpng15.patch
new file mode 100644
index 000000000000..b32c30967547
--- /dev/null
+++ b/pkgs/misc/emulators/zsnes/zsnes-1.51-libpng15.patch
@@ -0,0 +1,12 @@
+Use existing png_set_IHDR() and stop accessing PNG structure members directly
+
+--- src/zip/zpng.c
++++ src/zip/zpng.c
+@@ -129,7 +129,6 @@
+         png_set_IHDR(png_ptr, info_ptr, width, height, 8,
+                      PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
+                      PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+-        info_ptr->color_type = PNG_COLOR_TYPE_RGB;
+ 
+         //Allocate an array of scanline pointers
+         row_pointers = (png_bytep*)malloc(height*sizeof(png_bytep));
diff --git a/pkgs/misc/emulators/zsnes/zsnes.patch b/pkgs/misc/emulators/zsnes/zsnes.patch
new file mode 100644
index 000000000000..d5d681ae67a8
--- /dev/null
+++ b/pkgs/misc/emulators/zsnes/zsnes.patch
@@ -0,0 +1,80 @@
+diff -aur zsnes_1_51//src/Makefile.in zsnes_1_51_new//src/Makefile.in
+--- zsnes_1_51//src/Makefile.in	2007-01-24 21:54:12.000000000 +0100
++++ zsnes_1_51_new//src/Makefile.in	2010-09-06 00:03:04.715810431 +0200
+@@ -95,7 +95,7 @@
+ %.o: %.cpp
+ 	@CXX@ @CXXFLAGS@ -o $@ -c $<
+ %.o %.h: %.psr $(PSR)
+-	./$(PSR) @PSRFLAGS@ -gcc @CC@ -compile -flags "@CFLAGS@ -O1" -cheader $*.h -fname $* $*.o $<
++	./$(PSR) @PSRFLAGS@ -gcc "@CC@" -compile -flags "@CFLAGS@ -O1 -D_FORTIFY_SOURCE=0" -cheader $*.h -fname $* $*.o $<
+ 
+ default: main
+ all: main tools
+@@ -133,7 +133,7 @@
+ 
+ include makefile.dep
+ makefile.dep: $(TOOL_D)/depbuild Makefile
+-	$(TOOL_D)/depbuild @CC@ "@CFLAGS@" @NASMPATH@ "@NFLAGS@" $(Z_OBJS) > makefile.dep
++	$(TOOL_D)/depbuild "@CC@" "@CFLAGS@" "@NASMPATH@" "@NFLAGS@" $(Z_OBJS) > makefile.dep
+ 
+ Makefile: Makefile.in config.status
+ 	./config.status
+diff -aur zsnes_1_51//src/parsegen.cpp zsnes_1_51_new//src/parsegen.cpp
+--- zsnes_1_51//src/parsegen.cpp	2007-10-31 05:30:26.000000000 +0100
++++ zsnes_1_51_new//src/parsegen.cpp	2010-09-05 15:48:36.903333444 +0200
+@@ -19,6 +19,9 @@
+ Config file handler creator by Nach (C) 2005-2007
+ */
+ 
++#include <cstring>
++#include <cstdlib>
++
+ #if !defined(__GNUC__) && !defined(_MSC_VER)
+ #error You are using an unsupported compiler
+ #endif
+@@ -1822,7 +1825,7 @@
+   }
+ }
+ 
+-int main(size_t argc, const char *const *const argv)
++int main(int argc, const char *const *const argv)
+ {
+   const char *cheader_file = 0;
+   bool compile = false;
+diff -aur zsnes_1_51//src/tools/depbuild.cpp zsnes_1_51_new//src/tools/depbuild.cpp
+--- zsnes_1_51//src/tools/depbuild.cpp	2006-12-27 12:04:05.000000000 +0100
++++ zsnes_1_51_new//src/tools/depbuild.cpp	2010-09-05 15:48:36.903333444 +0200
+@@ -183,7 +183,7 @@
+   }
+ }
+ 
+-int main(size_t argc, const char *const *const argv)
++int main(int argc, const char *const *const argv)
+ {
+   if (argc < 5)
+   {
+diff -aur zsnes_1_51//src/tools/strutil.h zsnes_1_51_new//src/tools/strutil.h
+--- zsnes_1_51//src/tools/strutil.h	2006-12-27 12:04:05.000000000 +0100
++++ zsnes_1_51_new//src/tools/strutil.h	2010-09-05 15:48:36.903333444 +0200
+@@ -15,6 +15,9 @@
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+ 
++#include <cstring>
++#include <cstdlib>
++
+ /*
+ This is part of a toolkit used to assist in ZSNES development
+ */
+diff -u -r zsnes_1_51/src/tools/depbuild.cpp zsnes_1_51-fix/src/tools/depbuild.cpp
+--- zsnes_1_51/src/tools/depbuild.cpp	2006-12-27 12:04:05.000000000 +0100
++++ zsnes_1_51-fix/src/tools/depbuild.cpp	2012-07-14 16:20:17.759886250 +0200
+@@ -26,6 +26,8 @@
+ #include <cstdio>
+ using namespace std;
+ 
++#include <unistd.h>
++
+ #include "fileutil.h"
+ #include "strutil.h"
+