1{ fetchFromGitHub, lib, stdenv, makeWrapper, unzip, libxml2, m4, uthash, which }:
2
3stdenv.mkDerivation rec {
4 pname = "z88dk";
5 version = "2.2";
6
7 src = fetchFromGitHub {
8 owner = "z88dk";
9 repo = "z88dk";
10 rev = "v${version}";
11 sha256 = "sha256-vf/hEmcl6R3nsc66G6eETNeW0SV/odk14XIpEPPAbKo=";
12 fetchSubmodules = true;
13 };
14
15 postPatch = ''
16 # we dont rely on build.sh :
17 export PATH="$PWD/bin:$PATH" # needed to have zcc in testsuite
18 export ZCCCFG=$PWD/lib/config/
19 # we don't want to build zsdcc since it required network (svn)
20 # we test in checkPhase
21 substituteInPlace Makefile \
22 --replace 'testsuite bin/z88dk-lib$(EXESUFFIX)' 'bin/z88dk-lib$(EXESUFFIX)'\
23 --replace 'ALL_EXT = bin/zsdcc$(EXESUFFIX)' 'ALL_EXT ='
24 '';
25
26 checkPhase = ''
27 make testsuite
28 '';
29 #failed on Issue_1105_function_pointer_calls
30 doCheck = stdenv.hostPlatform.system != "aarch64-linux";
31
32 #_FORTIFY_SOURCE requires compiling with optimization (-O)
33 env.NIX_CFLAGS_COMPILE = "-O";
34
35 short_rev = builtins.substring 0 7 src.rev;
36 makeFlags = [
37 "git_rev=${short_rev}"
38 "version=${version}"
39 "DESTDIR=$(out)"
40 "git_count=0"
41 ];
42
43 nativeBuildInputs = [ which makeWrapper unzip ];
44 buildInputs = [ libxml2 m4 uthash ];
45
46 preInstall = ''
47 mkdir -p $out/{bin,share}
48 '';
49
50 installTargets = [ "libs" "install" ];
51
52 meta = with lib; {
53 homepage = "https://www.z88dk.org";
54 description = "z80 Development Kit";
55 license = licenses.clArtistic;
56 maintainers = [ maintainers.siraben ];
57 platforms = platforms.unix;
58 };
59}