summary refs log tree commit diff
path: root/pkgs/tools/graphics/nifskope
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-09-10 10:55:58 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-09-10 10:56:35 +0200
commit79c9adce657dd6d3a73cc830fe4f5316fa9dcd26 (patch)
tree1e7b09865d9b2a51a4dc40209e67ba3402c3320b /pkgs/tools/graphics/nifskope
parent79c7d103bc9de24db11e959c985bc2cb9c732308 (diff)
downloadnixpkgs-79c9adce657dd6d3a73cc830fe4f5316fa9dcd26.tar
nixpkgs-79c9adce657dd6d3a73cc830fe4f5316fa9dcd26.tar.gz
nixpkgs-79c9adce657dd6d3a73cc830fe4f5316fa9dcd26.tar.bz2
nixpkgs-79c9adce657dd6d3a73cc830fe4f5316fa9dcd26.tar.lz
nixpkgs-79c9adce657dd6d3a73cc830fe4f5316fa9dcd26.tar.xz
nixpkgs-79c9adce657dd6d3a73cc830fe4f5316fa9dcd26.tar.zst
nixpkgs-79c9adce657dd6d3a73cc830fe4f5316fa9dcd26.zip
nifskope: Fix build
https://hydra.nixos.org/build/60608938
Diffstat (limited to 'pkgs/tools/graphics/nifskope')
-rw-r--r--pkgs/tools/graphics/nifskope/default.nix6
-rw-r--r--pkgs/tools/graphics/nifskope/gcc-6.patch123
2 files changed, 127 insertions, 2 deletions
diff --git a/pkgs/tools/graphics/nifskope/default.nix b/pkgs/tools/graphics/nifskope/default.nix
index f66d01ef7aa..19aa7f00f14 100644
--- a/pkgs/tools/graphics/nifskope/default.nix
+++ b/pkgs/tools/graphics/nifskope/default.nix
@@ -4,10 +4,12 @@ stdenv.mkDerivation rec {
   name = "nifskope-1.1.3";
 
   src = fetchurl {
-    url = "mirror://sourceforge/niftools/${name}.tar.bz2";
+    url = "https://github.com/niftools/nifskope/releases/download/${name}/${name}.tar.bz2";
     sha256 = "0fcvrcjyvivww10sjhxamcip797b9ykbf5p3rm2k24xhkwdaqp72";
   };
 
+  patches = [ ./gcc-6.patch ];
+
   buildInputs = [ qt4 ];
 
   nativeBuildInputs = [ qmake4Hook ];
@@ -46,7 +48,7 @@ stdenv.mkDerivation rec {
     ''; # */
 
   meta = {
-    homepage = http://niftools.sourceforge.net/;
+    homepage = https://github.com/niftools/nifskope/;
     description = "A tool for analyzing and editing NetImmerse/Gamebryo '*.nif' files";
     maintainers = [ stdenv.lib.maintainers.eelco ];
     platforms = stdenv.lib.platforms.linux;
diff --git a/pkgs/tools/graphics/nifskope/gcc-6.patch b/pkgs/tools/graphics/nifskope/gcc-6.patch
new file mode 100644
index 00000000000..2bb8af9cfe4
--- /dev/null
+++ b/pkgs/tools/graphics/nifskope/gcc-6.patch
@@ -0,0 +1,123 @@
+Based on https://github.com/niftools/nifskope/commit/7261b0a119a549b11006d8e41ba990d706171f1c
+
+diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/ColorBlock.cpp nifskope-1.1.3/gl/dds/ColorBlock.cpp
+--- nifskope-1.1.3-orig/gl/dds/ColorBlock.cpp	2012-11-17 23:40:31.000000000 +0100
++++ nifskope-1.1.3/gl/dds/ColorBlock.cpp	2017-09-10 10:50:36.766909836 +0200
+@@ -78,8 +78,8 @@
+ 

+ void ColorBlock::init(const Image * img, uint x, uint y)

+ {

+-	const uint bw = min(img->width() - x, 4U);

+-	const uint bh = min(img->height() - y, 4U);

++	const uint bw = std::min(img->width() - x, 4U);

++	const uint bh = std::min(img->height() - y, 4U);

+ 

+ 	static int remainder[] = {

+ 		0, 0, 0, 0,

+diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/Common.h nifskope-1.1.3/gl/dds/Common.h
+--- nifskope-1.1.3-orig/gl/dds/Common.h	2012-11-17 23:40:31.000000000 +0100
++++ nifskope-1.1.3/gl/dds/Common.h	2017-09-10 10:48:08.462099032 +0200
+@@ -33,14 +33,10 @@
+ #ifndef _DDS_COMMON_H

+ #define _DDS_COMMON_H

+ 

+-#ifndef min

+-#define min(a,b) ((a) <= (b) ? (a) : (b))

+-#endif

+-#ifndef max

+-#define max(a,b) ((a) >= (b) ? (a) : (b))

+-#endif

++#include <algorithm>

++

+ #ifndef clamp

+-#define clamp(x,a,b) min(max((x), (a)), (b))

++#define clamp(x,a,b) std::min( std::max( (x), (a) ), (b) )

+ #endif

+ 

+ template<typename T>

+diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/DirectDrawSurface.cpp nifskope-1.1.3/gl/dds/DirectDrawSurface.cpp
+--- nifskope-1.1.3-orig/gl/dds/DirectDrawSurface.cpp	2012-11-17 23:40:31.000000000 +0100
++++ nifskope-1.1.3/gl/dds/DirectDrawSurface.cpp	2017-09-10 10:48:45.912056969 +0200
+@@ -63,6 +63,7 @@
+ #include "DirectDrawSurface.h"

+ #include "BlockDXT.h"

+ #include "PixelFormat.h"

++#include "Common.h"

+ 

+ #include <stdio.h> // printf

+ #include <math.h>  // sqrt

+@@ -685,8 +686,8 @@
+ 	// Compute width and height.

+ 	for (uint m = 0; m < mipmap; m++)

+ 	{

+-		w = max(1U, w / 2);

+-		h = max(1U, h / 2);

++		w = std::max(1U, w / 2);

++		h = std::max(1U, h / 2);

+ 	}

+ 	

+ 	img->allocate(w, h);

+@@ -787,9 +788,9 @@
+ 			readBlock(&block);

+ 			

+ 			// Write color block.

+-			for (uint y = 0; y < min(4U, h-4*by); y++)

++			for (uint y = 0; y < std::min(4U, h-4*by); y++)

+ 			{

+-				for (uint x = 0; x < min(4U, w-4*bx); x++)

++				for (uint x = 0; x < std::min(4U, w-4*bx); x++)

+ 				{

+ 					img->pixel(4*bx+x, 4*by+y) = block.color(x, y);

+ 				}

+@@ -909,9 +910,9 @@
+ 	

+ 	for (uint m = 0; m < mipmap; m++)

+ 	{

+-		w = max(1U, w / 2);

+-		h = max(1U, h / 2);

+-		d = max(1U, d / 2);

++		w = std::max(1U, w / 2);

++		h = std::max(1U, h / 2);

++		d = std::max(1U, d / 2);

+ 	}

+ 

+ 	if (header.pf.flags & DDPF_FOURCC)

+diff -ru -x '*~' nifskope-1.1.3-orig/gl/gltexloaders.cpp nifskope-1.1.3/gl/gltexloaders.cpp
+--- nifskope-1.1.3-orig/gl/gltexloaders.cpp	2012-11-17 23:40:31.000000000 +0100
++++ nifskope-1.1.3/gl/gltexloaders.cpp	2017-09-10 10:51:23.586839810 +0200
+@@ -1736,8 +1736,8 @@
+ 			

+ 			// generate next offset, resize

+ 			mipmapOffset += mipmapWidth * mipmapHeight * 4;

+-			mipmapWidth = max( 1, mipmapWidth / 2 );

+-			mipmapHeight = max( 1, mipmapHeight / 2 );

++			mipmapWidth = std::max( 1, mipmapWidth / 2 );

++			mipmapHeight = std::max( 1, mipmapHeight / 2 );

+ 		}

+ 		

+ 		// set total pixel size

+@@ -1932,11 +1932,11 @@
+ 			{

+ 				if ( ddsHeader.ddsPixelFormat.dwFourCC == FOURCC_DXT1 )

+ 				{

+-					mipmapOffset += max( 8, ( mipmapWidth * mipmapHeight / 2 ) );

++					mipmapOffset += std::max( 8, ( mipmapWidth * mipmapHeight / 2 ) );

+ 				}

+ 				else if ( ddsHeader.ddsPixelFormat.dwFourCC == FOURCC_DXT5 )

+ 				{

+-					mipmapOffset += max( 16, ( mipmapWidth * mipmapHeight ) );

++					mipmapOffset += std::max( 16, ( mipmapWidth * mipmapHeight ) );

+ 				}

+ 			}

+ 			else if ( ddsHeader.ddsPixelFormat.dwBPP == 24 )

+@@ -1947,8 +1947,8 @@
+ 			{

+ 				mipmapOffset += ( mipmapWidth * mipmapHeight * 4 );

+ 			}

+-			mipmapWidth = max( 1, mipmapWidth / 2 );

+-			mipmapHeight = max( 1, mipmapHeight / 2 );

++			mipmapWidth = std::max( 1, mipmapWidth / 2 );

++			mipmapHeight = std::max( 1, mipmapHeight / 2 );

+ 		}

+ 		

+ 		nif->set<quint32>( iData, "Num Pixels", mipmapOffset );