commit c264a7c
xplshn
·
2026-06-09 04:41:26 +0000 UTC
parent 68d8340
update aruu-box & readme Signed-off-by: xplshn <anto@xplshn.com.ar>
2 files changed,
+153,
-38
M
README
M
README
+31,
-31
1@@ -29,7 +29,7 @@ REQUIREMENTS
2 ============
3
4 cc POSIX.1-2008-compliant C compiler (pcc, etc)
5- make POSIX make (pdpmake, gmake, bmake)
6+ make POSIX make (aruu make, pdpmake, gmake, bmake)
7 ar archive tool
8 ranlib archive indexer
9 objcopy for 'make box' only
10@@ -84,44 +84,44 @@ SOURCE LAYOUT
11 TOOLS
12 =====
13
14-posix: [, basename, cal, cat, chgrp, chmod, chown, cksum, cmp, comm,
15- cp, cut, date, dd, df, dirname, du, echo, ed, env, expand,
16- expr, false, find, fold, getconf, grep, head, id, join, kill,
17- link, ln, logger, logname, ls, mesg, mkdir, mkfifo, mv, nice,
18- nl, nohup, od, paste, pathchk, printf, ps, pwd, readlink,
19- renice, rm, rmdir, sed, sleep, sort, split, tail, tee, test,
20- time, touch, tr, true, tsort, tty, uname, unexpand, uniq,
21- unlink, uudecode, uuencode, wc, who, xargs
22-
23-posix/make: make
24-
25-linux: blkdiscard, chvt, ctrlaltdel, dmesg, eject, fallocate, free,
26- freeramdisk, fsfreeze, hwclock, insmod, lsmod, lsusb, mkswap,
27- mount, mountpoint, pidof, pivot_root, pwdx, readahead, rmmod,
28- swaplabel, swapoff, swapon, switch_root, sysctl, umount,
29- unshare, uptime, vtallow
30-
31-net: host, httpd, ifconfig, netcat, ping, tftp, tunctl, wget
32-
33-pseudo: chroot, clear, cols, cron, flock, getty, halt, hostname,
34- install, killall5, last, lastlog, login, md5sum, mktemp,
35- nologin, pagesize, printenv, respawn, rev, seq, setsid,
36- sha1sum, sha224sum, sha256sum, sha384sum, sha512sum,
37- sha512-224sum, sha512-256sum, sponge, stat, tar, truncate,
38- watch, which, whoami, yes
39-
40-xsi: mknod, passwd, su
41+posix:
42+ [, awk, basename, cal, cat, chgrp, chmod, chown, cksum, cmp, comm, cp,
43+ cut, date, dd, df, dirname, du, echo, ed, env, expand, expr, false,
44+ find, fold, getconf, grep, head, id, join, kill, link, ln, logger,
45+ logname, ls, make, mesg, mkdir, mkfifo, mv, nice, nl, nohup, od,
46+ paste, pathchk, pax, printf, ps, pwd, readlink, renice, rm, rmdir,
47+ sed, sh, sleep, sort, split, tail, tee, test, time, touch, tr, true,
48+ tsort, tty, uname, unexpand, uniq, unlink, uudecode, uuencode, wc,
49+ who, xargs
50+
51+linux:
52+ blkdiscard, chvt, ctrlaltdel, dmesg, eject, fallocate, free,
53+ freeramdisk, fsfreeze, hwclock, insmod, lsmod, lsusb, mkswap, mount,
54+ mountpoint, pidof, pivot_root, pwdx, readahead, rmmod, swaplabel,
55+ swapoff, swapon, switch_root, sysctl, umount, unshare, uptime,
56+ vtallow
57+
58+net:
59+ host, httpd, ifconfig, netcat, ping, tftp, tunctl, wget
60+
61+pseudo:
62+ base64, chroot, clear, cols, cron, flock, getty, halt, hostname,
63+ install, killall5, last, lastlog, login, md5sum, mktemp, nologin,
64+ pagesize, printenv, respawn, rev, seq, setsid, sha1sum, sha224sum,
65+ sha256sum, sha384sum, sha512-224sum, sha512-256sum, sha512sum, sponge,
66+ stat, tar, truncate, watch, which, whoami, xinstall, yes
67+
68+xsi:
69+ mknod, passwd, su
70
71 TODOs / PENDING RELEASE
72 =======================
73-sh - ported from freebsd
74-awk - one true awk, with some stale PRs merged
75 ip - new impl partially based on toybox's applet
76 dhcpd - no idea where to start with this one
77 init - situation/sctl rewrite
78-pax - port minix's
79 troff - neatroff
80 man - unsure
81+vendor and publish my compiler toolchain (small binutils + cproc), even if incomplete - unsure
82
83 LICENSE
84 =======
+122,
-7
1@@ -1,7 +1,7 @@
2 #!/bin/sh
3 # mkbox - build aruu-box, the aruu multi-call binary
4 #
5-# expects CC CPPFLAGS CFLAGS LDFLAGS LDLIBS OBJCOPY from the environment;
6+# expects CC CPPFLAGS CFLAGS LDFLAGS LDLIBS OBJCOPY YACC from the environment
7 # defaults match config.mk but can be overridden
8 #
9 # run from the source root (the Makefile does this automatically)
10@@ -14,6 +14,7 @@ set -e
11 : "${LDFLAGS:=}"
12 : "${LDLIBS:=-lcrypt -lresolv}"
13 : "${OBJCOPY:=objcopy}"
14+: "${YACC:=yacc}"
15
16 ROOT=$(CDPATH= cd "$(dirname "$0")/.." && pwd)
17 BDIR="${ROOT}/.box"
18@@ -43,12 +44,15 @@ mkdir -p "${BDIR}"
19
20 OBJS=""
21 DECL_F="${BDIR}/decls.inc"
22-ENT_F="${BDIR}/entries.inc"
23 : > "${DECL_F}"
24-: > "${ENT_F}"
25+for _c in posix linux net pseudo xsi; do
26+ : > "${BDIR}/entries_${_c}.inc"
27+done
28+unset _c
29
30 alias_entry() {
31- printf '\t{ "%s", %s_main, "%s" },\n' "$1" "$2" "$3" >> "${ENT_F}"
32+ printf '\t{ "%s", %s_main, "%s" },\n' "$1" "$2" "$3" \
33+ >> "${BDIR}/entries_${3}.inc"
34 }
35
36 compile_tool() {
37@@ -71,7 +75,8 @@ compile_tool() {
38 rm -f "${symf}"
39 OBJS="${OBJS} ${out}"
40 printf 'int %s_main(int, char **);\n' "${fn}" >> "${DECL_F}"
41- printf '\t{ "%s", %s_main, "%s" },\n' "${name}" "${fn}" "${catg}" >> "${ENT_F}"
42+ printf '\t{ "%s", %s_main, "%s" },\n' "${name}" "${fn}" "${catg}" \
43+ >> "${BDIR}/entries_${catg}.inc"
44 }
45
46 compile_make() {
47@@ -104,7 +109,109 @@ compile_make() {
48
49 OBJS="${OBJS} ${combined}"
50 printf 'int make_main(int, char **);\n' >> "${DECL_F}"
51- printf '\t{ "make", make_main, "posix/make" },\n' >> "${ENT_F}"
52+ printf '\t{ "make", make_main, "posix" },\n' >> "${BDIR}/entries_posix.inc"
53+}
54+
55+compile_awk() {
56+ adir="${ROOT}/cmd/posix/awk"
57+ symf="${BDIR}/awk.syms"
58+ awk_objs=""
59+
60+ printf 'mkbox: yacc awk/awkgram.y\n'
61+ ${YACC} -d -o "${adir}/awkgram.tab.c" "${adir}/awkgram.y" ||
62+ die "yacc failed: awk/awkgram.y"
63+
64+ # maketab is a host code-generator, only needs CFLAGS, no CPPFLAGS
65+ printf 'mkbox: cc awk/maketab\n'
66+ ${CC} ${CFLAGS} -o "${BDIR}/awk_maketab" "${adir}/maketab.c" ||
67+ die "compile failed: awk/maketab.c"
68+
69+ printf 'mkbox: gen awk/proctab.c\n'
70+ "${BDIR}/awk_maketab" "${adir}/awkgram.tab.h" > "${adir}/proctab.c" ||
71+ die "maketab failed"
72+
73+ for s in b main parse proctab tran lib run lex math; do
74+ out="${BDIR}/awk_${s}.o"
75+ eval "${CC} ${CPPFLAGS} -I\"\$adir\" ${CFLAGS} -c \"\$adir/${s}.c\" -o \"\$out\"" ||
76+ die "compile failed: awk/${s}.c"
77+ awk_objs="${awk_objs} ${out}"
78+ done
79+ out="${BDIR}/awk_awkgram.tab.o"
80+ eval "${CC} ${CPPFLAGS} -I\"\$adir\" ${CFLAGS} -c \"\$adir/awkgram.tab.c\" -o \"\$out\"" ||
81+ die "compile failed: awk/awkgram.tab.c"
82+ awk_objs="${awk_objs} ${out}"
83+
84+ combined="${BDIR}/awk_combined.o"
85+ ${LD:-ld} -r -o "${combined}" ${awk_objs} ||
86+ die "ld -r failed: awk"
87+
88+ printf 'main awk_main\n' > "${symf}"
89+ ${OBJCOPY} --redefine-syms="${symf}" "${combined}" ||
90+ die "objcopy failed: awk"
91+ ${OBJCOPY} --keep-global-symbol=awk_main "${combined}" ||
92+ die "objcopy localize failed: awk"
93+ rm -f "${symf}" ${awk_objs}
94+
95+ OBJS="${OBJS} ${combined}"
96+ LDLIBS="${LDLIBS} -lm"
97+ printf 'int awk_main(int, char **);\n' >> "${DECL_F}"
98+ printf '\t{ "awk", awk_main, "posix" },\n' >> "${BDIR}/entries_posix.inc"
99+}
100+
101+compile_sh() {
102+ sdir="${ROOT}/cmd/posix/sh"
103+ symf="${BDIR}/sh.syms"
104+ sh_objs=""
105+
106+ # mknodes and mksyntax are host code-generators, not part of the shell
107+ printf 'mkbox: cc sh/mknodes\n'
108+ ${CC} ${CFLAGS} -o "${BDIR}/sh_mknodes" "${sdir}/mknodes.c" ||
109+ die "compile failed: sh/mknodes.c"
110+
111+ printf 'mkbox: cc sh/mksyntax\n'
112+ ${CC} ${CPPFLAGS} -I"${sdir}" ${CFLAGS} -o "${BDIR}/sh_mksyntax" "${sdir}/mksyntax.c" ||
113+ die "compile failed: sh/mksyntax.c"
114+
115+ printf 'mkbox: gen sh/nodes.{c,h}\n'
116+ (cd "${sdir}" && "${BDIR}/sh_mknodes" nodetypes nodes.c.pat) ||
117+ die "mknodes failed"
118+
119+ printf 'mkbox: gen sh/syntax.{c,h}\n'
120+ (cd "${sdir}" && "${BDIR}/sh_mksyntax") ||
121+ die "mksyntax failed"
122+
123+ printf 'mkbox: gen sh/builtins.{c,h}\n'
124+ (cd "${sdir}" && sh mkbuiltins .) ||
125+ die "mkbuiltins failed"
126+
127+ printf 'mkbox: gen sh/token.h\n'
128+ (cd "${sdir}" && sh mktokens) ||
129+ die "mktokens failed"
130+
131+ for s in alias arith_yacc arith_yylex cd echo error eval exec \
132+ expand histedit input jobs kill mail main memalloc \
133+ miscbltin mystring options output parser printf redir \
134+ show test trap var builtins nodes syntax; do
135+ out="${BDIR}/sh_${s}.o"
136+ eval "${CC} ${CPPFLAGS} -DSHELL -I\"\$sdir\" ${CFLAGS} -c \"\$sdir/${s}.c\" -o \"\$out\"" ||
137+ die "compile failed: sh/${s}.c"
138+ sh_objs="${sh_objs} ${out}"
139+ done
140+
141+ combined="${BDIR}/sh_combined.o"
142+ ${LD:-ld} -r -o "${combined}" ${sh_objs} ||
143+ die "ld -r failed: sh"
144+
145+ printf 'main sh_main\n' > "${symf}"
146+ ${OBJCOPY} --redefine-syms="${symf}" "${combined}" ||
147+ die "objcopy failed: sh"
148+ ${OBJCOPY} --keep-global-symbol=sh_main "${combined}" ||
149+ die "objcopy localize failed: sh"
150+ rm -f "${symf}" ${sh_objs}
151+
152+ OBJS="${OBJS} ${combined}"
153+ printf 'int sh_main(int, char **);\n' >> "${DECL_F}"
154+ printf '\t{ "sh", sh_main, "posix" },\n' >> "${BDIR}/entries_posix.inc"
155 }
156
157 process_dir() {
158@@ -127,6 +234,8 @@ process_dir() {
159 }
160
161 process_dir "${ROOT}/cmd/posix" "posix"
162+compile_awk
163+compile_sh
164 compile_make
165 process_dir "${ROOT}/cmd/linux" "linux"
166 process_dir "${ROOT}/cmd/net" "net"
167@@ -166,7 +275,13 @@ struct Cmd {
168 static struct Cmd cmds[] = {
169 DISPATCH_STRUCT
170
171-cat "${ENT_F}" >> "${DISP}"
172+# sort each category alphabetically by tool name at build time;
173+# entries have the form: \t{ "name", fn_main, "cat" },
174+# splitting on " makes field 2 the tool name
175+for _c in posix linux net pseudo xsi; do
176+ sort -t'"' -k2,2 "${BDIR}/entries_${_c}.inc"
177+done >> "${DISP}"
178+unset _c
179
180 cat >> "${DISP}" << 'DISPATCH_TAIL'
181 { NULL, NULL, NULL }