about summary refs log tree commit diff
path: root/pkgs/tools/misc/mprime
diff options
context:
space:
mode:
authorSvein Ove Aas <svein.ove@aas.no>2016-02-16 16:37:45 +0000
committerSvein Ove Aas <svein.ove@aas.no>2016-02-16 16:37:45 +0000
commit6efcbd89506590a2d16fc3ca8d540ae3e632e219 (patch)
treee2d0474d0077e114265d9a4c0f7d4766cad29b65 /pkgs/tools/misc/mprime
parentd13adb4f8d67e70856e09112a76f3fe02096f1e3 (diff)
mprime: Init at 28.7
Diffstat (limited to 'pkgs/tools/misc/mprime')
-rw-r--r--pkgs/tools/misc/mprime/default.nix56
-rw-r--r--pkgs/tools/misc/mprime/makefile.patch46
2 files changed, 102 insertions, 0 deletions
diff --git a/pkgs/tools/misc/mprime/default.nix b/pkgs/tools/misc/mprime/default.nix
new file mode 100644
index 0000000000000..9a435622c7d78
--- /dev/null
+++ b/pkgs/tools/misc/mprime/default.nix
@@ -0,0 +1,56 @@
+{ stdenv, fetchurl, unzip, pkgconfig, curl }:
+
+let
+  srcDir =
+    if stdenv.system == "x86_64-linux" then "linux64"
+    else if stdenv.system == "i686-linux" then "linux"
+    else if stdenv.system == "x86_64-darwin" then "macosx64"
+    else abort "Unsupported platform";
+  gwnum =
+    if stdenv.system == "x86_64-linux" then "make64"
+    else if stdenv.system == "i686-linux" then "makefile"
+    else if stdenv.system == "x86_64-darwin" then "makemac"
+    else abort "Unsupported platform";
+in
+
+stdenv.mkDerivation {
+  name = "mprime-28.7";
+
+  src = fetchurl {
+    url = http://www.mersenne.org/ftp_root/gimps/p95v287.source.zip;
+    sha256 = "1k3gxhs3g8hfghzpmidhcwpwyayj8r83v8zjai1z4xgsql4jwby1";
+  };
+
+  unpackCmd = "unzip -d src -q $curSrc";
+
+  buildInputs = [ unzip pkgconfig curl ];
+
+  patches = [ ./makefile.patch ];
+
+  buildPhase = ''
+    make -C gwnum -f ${gwnum}
+    echo 'override CFLAGS := $(CFLAGS)' $(pkg-config --cflags libcurl) >> ${srcDir}/makefile
+    echo 'override LIBS := $(LIBS)' $(pkg-config --libs libcurl) >> ${srcDir}/makefile
+    make -C ${srcDir}
+  '';
+
+  installPhase = ''
+    install -D ${srcDir}/mprime $out/bin/mprime
+  '';
+  
+  meta = {
+    description = "Mersenne prime search / System stability tester";
+    longDescription = ''
+      MPrime is the Linux command-line interface version of Prime95, to be run
+      in a text terminal or in a terminal emulator window as a remote shell
+      client. It is identical to Prime95 in functionality, except it lacks a
+      graphical user interface.
+    '';
+    homepage = http://www.mersenne.org/;
+    # Unfree, because of a license requirement to share prize money if you find
+    # a suitable prime. http://www.mersenne.org/legal/#EULA
+    license = stdenv.lib.licenses.unfree;
+    # Untested on linux-32 and osx. Works in theory.
+    platforms = ["i686-linux" "x86_64-linux" "x86_64-darwin"];
+  };
+}
diff --git a/pkgs/tools/misc/mprime/makefile.patch b/pkgs/tools/misc/mprime/makefile.patch
new file mode 100644
index 0000000000000..7f758af7b7c4c
--- /dev/null
+++ b/pkgs/tools/misc/mprime/makefile.patch
@@ -0,0 +1,46 @@
+diff -ru orig/linux/makefile patched/linux/makefile
+--- orig/linux/makefile	2015-08-09 21:06:18.000000000 +0100
++++ patched/linux/makefile	2016-02-16 16:25:45.988662423 +0000
+@@ -25,8 +25,8 @@
+ CPP = g++
+ CPPFLAGS = -I.. -I../gwnum -O2 -march=i486 -malign-double
+ 
+-LFLAGS = -Wl,-M -Wl,-L/usr/local/lib
+-LIBS = ../gwnum/gwnum.a ../gwnum/gwnum.ld -lm -lpthread -Wl,-Bstatic -lcurl -Wl,-Bdynamic -lrt -lstdc++ -ldl
++LFLAGS =
++LIBS = ../gwnum/gwnum.a ../gwnum/gwnum.ld -lm -lpthread -lrt -lstdc++ -ldl
+ 
+ FACTOROBJ = factor32.o
+ LINUXOBJS = prime.o menu.o
+diff -ru orig/linux64/makefile patched/linux64/makefile
+--- orig/linux64/makefile	2015-08-09 21:06:20.000000000 +0100
++++ patched/linux64/makefile	2016-02-16 16:25:57.076531585 +0000
+@@ -13,13 +13,13 @@
+ #	LIBS = ../gwnum/gwnum.a ../gwnum/gwnum.ld -lm -lpthread -Wl,-Bstatic $(shell pkg-config --static --libs libcurl) -lstdc++ -Wl,-Bdynamic -ldl
+ 
+ CC = gcc
+-CFLAGS = -I.. -I../gwnum -I/usr/local/include -DX86_64 -O2 
++CFLAGS = -I.. -I../gwnum -I/usr/local/include -DX86_64 -O2
+ 
+ CPP = g++
+ CPPFLAGS = -I.. -I../gwnum -DX86_64 -O2
+ 
+-LFLAGS = -Wl,-M -Wl,-L/usr/local/lib
+-LIBS = ../gwnum/gwnum.a ../gwnum/gwnum.ld -lm -lpthread -Wl,-Bstatic -lcurl -Wl,-Bdynamic -lrt -lstdc++ -ldl
++LFLAGS =
++LIBS = ../gwnum/gwnum.a ../gwnum/gwnum.ld -lm -lpthread -lrt -lstdc++ -ldl
+ 
+ FACTOROBJ = factor64.o
+ LINUXOBJS = prime.o menu.o
+diff -ru orig/macosx64/makefile patched/macosx64/makefile
+--- orig/macosx64/makefile	2015-08-09 21:06:22.000000000 +0100
++++ patched/macosx64/makefile	2016-02-16 16:19:03.988415925 +0000
+@@ -10,7 +10,7 @@
+ CPPFLAGS = -I.. -I../gwnum -I../linux -O2 -DX86_64 -DCOMMAND_LINE_MPRIME -m64
+ 
+ LFLAGS = -m64 -Wl,-no_pie
+-LIBS   = ../gwnum/amd64/release/gwnum.a -lm -lpthread -lcurl -framework IOKit -framework CoreFoundation -lstdc++
++LIBS   = ../gwnum/amd64/release/gwnum.a -lm -lpthread -framework IOKit -framework CoreFoundation -lstdc++
+ 
+ FACTOROBJ = ../prime95/macosx64/factor64.o
+ OBJS = prime.o menu.o