1{ lib
2, stdenv
3, python3
4, xmlto
5, docbook-xsl-nons
6, fetchFromGitLab
7, installShellFiles
8}:
9
10stdenv.mkDerivation rec {
11 pname = "deheader";
12 version = "1.10";
13 outputs = [ "out" "man" ];
14
15 src = fetchFromGitLab {
16 owner = "esr";
17 repo = "deheader";
18 rev = version;
19 sha256 = "sha256-dYTHvFWlt3aM/fdZFge7GBdd9bfCrEcp7ULJuBl71Xs=";
20 };
21
22 buildInputs = [ python3 ];
23
24 nativeBuildInputs = [ xmlto docbook-xsl-nons installShellFiles ];
25
26 # With upstream Makefile, xmlto is called without "--skip-validation". It
27 # makes it require a lot of dependencies, yet ultimately it fails
28 # nevertheless in attempt to fetch something from SourceForge.
29 #
30 # Need to set "foundMakefile" so "make check" tests are run.
31 buildPhase = ''
32 runHook preBuild
33
34 xmlto man --skip-validation deheader.xml
35 patchShebangs ./deheader
36 foundMakefile=1
37
38 runHook postBuild
39 '';
40
41 doCheck = true;
42
43 installPhase = ''
44 runHook preInstall
45
46 install -Dm755 ./deheader -t $out/bin
47 installManPage ./deheader.1
48
49 runHook postInstall
50 '';
51
52 meta = with lib; {
53 description = "Tool to find and optionally remove unneeded includes in C or C++ source files";
54 longDescription = ''
55 This tool takes a list of C or C++ sourcefiles and generates a report
56 on which #includes can be omitted from them -- the test, for each foo.c
57 or foo.cc or foo.cpp, is simply whether 'rm foo.o; make foo.o' returns a
58 zero status. Optionally, with the -r option, the unneeded headers are removed.
59 The tool also reports on headers required for strict portability.
60 '';
61 homepage = "http://catb.org/~esr/deheader";
62 changelog = "https://gitlab.com/esr/deheader/-/blob/master/NEWS.adoc";
63 license = licenses.bsd2;
64 maintainers = with maintainers; [ kaction ];
65
66 platforms = platforms.linux;
67 };
68}