Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 130 lines 3.2 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 autoconf, 6 bison, 7 boost, 8 flex, 9 gputils, 10 texinfo, 11 zlib, 12 withGputils ? false, 13 excludePorts ? [ ], 14}: 15 16assert 17 lib.subtractLists [ 18 "ds390" 19 "ds400" 20 "gbz80" 21 "hc08" 22 "mcs51" 23 "pic14" 24 "pic16" 25 "r2k" 26 "r3ka" 27 "s08" 28 "stm8" 29 "tlcs90" 30 "z80" 31 "z180" 32 ] excludePorts == [ ]; 33stdenv.mkDerivation (finalAttrs: { 34 pname = "sdcc"; 35 version = "4.5.0"; 36 37 src = fetchurl { 38 url = "mirror://sourceforge/sdcc/sdcc-src-${finalAttrs.version}.tar.bz2"; 39 hash = "sha256-1QMEN/tDa7HZOo29v7RrqqYGEzGPT7P1hx1ygV0e7YA="; 40 }; 41 42 # TODO: sdcc version 4.5.0 does not currently produce a man output. 43 # Until the fix to sdcc's makefiles is released, this workaround 44 # conditionally withholds the man output on darwin. 45 # 46 # sdcc's tracking issue: 47 # <https://sourceforge.net/p/sdcc/bugs/3848/> 48 outputs = [ 49 "out" 50 "doc" 51 ] 52 ++ lib.optionals (!stdenv.isDarwin) [ 53 "man" 54 ]; 55 56 enableParallelBuilding = true; 57 58 nativeBuildInputs = [ 59 autoconf 60 bison 61 flex 62 ]; 63 64 buildInputs = [ 65 boost 66 texinfo 67 zlib 68 ] 69 ++ lib.optionals withGputils [ 70 gputils 71 ]; 72 73 # sdcc 4.5.0 massively rewrote sim/ucsim/Makefile.in, and lost the `.PHONY` 74 # rule in the process. As a result, on macOS (which uses a case-insensitive 75 # filesystem), the INSTALL file keeps the `install` target in the ucsim 76 # directory from running. Nothing else creates the `man` output, causing the 77 # entire build to fail. 78 # 79 # TODO: remove this when updating to the next release - it's been fixed in 80 # upstream sdcc r15384 <https://sourceforge.net/p/sdcc/code/15384/>. 81 82 postPatch = '' 83 if grep -q '\.PHONY:.*install' sim/ucsim/Makefile.in; then 84 echo 'Upstream has added `.PHONY: install` rule; must remove `postPatch` from the Nix file.' >&2 85 exit 1 86 fi 87 echo '.PHONY: install' >> sim/ucsim/Makefile.in 88 ''; 89 90 configureFlags = 91 let 92 excludedPorts = 93 excludePorts 94 ++ (lib.optionals (!withGputils) [ 95 "pic14" 96 "pic16" 97 ]); 98 in 99 map (f: "--disable-${f}-port") excludedPorts; 100 101 preConfigure = '' 102 if test -n "''${dontStrip-}"; then 103 export STRIP=none 104 fi 105 ''; 106 107 # ${src}/support/cpp/gcc/Makefile.in states: 108 # We don't want to compile the compilers with -fPIE, it make PCH fail. 109 hardeningDisable = [ "pie" ]; 110 111 meta = { 112 homepage = "https://sdcc.sourceforge.net/"; 113 description = "Small Device C Compiler"; 114 longDescription = '' 115 SDCC is a retargettable, optimizing ANSI - C compiler suite that targets 116 the Intel MCS51 based microprocessors (8031, 8032, 8051, 8052, etc.), 117 Maxim (formerly Dallas) DS80C390 variants, Freescale (formerly Motorola) 118 HC08 based (hc08, s08) and Zilog Z80 based MCUs (z80, z180, gbz80, Rabbit 119 2000/3000, Rabbit 3000A). Work is in progress on supporting the Microchip 120 PIC16 and PIC18 targets. It can be retargeted for other microprocessors. 121 ''; 122 license = if withGputils then lib.licenses.unfreeRedistributable else lib.licenses.gpl2Plus; 123 mainProgram = "sdcc"; 124 maintainers = with lib.maintainers; [ 125 bjornfor 126 yorickvp 127 ]; 128 platforms = lib.platforms.all; 129 }; 130})