1cflags{
2 '-std=c99', '-Wall', '-Wpedantic', '-Wno-maybe-uninitialized',
3 '-D _DEFAULT_SOURCE',
4 '-D _BSD_SOURCE',
5 '-D _XOPEN_SOURCE=700',
6 '-I $outdir',
7 '-I $srcdir',
8 ([['-D PREFIX="%s"']]):format(config.prefix),
9}
10
11lib('libutil.a', [[libutil/(
12 concat.c
13 cp.c
14 crypt.c
15 confirm.c
16 ealloc.c
17 enmasse.c
18 eprintf.c
19 eregcomp.c
20 estrtod.c
21 fnck.c
22 fshut.c
23 getlines.c
24 human.c
25 linecmp.c
26 md5.c
27 memmem.c
28 mkdirp.c
29 mode.c
30 parseoffset.c
31 putword.c
32 reallocarray.c
33 recurse.c
34 rm.c
35 sha1.c
36 sha224.c
37 sha256.c
38 sha384.c
39 sha512.c
40 sha512-224.c
41 sha512-256.c
42 strcasestr.c
43 strlcat.c
44 strlcpy.c
45 strsep.c
46 strnsubst.c
47 strtonum.c
48 unescape.c
49 writeall.c
50)]])
51lib('libutf.a', [[libutf/(
52 fgetrune.c
53 fputrune.c
54 isalnumrune.c
55 isalpharune.c
56 isblankrune.c
57 iscntrlrune.c
58 isdigitrune.c
59 isgraphrune.c
60 isprintrune.c
61 ispunctrune.c
62 isspacerune.c
63 istitlerune.c
64 isxdigitrune.c
65 lowerrune.c
66 rune.c
67 runetype.c
68 upperrune.c
69 utf.c
70 utftorunestr.c
71)]])
72
73rule('getconf', '$srcdir/scripts/getconf.sh >$out')
74build('getconf', '$outdir/getconf.h', {'|', '$srcdir/scripts/getconf.sh'})
75
76local cmds = {
77 'basename',
78 'cal',
79 'cat',
80 'chgrp',
81 'chmod',
82 'chown',
83 'chroot',
84 'cksum',
85 'cmp',
86 'cols',
87 'comm',
88 'cp',
89 'cron',
90 'cut',
91 'dc',
92 'date',
93 'dd',
94 'dirname',
95 'du',
96 'echo',
97 'ed',
98 'env',
99 'expand',
100 'expr',
101 'false',
102 'find',
103 'flock',
104 'fold',
105 'getconf',
106 'grep',
107 'head',
108 'hostname',
109 'install',
110 'join',
111 'kill',
112 'link',
113 'ln',
114 'logger',
115 'logname',
116 'ls',
117 'md5sum',
118 'mkdir',
119 'mkfifo',
120 'mknod',
121 'mktemp',
122 'mv',
123 'nice',
124 'nl',
125 'nohup',
126 'od',
127 'paste',
128 'pathchk',
129 'printenv',
130 'printf',
131 'pwd',
132 'readlink',
133 'renice',
134 'rev',
135 'rm',
136 'rmdir',
137 'sed',
138 'seq',
139 'setsid',
140 'sha1sum',
141 'sha224sum',
142 'sha256sum',
143 'sha384sum',
144 'sha512-224sum',
145 'sha512-256sum',
146 'sha512sum',
147 'sleep',
148 'sort',
149 'split',
150 'sponge',
151 -- use strings from binutils
152 'sync',
153 'tail',
154 -- use tar from OpenBSD
155 'tee',
156 'test',
157 'tftp',
158 'time',
159 'touch',
160 'tr',
161 'true',
162 'tsort',
163 'tty',
164 'uname',
165 'unexpand',
166 'uniq',
167 'unlink',
168 'uudecode',
169 'uuencode',
170 'wc',
171 'which',
172 'whoami',
173 'xargs',
174 'yes',
175}
176for _, cmd in ipairs(cmds) do
177 local src = cmd
178 if src == 'install' then
179 src = 'xinstall'
180 end
181 local deps
182 if cmd == 'getconf' then
183 deps = {'$outdir/getconf.h'}
184 end
185 file('bin/'..cmd, '755', exe(cmd, {src..'.c', 'libutil.a', 'libutf.a'}, deps))
186 local out = '$outdir/'..cmd..'.1.gz'
187 build('gzip', out, '$srcdir/'..src..'.1')
188 file('share/man/man1/'..cmd..'.1.gz', '644', out)
189end
190
191yacc('bc', 'bc.y')
192pkg.deps = {'$outdir/bc.tab.c'}
193exe('bc', [[$outdir/(bc.tab.c libutil.a)]])
194--file('bin/bc', '755', '$outdir/bc')
195
196exe('smake', {
197 'make/defaults.c',
198 'make/main.c',
199 'make/parser.c',
200 'make/posix.c',
201 'make/rules.c',
202})
203file('bin/smake', '755', '$outdir/smake')
204
205sym('bin/[', 'test')
206
207-- TODO: binutils' config/lib-ld.m4 should use AC_REQUIRE([AC_PROG_EGREP]) and
208-- $EGREP instead of egrep.
209file('bin/egrep', '755', '$dir/egrep')
210
211fetch 'git'