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