summary refs log tree commit diff
path: root/pkgs/development/tools/misc/sloccount/default.nix
blob: b2b83aa79b16ebad5743c56a2137f71466e0dc37 (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
70
71
72
{ fetchurl, stdenv, perl, makeWrapper }:

stdenv.mkDerivation rec {
  name = "sloccount-2.26";

  src = fetchurl {
    url = "https://www.dwheeler.com/sloccount/${name}.tar.gz";
    sha256 = "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs";
  };

  nativeBuildInputs = [ makeWrapper ];
  buildInputs = [ perl ];

  # Make sure the Flex-generated files are newer than the `.l' files, so that
  # Flex isn't needed to recompile them.
  patchPhase = ''
    for file in *
    do
      if grep -q /usr/bin/perl "$file"
      then
          echo "patching \`$file'..."
          substituteInPlace "$file" --replace \
            "/usr/bin/perl" "${perl}/bin/perl"
      fi
    done

    for file in *.l
    do
      touch "$(echo $file | sed -es'/\.l$/.c/g')"
    done
  '';

  makeFlags = [ "PREFIX=$(out)" "CC=cc" ];

  doCheck = true;
  checkPhase = ''HOME="$TMPDIR" PATH="$PWD:$PATH" make test'';

  preInstall = ''
    mkdir -p "$out/bin"
    mkdir -p "$out/share/man/man1"
    mkdir -p "$out/share/doc"
  '';

  postInstall = ''
    for w in "$out/bin"/*; do
      isScript "$w" || continue
      wrapProgram "$w" --prefix PATH : "$out/bin"
    done
    '';

  meta = {
    description = "Set of tools for counting physical Source Lines of Code (SLOC)";

    longDescription = ''
      This is the home page of "SLOCCount", a set of tools for
      counting physical Source Lines of Code (SLOC) in a large number
      of languages of a potentially large set of programs.  This suite
      of tools was used in my papers More than a Gigabuck: Estimating
      GNU/Linux's Size and Estimating Linux's Size to measure the SLOC
      of entire GNU/Linux distributions, and my essay Linux Kernel
      2.6: It's Worth More!  Others have measured Debian GNU/Linux and
      the Perl CPAN library using this tool suite.
    '';

    license = stdenv.lib.licenses.gpl2Plus;

    homepage = "https://www.dwheeler.com/sloccount/";

    maintainers = [ ];
    platforms = stdenv.lib.platforms.all;
  };
}