1{ lib
2, fetchurl
3, kaem
4, tinycc
5, gnumake
6, gnupatch
7, coreutils
8}:
9let
10 pname = "heirloom-devtools";
11 version = "070527";
12
13 src = fetchurl {
14 url = "mirror://sourceforge/heirloom/heirloom-devtools/heirloom-devtools-${version}.tar.bz2";
15 sha256 = "9f233d8b78e4351fe9dd2d50d83958a0e5af36f54e9818521458a08e058691ba";
16 };
17
18 # Thanks to the live-bootstrap project!
19 # See https://github.com/fosslinux/live-bootstrap/blob/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527/heirloom-devtools-070527.kaem
20 liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527";
21
22 patches = [
23 # Remove all kinds of wchar support. Mes Libc does not support wchar in any form
24 (fetchurl {
25 url = "${liveBootstrap}/patches/yacc_remove_wchar.patch";
26 sha256 = "0wgiz02bb7xzjy2gnbjp8y31qy6rc4b29v01zi32zh9lw54j68hc";
27 })
28 # Similarly to yacc, remove wchar. See yacc patch for further information
29 (fetchurl {
30 url = "${liveBootstrap}/patches/lex_remove_wchar.patch";
31 sha256 = "168dfngi51ljjqgd55wbvmffaq61gk48gak50ymnl1br92qkp4zh";
32 })
33 ];
34in
35kaem.runCommand "${pname}-${version}" {
36 inherit pname version;
37
38 nativeBuildInputs = [
39 tinycc.compiler
40 gnumake
41 gnupatch
42 coreutils
43 ];
44
45 meta = with lib; {
46 description = "Portable yacc and lex derived from OpenSolaris";
47 homepage = "https://heirloom.sourceforge.net/devtools.html";
48 license = with licenses; [ cddl bsdOriginalUC caldera ];
49 maintainers = teams.minimal-bootstrap.members;
50 platforms = platforms.unix;
51 };
52} ''
53 # Unpack
54 unbz2 --file ${src} --output heirloom-devtools.tar
55 untar --file heirloom-devtools.tar
56 rm heirloom-devtools.tar
57 build=''${NIX_BUILD_TOP}/heirloom-devtools-${version}
58 cd ''${build}
59
60 # Patch
61 ${lib.concatLines (map (f: "patch -Np0 -i ${f}") patches)}
62
63 # Build yacc
64 cd yacc
65 make -f Makefile.mk \
66 CC="tcc -B ${tinycc.libs}/lib" \
67 AR="tcc -ar" \
68 CFLAGS="-DMAXPATHLEN=4096 -DEILSEQ=84 -DMB_LEN_MAX=100" \
69 LDFLAGS="-lgetopt" \
70 RANLIB=true \
71 LIBDIR=''${out}/lib
72
73 # Install yacc
74 install -D yacc ''${out}/bin/yacc
75 install -Dm 444 liby.a ''${out}/lib/liby.a
76 install -Dm 444 yaccpar ''${out}/lib/yaccpar
77
78 # Make yacc available to lex
79 PATH="''${out}/bin:''${PATH}"
80
81 # Build lex
82 cd ../lex
83 make -f Makefile.mk \
84 CC="tcc -B ${tinycc.libs}/lib" \
85 AR="tcc -ar" \
86 CFLAGS="-DEILSEQ=84 -DMB_LEN_MAX=100" \
87 LDFLAGS="-lgetopt" \
88 RANLIB=true \
89 LIBDIR=''${out}/lib
90
91 # Install lex
92 install -D lex ''${out}/bin/lex
93 install -Dm 444 ncform ''${out}/lib/lex/ncform
94 install -Dm 444 nceucform ''${out}/lib/lex/nceucform
95 install -Dm 444 nrform ''${out}/lib/lex/nrform
96 install -Dm 444 libl.a ''${out}/lib/libl.a
97''