1{ lib, stdenv, fetchFromGitHub, fetchurl, tie }:
2
3stdenv.mkDerivation rec {
4 pname = "cwebbin";
5 version = "22p";
6
7 src = fetchFromGitHub {
8 owner = "ascherer";
9 repo = "cwebbin";
10 rev = "2016-05-20-22p";
11 sha256 = "0zf93016hm9i74i2v384rwzcw16y3hg5vc2mibzkx1rzvqa50yfr";
12 };
13
14 cweb = fetchurl {
15 url = "https://www.ctan.org/tex-archive/web/c_cpp/cweb/cweb-3.64ah.tgz";
16 sha256 = "1hdzxfzaibnjxjzgp6d2zay8nsarnfy9hfq55hz1bxzzl23n35aj";
17 };
18
19 # Remove references to __DATE__ and __TIME__
20 postPatch = ''
21 substituteInPlace wmerg-patch.ch --replace ' ("__DATE__", "__TIME__")' ""
22 substituteInPlace ctang-patch.ch --replace ' ("__DATE__", "__TIME__")' ""
23 substituteInPlace ctangle.cxx --replace ' ("__DATE__", "__TIME__")' ""
24 substituteInPlace cweav-patch.ch --replace ' ("__DATE__", "__TIME__")' ""
25 '';
26
27 nativeBuildInputs = [ tie ];
28
29 makeFlags = [
30 "MACROSDIR=$(out)/share/texmf/tex/generic/cweb"
31 "CWEBINPUTS=$(out)/lib/cweb"
32 "DESTDIR=$(out)/bin/"
33 "MANDIR=$(out)/share/man/man1"
34 "EMACSDIR=$(out)/share/emacs/site-lisp"
35 "CP=cp"
36 "RM=rm"
37 "PDFTEX=echo"
38 "CC=${stdenv.cc.targetPrefix}c++"
39 ];
40
41 buildPhase = ''
42 zcat ${cweb} | tar -xvpf -
43 make -f Makefile.unix boot $makeFlags
44 make -f Makefile.unix cautiously $makeFlags
45 '';
46
47 installPhase = ''
48 mkdir -p $out/share/man/man1 $out/share/texmf/tex/generic $out/share/emacs $out/lib
49 make -f Makefile.unix install $makeFlags
50 '';
51
52 meta = with lib; {
53 inherit (src.meta) homepage;
54 description = "Literate Programming in C/C++";
55 platforms = with platforms; unix;
56 maintainers = with maintainers; [ vrthra ];
57 license = licenses.abstyles;
58 };
59}