about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/tools/misc/deheader/default.nix
blob: 5c2fdb20376f47c0f5ce5a1e697ba0923baf39f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{ lib
, stdenv
, python3
, xmlto
, docbook-xsl-nons
, fetchFromGitLab
, installShellFiles
}:

stdenv.mkDerivation rec {
  pname = "deheader";
  version = "1.10";
  outputs = [ "out" "man" ];

  src = fetchFromGitLab {
    owner = "esr";
    repo = "deheader";
    rev = version;
    sha256 = "sha256-dYTHvFWlt3aM/fdZFge7GBdd9bfCrEcp7ULJuBl71Xs=";
  };

  buildInputs = [ python3 ];

  nativeBuildInputs = [ xmlto docbook-xsl-nons installShellFiles ];

  # With upstream Makefile, xmlto is called without "--skip-validation". It
  # makes it require a lot of dependencies, yet ultimately it fails
  # nevertheless in attempt to fetch something from SourceForge.
  #
  # Need to set "foundMakefile" so "make check" tests are run.
  buildPhase = ''
    runHook preBuild

    xmlto man --skip-validation deheader.xml
    patchShebangs ./deheader
    foundMakefile=1

    runHook postBuild
  '';

  doCheck = true;

  installPhase = ''
    runHook preInstall

    install -Dm755 ./deheader -t $out/bin
    installManPage ./deheader.1

    runHook postInstall
  '';

  meta = with lib; {
    description = "Tool to find and optionally remove unneeded includes in C or C++ source files";
    mainProgram = "deheader";
    longDescription = ''
      This tool takes a list of C or C++ sourcefiles and generates a report
      on which #includes can be omitted from them -- the test, for each foo.c
      or foo.cc or foo.cpp, is simply whether 'rm foo.o; make foo.o' returns a
      zero status. Optionally, with the -r option, the unneeded headers are removed.
      The tool also reports on headers required for strict portability.
    '';
    homepage = "http://catb.org/~esr/deheader";
    changelog = "https://gitlab.com/esr/deheader/-/blob/master/NEWS.adoc";
    license = licenses.bsd2;
    maintainers = with maintainers; [ kaction ];

    platforms = platforms.linux;
  };
}