forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / by-name / z8 / z88dk / package.nix
blobc2b36703d51d4b608fe8ec9f900425c6a85e1118
2   fetchFromGitHub,
3   lib,
4   stdenv,
5   unzip,
6   libxml2,
7   gmp,
8   m4,
9   uthash,
10   which,
11   pkg-config,
12   perl,
13   perlPackages,
14   fetchurl,
17 let
18   # Perl packages used by this project.
19   # TODO: put these into global perl-packages.nix once this is submitted.
20   ObjectTinyRW = perlPackages.buildPerlPackage {
21     pname = "Object-Tiny-RW";
22     version = "1.07";
23     src = fetchurl {
24       url = "mirror://cpan/authors/id/S/SC/SCHWIGON/object-tiny-rw/Object-Tiny-RW-1.07.tar.gz";
25       hash = "sha256-NbQIy9d4ZcMnRJJApPBSej+W6e/aJ8rkb5E7rD7GVgs=";
26     };
27     meta = {
28       description = "A date object with as little code as possible (and rw accessors)";
29       license = with lib.licenses; [ artistic1 gpl1Plus ];
30     };
31   };
33   IteratorSimpleLookahead = perlPackages.buildPerlPackage {
34     pname = "Iterator-Simple-Lookahead";
35     version = "0.09";
36     src = fetchurl {
37       url = "mirror://cpan/authors/id/P/PS/PSCUST/Iterator-Simple-Lookahead-0.09.tar.gz";
38       hash = "sha256-FmPE1xdU8LAXS21+H4DJaQ87qDi4Q4UkLawsUAqseZw=";
39     };
40     propagatedBuildInputs = with perlPackages; [
41       ClassAccessor IteratorSimple
42     ];
43     meta = {
44       description = "Simple iterator with lookahead and unget";
45       license = with lib.licenses; [ artistic1 gpl2Only ];
46     };
47   };
49   AsmPreproc = perlPackages.buildPerlPackage {
50     pname = "Asm-Preproc";
51     version = "1.03";
52     src = fetchurl {
53       url = "mirror://cpan/authors/id/P/PS/PSCUST/Asm-Preproc-1.03.tar.gz";
54       hash = "sha256-pVTpIqGxZpBxZlAbXuGDapuOxsp3uM/AM5dKUxlej1M=";
55     };
56     propagatedBuildInputs = [
57         IteratorSimpleLookahead
58       ] ++ (with perlPackages; [
59         IteratorSimple
60         TextTemplate
61         DataDump
62         FileSlurp
63       ]);
64     meta = {
65       description = "Preprocessor to be called from an assembler";
66       license = with lib.licenses; [ artistic1 gpl2Only ];
67     };
68   };
70   CPUZ80Assembler = perlPackages.buildPerlPackage {
71     pname = "CPU-Z80-Assembler";
72     version = "2.25";
73     src = fetchurl {
74       url = "mirror://cpan/authors/id/P/PS/PSCUST/CPU-Z80-Assembler-2.25.tar.gz";
75       hash = "sha256-cJ8Fl2KZw9/bnBDUzFuwwdw9x23OUvcftk78kw7abdU=";
76     };
77     buildInputs = [ AsmPreproc ] ++ (with perlPackages; [
78         CaptureTiny
79         RegexpTrie
80         PathTiny
81         ClassAccessor
82       ]);
83     meta = {
84       description = "Functions to assemble a set of Z80 assembly instructions";
85       license = with lib.licenses; [ artistic1 gpl2Only ];
86     };
87   };
89 stdenv.mkDerivation (finalAttrs: {
90   pname = "z88dk";
91   version = "2.3";
93   src = fetchFromGitHub {
94     owner = "z88dk";
95     repo = "z88dk";
96     rev = "v${finalAttrs.version}";
97     hash = "sha256-CHTORgK6FYIO6n+cvTUX4huY2Ek5FuHrs40QN5NZX44=";
98     fetchSubmodules = true;
99   };
101   postPatch = ''
102     # we dont rely on build.sh :
103     export PATH="$PWD/bin:$PATH" # needed to have zcc in testsuite
104     export ZCCCFG=$PWD/lib/config/
106     # we don't want to build zsdcc since it required network (svn)
107     # we test in checkPhase
108     substituteInPlace Makefile \
109       --replace 'testsuite bin/z88dk-lib$(EXESUFFIX)' 'bin/z88dk-lib$(EXESUFFIX)'\
110       --replace 'ALL_EXT = bin/zsdcc$(EXESUFFIX)' 'ALL_EXT ='
112     # rc2014.lib not created, making corresponding tests fail. Comment out.
113     substituteInPlace  test/suites/make.config \
114       --replace 'zcc +rc2014'            '#zcc +rc2014' \
115       --replace '@$(MACHINE) -pc 0x9000' '#@$(MACHINE) -pc 0x9000'
117     # The following tests don't pass.
118     rm src/z80asm/t/issue_0341.t
119     rm src/z80asm/t/z80asm_lib.t
120   '';
122   # Parallel building is not working yet with the upstream Makefiles.
123   # Explicitly switch this off for now.
124   enableParallelBuilding = false;
126   doCheck = true;
127   checkPhase = ''
128     # Need to build libs first, Makefile deps not fully defined
129     make libs      $makeFlags
130     make testsuite $makeFlags
131     make -k test   $makeFlags
132   '';
134   short_rev = builtins.substring 0 7 finalAttrs.src.rev;
135   makeFlags = [
136     "git_rev=${finalAttrs.short_rev}"
137     "version=${finalAttrs.version}"
138     "PREFIX=$(out)"
139     "git_count=0"
140   ];
142   nativeBuildInputs = [
143     which
144     unzip
145     m4
146     perl
147     pkg-config
149     # Local perl packages
150     AsmPreproc
151     CPUZ80Assembler
152     ObjectTinyRW
153   ] ++ (with perlPackages; [
154     CaptureTiny
155     DataHexDump
156     ModernPerl
157     PathTiny
158     RegexpCommon
159     TestHexDifferences
160     TextDiff
161     RegexpTrie
162   ]);
164   buildInputs = [
165     libxml2
166     uthash
167     gmp
168   ];
170   preInstall = ''
171     mkdir -p $out/{bin,share}
172   '';
174   installTargets = [
175     "libs"
176     "install"
177   ];
179   meta = with lib; {
180     homepage = "https://www.z88dk.org";
181     description = "z80 Development Kit";
182     license = licenses.clArtistic;
183     maintainers = [ maintainers.siraben ];
184     platforms = platforms.unix;
185   };