1 { lib, stdenv, fetchpatch, fetchurl, boost, updateAutotoolsGnuConfigScriptsHook, llvmPackages }:
3 stdenv.mkDerivation rec {
4 pname = "source-highlight";
7 outputs = [ "out" "doc" "dev" ];
10 url = "mirror://gnu/src-highlite/${pname}-${version}.tar.gz";
11 sha256 = "148w47k3zswbxvhg83z38ifi85f9dqcpg7icvvw1cm6bg21x4zrs";
15 # gcc-11 compat upstream patch
17 url = "https://git.savannah.gnu.org/cgit/src-highlite.git/patch/?id=904949c9026cb772dc93fbe0947a252ef47127f4";
18 hash = "sha256-h9DyD+pmlQT5dmKjWI9t0gCIYHe7pYkP55LnOqsE0vI=";
19 excludes = [ "ChangeLog" ];
22 # Upstream fix for clang-13 and gcc-12 test support
24 name = "gcc-12.patch";
25 url = "https://git.savannah.gnu.org/cgit/src-highlite.git/patch/?id=ab9fe5cb9b85c5afab94f2a7f4b6d7d473c14ee9";
26 hash = "sha256-wmSLgLnLuFE+IC6AjxzZp/HEnaOCS1VfY2cac0T7Y+w=";
28 ] ++ lib.optionals stdenv.cc.isClang [
29 # Adds compatibility with C++17 by removing the `register` storage class specifier.
31 name = "remove-register-keyword";
32 url = "https://git.savannah.gnu.org/cgit/src-highlite.git/patch/?id=416b39758dba2c74515584514a959ad1b0ad50d1";
33 hash = "sha256-R5A7IGHhU82EqceMCsuNBanhRz4dFVqiaH8637dr7jw=";
34 includes = [ "lib/*" ];
38 # source-highlight uses it's own binary to generate documentation.
39 # During cross-compilation, that binary was built for the target
40 # platform architecture, so it can't run on the build host.
41 postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
42 substituteInPlace Makefile.in --replace "src doc tests" "src tests"
46 # necessary to build on FreeBSD native pending inclusion of
47 # https://git.savannah.gnu.org/cgit/config.git/commit/?id=e4786449e1c26716e3f9ea182caf472e4dbc96e0
48 nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ];
49 buildInputs = [ boost ]
50 ++ lib.optional (stdenv.targetPlatform.useLLVM or false) (llvmPackages.compiler-rt.override {
55 "--with-boost=${boost.out}"
56 "--with-bash-completion=${placeholder "out"}/share/bash-completion/completions"
61 enableParallelBuilding = true;
62 # Upstream uses the same intermediate files in multiple tests, running
63 # them in parallel by make will eventually break one or more tests.
64 enableParallelChecking = false;
67 description = "Source code renderer with syntax highlighting";
69 GNU Source-highlight, given a source file, produces a document
70 with syntax highlighting.
72 homepage = "https://www.gnu.org/software/src-highlite/";
73 license = licenses.gpl3Plus;
74 platforms = platforms.unix;
75 maintainers = with maintainers; [ SuperSandro2000 ];
77 } // lib.optionalAttrs (stdenv.targetPlatform.useLLVM or false) {
78 # Force linking to "libgcc" so tests pass
79 NIX_CFLAGS_COMPILE = "-lgcc";