forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / by-name / sl / sloccount / package.nix
blobfc619612a48bb6586c460a7f69f46d623b154fa6
1 { fetchurl, lib, stdenv, perl, makeWrapper }:
3 stdenv.mkDerivation rec {
4   pname = "sloccount";
5   version = "2.26";
7   src = fetchurl {
8     url = "https://www.dwheeler.com/${pname}/${pname}-${version}.tar.gz";
9     sha256 = "0ayiwfjdh1946asah861ah9269s5xkc8p5fv1wnxs9znyaxs4zzs";
10   };
12   nativeBuildInputs = [ makeWrapper ];
13   buildInputs = [ perl ];
15   # Make sure the Flex-generated files are newer than the `.l' files, so that
16   # Flex isn't needed to recompile them.
17   patchPhase = ''
18     for file in *
19     do
20       if grep -q /usr/bin/perl "$file"
21       then
22           echo "patching \`$file'..."
23           substituteInPlace "$file" --replace \
24             "/usr/bin/perl" "${perl}/bin/perl"
25       fi
26     done
28     for file in *.l
29     do
30       touch "$(echo $file | sed -es'/\.l$/.c/g')"
31     done
32   '';
34   makeFlags = [ "PREFIX=$(out)" "CC=${stdenv.cc.targetPrefix}cc" ];
36   doCheck = true;
37   checkPhase = ''HOME="$TMPDIR" PATH="$PWD:$PATH" make test'';
39   preInstall = ''
40     mkdir -p "$out/bin"
41     mkdir -p "$out/share/man/man1"
42     mkdir -p "$out/share/doc"
43   '';
45   postInstall = ''
46     for w in "$out/bin"/*; do
47       isScript "$w" || continue
48       wrapProgram "$w" --prefix PATH : "$out/bin"
49     done
50     '';
52   meta = {
53     description = "Set of tools for counting physical Source Lines of Code (SLOC)";
55     longDescription = ''
56       This is the home page of "SLOCCount", a set of tools for
57       counting physical Source Lines of Code (SLOC) in a large number
58       of languages of a potentially large set of programs.  This suite
59       of tools was used in my papers More than a Gigabuck: Estimating
60       GNU/Linux's Size and Estimating Linux's Size to measure the SLOC
61       of entire GNU/Linux distributions, and my essay Linux Kernel
62       2.6: It's Worth More!  Others have measured Debian GNU/Linux and
63       the Perl CPAN library using this tool suite.
64     '';
66     license = lib.licenses.gpl2Plus;
68     homepage = "https://www.dwheeler.com/sloccount/";
70     maintainers = [ ];
71     platforms = lib.platforms.all;
72   };