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