summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/c6/c64-debugger/package.nix
blob: 2a1d6e9525bb6ecb88d88292017ca22218c06f6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{
  lib,
  stdenv,
  fetchgit,
  alsa-lib,
  gtk3,
  libGL,
  libGLU,
  libx11,
  pkg-config,
  upx,
  libxcb-util,
}:

stdenv.mkDerivation {
  pname = "c64-debugger";
  version = "0.64.58.6";

  src = fetchgit {
    url = "https://git.code.sf.net/p/c64-debugger/code";
    rev = "f97772e3f5c8b4fa99e8ed212ed1c4cb1e2389f1";
    hash = "sha256-3SR73AHQlYSEYpJLtQ/aJ1UITZGq7aA9tQKxBsn/yuc=";
  };

  buildInputs = [
    alsa-lib
    gtk3
    libGL
    libGLU
    libx11
    libxcb-util
  ];

  nativeBuildInputs = [
    upx
    pkg-config
  ];

  postPatch = ''
    # Disable default definition of RUN_COMMODORE64
    sed -i 's|^#define RUN_COMMODORE64|//#define RUN_COMMODORE64|' MTEngine/Games/c64/C64D_Version.h
  '';

  buildPhase = ''
    runHook preBuild

    # Build C64 debugger
    make -C MTEngine \
      CFLAGS="-w -O2 -fcommon -std=gnu17" \
      CXXFLAGS="-w -O2 --std=c++11" \
      DEFINES="-DRUN_COMMODORE64" \
      -j$NIX_BUILD_CORES
    mv MTEngine/c64debugger c64debugger
    make -C MTEngine clean

    # Build 65XE debugger
    make -C MTEngine \
      CFLAGS="-w -O2 -fcommon -std=gnu17" \
      CXXFLAGS="-w -O2 --std=c++11" \
      DEFINES="-DRUN_ATARI" \
      -j$NIX_BUILD_CORES
    mv MTEngine/c64debugger 65xedebugger
    make -C MTEngine clean

    # Build NES debugger
    make -C MTEngine \
      CFLAGS="-w -O2 -fcommon -std=gnu17" \
      CXXFLAGS="-w -O2 --std=c++11" \
      DEFINES="-DRUN_NES" \
      -j$NIX_BUILD_CORES
    mv MTEngine/c64debugger nesdebugger

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    install -d "$out/bin"
    install -d "$out/share/doc"
    install -m 755 c64debugger 65xedebugger nesdebugger "$out/bin"
    install -m 644 MTEngine/Assets/*.txt "$out/share/doc"
    install -m 644 MTEngine/Assets/*.pdf "$out/share/doc"

    runHook postInstall
  '';

  env = {
    NIX_CFLAGS_COMPILE = toString [
      "-Wno-error=narrowing"
      "-Wno-error=implicit-function-declaration"
      "-Wno-error=int-conversion"
      "-Wno-error=incompatible-pointer-types"
    ];
  };

  meta = {
    homepage = "https://sourceforge.net/projects/c64-debugger";
    description = "Commodore 64, Atari XL/XE and NES code and memory debugger that works in real time";
    license = with lib.licenses; [
      gpl3Only # c64-debugger
      mit # MTEngine
      # emulators included in c64-debugger
      gpl2Plus # VICE, atari800
      gpl2 # nestopiaue
    ];
    mainProgram = "c64debugger";
    maintainers = [ lib.maintainers.detegr ];
    platforms = lib.platforms.linux;
  };
}