summary refs log tree commit diff
path: root/pkgs/development/tools/misc/cwebbin/default.nix
blob: 055a24f3fe0a02f10777d09e593d6a684eb3e2ed (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
{ lib, stdenv, fetchFromGitHub, fetchurl, tie }:

stdenv.mkDerivation rec {
  pname = "cwebbin";
  version = "22p";

  src = fetchFromGitHub {
    owner = "ascherer";
    repo = "cwebbin";
    rev = "2016-05-20-22p";
    sha256 = "0zf93016hm9i74i2v384rwzcw16y3hg5vc2mibzkx1rzvqa50yfr";
  };

  cweb = fetchurl {
    url = "https://www.ctan.org/tex-archive/web/c_cpp/cweb/cweb-3.64ah.tgz";
    sha256 = "1hdzxfzaibnjxjzgp6d2zay8nsarnfy9hfq55hz1bxzzl23n35aj";
  };

  # Remove references to __DATE__ and __TIME__
  postPatch = ''
    substituteInPlace wmerg-patch.ch --replace ' ("__DATE__", "__TIME__")' ""
    substituteInPlace ctang-patch.ch --replace ' ("__DATE__", "__TIME__")' ""
    substituteInPlace ctangle.cxx --replace ' ("__DATE__", "__TIME__")' ""
    substituteInPlace cweav-patch.ch --replace ' ("__DATE__", "__TIME__")' ""
  '';

  nativeBuildInputs = [ tie ];

  makeFlags = [
    "MACROSDIR=$(out)/share/texmf/tex/generic/cweb"
    "CWEBINPUTS=$(out)/lib/cweb"
    "DESTDIR=$(out)/bin/"
    "MANDIR=$(out)/share/man/man1"
    "EMACSDIR=$(out)/share/emacs/site-lisp"
    "CP=cp"
    "RM=rm"
    "PDFTEX=echo"
    "CC=${stdenv.cc.targetPrefix}c++"
  ];

  buildPhase = ''
    zcat ${cweb} | tar -xvpf -
    make -f Makefile.unix boot $makeFlags
    make -f Makefile.unix cautiously $makeFlags
  '';

  installPhase = ''
    mkdir -p $out/share/man/man1 $out/share/texmf/tex/generic $out/share/emacs $out/lib
    make -f Makefile.unix install $makeFlags
  '';

  meta = with lib; {
    inherit (src.meta) homepage;
    description = "Literate Programming in C/C++";
    platforms = with platforms; unix;
    maintainers = with maintainers; [ vrthra ];
    license = licenses.abstyles;
  };
}