1{ lib, stdenv, fetchurl, autoconf, bison, boost, flex, texinfo, zlib, gputils ? null
2, excludePorts ? [] }:
3
4let
5 # choices: mcs51 z80 z180 r2k r3ka gbz80 tlcs90 ds390 ds400 pic14 pic16 hc08 s08 stm8
6 excludedPorts = excludePorts ++ (lib.optionals (gputils == null) [ "pic14" "pic16" ]);
7in
8
9stdenv.mkDerivation rec {
10 pname = "sdcc";
11 version = "4.2.0";
12
13 src = fetchurl {
14 url = "mirror://sourceforge/sdcc/sdcc-src-${version}.tar.bz2";
15 sha256 = "sha256-tJuuHSO81gV6gsT/5WE/nNDLz9HpQOnYTEv+nfCowFM=";
16 };
17
18 enableParallelBuilding = true;
19
20 buildInputs = [ boost gputils texinfo zlib ];
21
22 nativeBuildInputs = [ autoconf bison flex ];
23
24 configureFlags = map (f: "--disable-${f}-port") excludedPorts;
25
26 preConfigure = ''
27 if test -n "''${dontStrip-}"; then
28 export STRIP=none
29 fi
30 '';
31
32 meta = with lib; {
33 description = "Small Device C Compiler";
34 longDescription = ''
35 SDCC is a retargettable, optimizing ANSI - C compiler suite that targets
36 the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), Maxim
37 (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) HC08 based
38 (hc08, s08) and Zilog Z80 based MCUs (z80, z180, gbz80, Rabbit 2000/3000,
39 Rabbit 3000A). Work is in progress on supporting the Microchip PIC16 and
40 PIC18 targets. It can be retargeted for other microprocessors.
41 '';
42 homepage = "https://sdcc.sourceforge.net/";
43 license = with licenses; if (gputils == null) then gpl2Plus else unfreeRedistributable;
44 maintainers = with maintainers; [ bjornfor yorickvp ];
45 platforms = platforms.all;
46 };
47}