1{ lib, stdenv, fetchpatch, fetchurl, boost }:
2
3stdenv.mkDerivation rec {
4 pname = "source-highlight";
5 version = "3.1.9";
6
7 outputs = [ "out" "doc" "dev" ];
8
9 src = fetchurl {
10 url = "mirror://gnu/src-highlite/${pname}-${version}.tar.gz";
11 sha256 = "148w47k3zswbxvhg83z38ifi85f9dqcpg7icvvw1cm6bg21x4zrs";
12 };
13
14 patches = [
15 # gcc-11 compat upstream patch
16 (fetchpatch {
17 url = "http://git.savannah.gnu.org/cgit/src-highlite.git/patch/?id=904949c9026cb772dc93fbe0947a252ef47127f4";
18 sha256 = "1wnj0jmkmrwjww7qk9dvfxh8h06jdn7mi8v2fvwh95b6x87z5l47";
19 excludes = [ "ChangeLog" ];
20 })
21
22 # Upstream fix for clang-13 and gcc-12 test support
23 (fetchpatch {
24 name = "gcc-12.patch";
25 url = "http://git.savannah.gnu.org/cgit/src-highlite.git/patch/?id=ab9fe5cb9b85c5afab94f2a7f4b6d7d473c14ee9";
26 sha256 = "1v33zd2766k7cdgmajw2lffw9wd7v4f8z01f40z53f6bp608nr62";
27 })
28 ];
29
30 # source-highlight uses it's own binary to generate documentation.
31 # During cross-compilation, that binary was built for the target
32 # platform architecture, so it can't run on the build host.
33 postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
34 substituteInPlace Makefile.in --replace "src doc tests" "src tests"
35 '';
36
37 strictDeps = true;
38 buildInputs = [ boost ];
39
40 configureFlags = [
41 "--with-boost=${boost.out}"
42 "--with-bash-completion=${placeholder "out"}/share/bash-completion/completions"
43 ];
44
45 doCheck = true;
46
47 enableParallelBuilding = true;
48 # Upstream uses the same intermediate files in multiple tests, running
49 # them in parallel by make will eventually break one or more tests.
50 enableParallelChecking = false;
51
52 meta = with lib; {
53 description = "Source code renderer with syntax highlighting";
54 longDescription = ''
55 GNU Source-highlight, given a source file, produces a document
56 with syntax highlighting.
57 '';
58 homepage = "https://www.gnu.org/software/src-highlite/";
59 license = licenses.gpl3Plus;
60 platforms = platforms.unix;
61 maintainers = with maintainers; [ SuperSandro2000 ];
62 };
63}