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