9 enableXwinGraphics ? false,
14 "${if enableXwinGraphics then "XWIN" else "CURSES"}GRAPHX"
20 lib.optionals enableXwinGraphics [ "x11" ]
21 ++ lib.optionals (!enableXwinGraphics) [ "ncurses" ];
23 stdenv.mkDerivation (finalAttrs: {
28 url = "http://www.koth.org/pmars/pmars-${finalAttrs.version}.zip";
29 hash = "sha256-68zsH9HWWp13pozjMajayS/VhY8iTosUp1CvcAmj/dE=";
33 # Error under Clang due to global "round" variable: redefinition of 'round' as different kind of symbol
34 ./0001-fix-round-redefinition.patch
36 # call to undeclared function 'sighandler' & undefined sighandler on Darwin
37 ./0002-fix-sighandler.patch
41 substituteInPlace src/Makefile \
42 --replace-fail 'CC = gcc' "CC = $CC" \
43 --replace-fail '@strip' "@$STRIP" \
44 --replace-fail 'CFLAGS = -O -DEXT94 -DXWINGRAPHX -DPERMUTATE -DRWLIMIT' "CFLAGS = ${
45 lib.concatMapStringsSep " " (opt: "-D${opt}") options
49 ) "$($PKG_CONFIG --cflags ${lib.strings.concatStringsSep " " pkgConfigLibs})"
51 --replace-fail 'LIB = -L/usr/X11R6/lib -lX11' "LIB = ${
54 ) "$($PKG_CONFIG --libs ${lib.strings.concatStringsSep " " pkgConfigLibs})"
58 nativeBuildInputs = [ installShellFiles ] ++ lib.optionals (pkgConfigLibs != [ ]) [ pkg-config ];
61 lib.optionals enableXwinGraphics [ libX11 ]
62 ++ lib.optionals (!enableXwinGraphics) [ ncurses ];
68 hardeningDisable = [ "format" ];
70 enableParallelBuilding = true;
75 install -Dm755 pmars $out/bin/pmars
77 mkdir -p $out/share/pmars
78 cp -R -t $out/share/pmars/ ../{AUTHORS,COPYING,README,config,warriors}
80 installManPage ../doc/pmars.6
82 mkdir -p $out/share/doc/pmars
83 cp -t $out/share/doc/pmars/ ../doc/{primer.*,redcode.ref}
93 description = "Official Core War simulator";
95 Portable MARS is the official Core War simulator of the ICWS and the rec.games.corewar newsgroup. pMARS serves as
96 a test bed for new Redcode standards and tournament styles. It has also been used in genetic algorithm experiments
97 and as an assembly language teaching aid. pMARS is under active development by a group of Core War enthusiasts who
98 put a lot of time into this project.
100 homepage = "http://www.koth.org/pmars/";
101 license = lib.licenses.gpl2Plus;
102 mainProgram = "pmars";
103 maintainers = with lib.maintainers; [ OPNA2608 ];
104 platforms = lib.platforms.unix;