1{ stdenv, fetchFromGitHub, fetchurl, nasm, perl, python, libuuid, mtools, makeWrapper }:
2
3stdenv.mkDerivation rec {
4 name = "syslinux-2015-11-09";
5
6 src = fetchFromGitHub {
7 owner = "geneC";
8 repo = "syslinux";
9 rev = "0cc9a99e560a2f52bcf052fd85b1efae35ee812f";
10 sha256 = "0wk3r5ki4lc334f9jpml07wpl8d0bnxi9h1l4h4fyf9a0d7n4kmw";
11 };
12
13 patches = [
14 ./perl-deps.patch
15 (fetchurl {
16 # ldlinux.elf: Not enough room for program headers, try linking with -N
17 name = "not-enough-room.patch";
18 url = "https://anonscm.debian.org/cgit/collab-maint/syslinux.git/plain/"
19 + "debian/patches/0014_fix_ftbfs_no_dynamic_linker.patch?id=a556ad7";
20 sha256 = "0ijqjsjmnphmvsx0z6ppnajsfv6xh6crshy44i2a5klxw4nlvrsw";
21 })
22 ];
23
24 postPatch = ''
25 substituteInPlace Makefile --replace /bin/pwd $(type -P pwd)
26 substituteInPlace gpxe/src/Makefile.housekeeping --replace /bin/echo $(type -P echo)
27 substituteInPlace utils/ppmtolss16 --replace /usr/bin/perl $(type -P perl)
28 substituteInPlace gpxe/src/Makefile --replace /usr/bin/perl $(type -P perl)
29
30 # fix tests
31 substituteInPlace tests/unittest/include/unittest/unittest.h \
32 --replace /usr/include/ ""
33 '';
34
35 nativeBuildInputs = [ nasm perl python ];
36 buildInputs = [ libuuid makeWrapper ];
37
38 enableParallelBuilding = false; # Fails very rarely with 'No rule to make target: ...'
39 hardeningDisable = [ "pic" "stackprotector" "fortify" ];
40
41 stripDebugList = "bin sbin share/syslinux/com32";
42
43 makeFlags = [
44 "BINDIR=$(out)/bin"
45 "SBINDIR=$(out)/sbin"
46 "LIBDIR=$(out)/lib"
47 "INCDIR=$(out)/include"
48 "DATADIR=$(out)/share"
49 "MANDIR=$(out)/share/man"
50 "PERL=perl"
51 "bios"
52 ];
53
54 doCheck = false; # fails. some fail in a sandbox, others require qemu
55
56 postInstall = ''
57 wrapProgram $out/bin/syslinux \
58 --prefix PATH : "${mtools}/bin"
59
60 # Delete com32 headers to save space, nobody seems to be using them
61 rm -rf $out/share/syslinux/com32
62 '';
63
64 meta = with stdenv.lib; {
65 homepage = http://www.syslinux.org/;
66 description = "A lightweight bootloader";
67 license = licenses.gpl2;
68 platforms = [ "i686-linux" "x86_64-linux" ];
69 };
70}