commit c264a7cd61179adbad2e9903143a4ffd6892ba19
parent 68d834030e84af7453405f5c51f2905abb24e1bc
Author: xplshn <anto@xplshn.com.ar>
Date: Tue, 9 Jun 2026 01:41:26 -0300
update aruu-box & readme
Signed-off-by: xplshn <anto@xplshn.com.ar>
Diffstat:
| M | README | | | 62 | +++++++++++++++++++++++++++++++------------------------------- |
| M | scripts/mkbox | | | 129 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- |
2 files changed, 153 insertions(+), 38 deletions(-)
diff --git a/README b/README
@@ -29,7 +29,7 @@ REQUIREMENTS
============
cc POSIX.1-2008-compliant C compiler (pcc, etc)
- make POSIX make (pdpmake, gmake, bmake)
+ make POSIX make (aruu make, pdpmake, gmake, bmake)
ar archive tool
ranlib archive indexer
objcopy for 'make box' only
@@ -84,44 +84,44 @@ SOURCE LAYOUT
TOOLS
=====
-posix: [, basename, cal, cat, chgrp, chmod, chown, cksum, cmp, comm,
- cp, cut, date, dd, df, dirname, du, echo, ed, env, expand,
- expr, false, find, fold, getconf, grep, head, id, join, kill,
- link, ln, logger, logname, ls, mesg, mkdir, mkfifo, mv, nice,
- nl, nohup, od, paste, pathchk, printf, ps, pwd, readlink,
- renice, rm, rmdir, sed, sleep, sort, split, tail, tee, test,
- time, touch, tr, true, tsort, tty, uname, unexpand, uniq,
- unlink, uudecode, uuencode, wc, who, xargs
-
-posix/make: make
-
-linux: blkdiscard, chvt, ctrlaltdel, dmesg, eject, fallocate, free,
- freeramdisk, fsfreeze, hwclock, insmod, lsmod, lsusb, mkswap,
- mount, mountpoint, pidof, pivot_root, pwdx, readahead, rmmod,
- swaplabel, swapoff, swapon, switch_root, sysctl, umount,
- unshare, uptime, vtallow
-
-net: host, httpd, ifconfig, netcat, ping, tftp, tunctl, wget
-
-pseudo: chroot, clear, cols, cron, flock, getty, halt, hostname,
- install, killall5, last, lastlog, login, md5sum, mktemp,
- nologin, pagesize, printenv, respawn, rev, seq, setsid,
- sha1sum, sha224sum, sha256sum, sha384sum, sha512sum,
- sha512-224sum, sha512-256sum, sponge, stat, tar, truncate,
- watch, which, whoami, yes
-
-xsi: mknod, passwd, su
+posix:
+ [, awk, basename, cal, cat, chgrp, chmod, chown, cksum, cmp, comm, cp,
+ cut, date, dd, df, dirname, du, echo, ed, env, expand, expr, false,
+ find, fold, getconf, grep, head, id, join, kill, link, ln, logger,
+ logname, ls, make, mesg, mkdir, mkfifo, mv, nice, nl, nohup, od,
+ paste, pathchk, pax, printf, ps, pwd, readlink, renice, rm, rmdir,
+ sed, sh, sleep, sort, split, tail, tee, test, time, touch, tr, true,
+ tsort, tty, uname, unexpand, uniq, unlink, uudecode, uuencode, wc,
+ who, xargs
+
+linux:
+ blkdiscard, chvt, ctrlaltdel, dmesg, eject, fallocate, free,
+ freeramdisk, fsfreeze, hwclock, insmod, lsmod, lsusb, mkswap, mount,
+ mountpoint, pidof, pivot_root, pwdx, readahead, rmmod, swaplabel,
+ swapoff, swapon, switch_root, sysctl, umount, unshare, uptime,
+ vtallow
+
+net:
+ host, httpd, ifconfig, netcat, ping, tftp, tunctl, wget
+
+pseudo:
+ base64, chroot, clear, cols, cron, flock, getty, halt, hostname,
+ install, killall5, last, lastlog, login, md5sum, mktemp, nologin,
+ pagesize, printenv, respawn, rev, seq, setsid, sha1sum, sha224sum,
+ sha256sum, sha384sum, sha512-224sum, sha512-256sum, sha512sum, sponge,
+ stat, tar, truncate, watch, which, whoami, xinstall, yes
+
+xsi:
+ mknod, passwd, su
TODOs / PENDING RELEASE
=======================
-sh - ported from freebsd
-awk - one true awk, with some stale PRs merged
ip - new impl partially based on toybox's applet
dhcpd - no idea where to start with this one
init - situation/sctl rewrite
-pax - port minix's
troff - neatroff
man - unsure
+vendor and publish my compiler toolchain (small binutils + cproc), even if incomplete - unsure
LICENSE
=======
diff --git a/scripts/mkbox b/scripts/mkbox
@@ -1,7 +1,7 @@
#!/bin/sh
# mkbox - build aruu-box, the aruu multi-call binary
#
-# expects CC CPPFLAGS CFLAGS LDFLAGS LDLIBS OBJCOPY from the environment;
+# expects CC CPPFLAGS CFLAGS LDFLAGS LDLIBS OBJCOPY YACC from the environment
# defaults match config.mk but can be overridden
#
# run from the source root (the Makefile does this automatically)
@@ -14,6 +14,7 @@ set -e
: "${LDFLAGS:=}"
: "${LDLIBS:=-lcrypt -lresolv}"
: "${OBJCOPY:=objcopy}"
+: "${YACC:=yacc}"
ROOT=$(CDPATH= cd "$(dirname "$0")/.." && pwd)
BDIR="${ROOT}/.box"
@@ -43,12 +44,15 @@ mkdir -p "${BDIR}"
OBJS=""
DECL_F="${BDIR}/decls.inc"
-ENT_F="${BDIR}/entries.inc"
: > "${DECL_F}"
-: > "${ENT_F}"
+for _c in posix linux net pseudo xsi; do
+ : > "${BDIR}/entries_${_c}.inc"
+done
+unset _c
alias_entry() {
- printf '\t{ "%s", %s_main, "%s" },\n' "$1" "$2" "$3" >> "${ENT_F}"
+ printf '\t{ "%s", %s_main, "%s" },\n' "$1" "$2" "$3" \
+ >> "${BDIR}/entries_${3}.inc"
}
compile_tool() {
@@ -71,7 +75,8 @@ compile_tool() {
rm -f "${symf}"
OBJS="${OBJS} ${out}"
printf 'int %s_main(int, char **);\n' "${fn}" >> "${DECL_F}"
- printf '\t{ "%s", %s_main, "%s" },\n' "${name}" "${fn}" "${catg}" >> "${ENT_F}"
+ printf '\t{ "%s", %s_main, "%s" },\n' "${name}" "${fn}" "${catg}" \
+ >> "${BDIR}/entries_${catg}.inc"
}
compile_make() {
@@ -104,7 +109,109 @@ compile_make() {
OBJS="${OBJS} ${combined}"
printf 'int make_main(int, char **);\n' >> "${DECL_F}"
- printf '\t{ "make", make_main, "posix/make" },\n' >> "${ENT_F}"
+ printf '\t{ "make", make_main, "posix" },\n' >> "${BDIR}/entries_posix.inc"
+}
+
+compile_awk() {
+ adir="${ROOT}/cmd/posix/awk"
+ symf="${BDIR}/awk.syms"
+ awk_objs=""
+
+ printf 'mkbox: yacc awk/awkgram.y\n'
+ ${YACC} -d -o "${adir}/awkgram.tab.c" "${adir}/awkgram.y" ||
+ die "yacc failed: awk/awkgram.y"
+
+ # maketab is a host code-generator, only needs CFLAGS, no CPPFLAGS
+ printf 'mkbox: cc awk/maketab\n'
+ ${CC} ${CFLAGS} -o "${BDIR}/awk_maketab" "${adir}/maketab.c" ||
+ die "compile failed: awk/maketab.c"
+
+ printf 'mkbox: gen awk/proctab.c\n'
+ "${BDIR}/awk_maketab" "${adir}/awkgram.tab.h" > "${adir}/proctab.c" ||
+ die "maketab failed"
+
+ for s in b main parse proctab tran lib run lex math; do
+ out="${BDIR}/awk_${s}.o"
+ eval "${CC} ${CPPFLAGS} -I\"\$adir\" ${CFLAGS} -c \"\$adir/${s}.c\" -o \"\$out\"" ||
+ die "compile failed: awk/${s}.c"
+ awk_objs="${awk_objs} ${out}"
+ done
+ out="${BDIR}/awk_awkgram.tab.o"
+ eval "${CC} ${CPPFLAGS} -I\"\$adir\" ${CFLAGS} -c \"\$adir/awkgram.tab.c\" -o \"\$out\"" ||
+ die "compile failed: awk/awkgram.tab.c"
+ awk_objs="${awk_objs} ${out}"
+
+ combined="${BDIR}/awk_combined.o"
+ ${LD:-ld} -r -o "${combined}" ${awk_objs} ||
+ die "ld -r failed: awk"
+
+ printf 'main awk_main\n' > "${symf}"
+ ${OBJCOPY} --redefine-syms="${symf}" "${combined}" ||
+ die "objcopy failed: awk"
+ ${OBJCOPY} --keep-global-symbol=awk_main "${combined}" ||
+ die "objcopy localize failed: awk"
+ rm -f "${symf}" ${awk_objs}
+
+ OBJS="${OBJS} ${combined}"
+ LDLIBS="${LDLIBS} -lm"
+ printf 'int awk_main(int, char **);\n' >> "${DECL_F}"
+ printf '\t{ "awk", awk_main, "posix" },\n' >> "${BDIR}/entries_posix.inc"
+}
+
+compile_sh() {
+ sdir="${ROOT}/cmd/posix/sh"
+ symf="${BDIR}/sh.syms"
+ sh_objs=""
+
+ # mknodes and mksyntax are host code-generators, not part of the shell
+ printf 'mkbox: cc sh/mknodes\n'
+ ${CC} ${CFLAGS} -o "${BDIR}/sh_mknodes" "${sdir}/mknodes.c" ||
+ die "compile failed: sh/mknodes.c"
+
+ printf 'mkbox: cc sh/mksyntax\n'
+ ${CC} ${CPPFLAGS} -I"${sdir}" ${CFLAGS} -o "${BDIR}/sh_mksyntax" "${sdir}/mksyntax.c" ||
+ die "compile failed: sh/mksyntax.c"
+
+ printf 'mkbox: gen sh/nodes.{c,h}\n'
+ (cd "${sdir}" && "${BDIR}/sh_mknodes" nodetypes nodes.c.pat) ||
+ die "mknodes failed"
+
+ printf 'mkbox: gen sh/syntax.{c,h}\n'
+ (cd "${sdir}" && "${BDIR}/sh_mksyntax") ||
+ die "mksyntax failed"
+
+ printf 'mkbox: gen sh/builtins.{c,h}\n'
+ (cd "${sdir}" && sh mkbuiltins .) ||
+ die "mkbuiltins failed"
+
+ printf 'mkbox: gen sh/token.h\n'
+ (cd "${sdir}" && sh mktokens) ||
+ die "mktokens failed"
+
+ for s in alias arith_yacc arith_yylex cd echo error eval exec \
+ expand histedit input jobs kill mail main memalloc \
+ miscbltin mystring options output parser printf redir \
+ show test trap var builtins nodes syntax; do
+ out="${BDIR}/sh_${s}.o"
+ eval "${CC} ${CPPFLAGS} -DSHELL -I\"\$sdir\" ${CFLAGS} -c \"\$sdir/${s}.c\" -o \"\$out\"" ||
+ die "compile failed: sh/${s}.c"
+ sh_objs="${sh_objs} ${out}"
+ done
+
+ combined="${BDIR}/sh_combined.o"
+ ${LD:-ld} -r -o "${combined}" ${sh_objs} ||
+ die "ld -r failed: sh"
+
+ printf 'main sh_main\n' > "${symf}"
+ ${OBJCOPY} --redefine-syms="${symf}" "${combined}" ||
+ die "objcopy failed: sh"
+ ${OBJCOPY} --keep-global-symbol=sh_main "${combined}" ||
+ die "objcopy localize failed: sh"
+ rm -f "${symf}" ${sh_objs}
+
+ OBJS="${OBJS} ${combined}"
+ printf 'int sh_main(int, char **);\n' >> "${DECL_F}"
+ printf '\t{ "sh", sh_main, "posix" },\n' >> "${BDIR}/entries_posix.inc"
}
process_dir() {
@@ -127,6 +234,8 @@ process_dir() {
}
process_dir "${ROOT}/cmd/posix" "posix"
+compile_awk
+compile_sh
compile_make
process_dir "${ROOT}/cmd/linux" "linux"
process_dir "${ROOT}/cmd/net" "net"
@@ -166,7 +275,13 @@ struct Cmd {
static struct Cmd cmds[] = {
DISPATCH_STRUCT
-cat "${ENT_F}" >> "${DISP}"
+# sort each category alphabetically by tool name at build time;
+# entries have the form: \t{ "name", fn_main, "cat" },
+# splitting on " makes field 2 the tool name
+for _c in posix linux net pseudo xsi; do
+ sort -t'"' -k2,2 "${BDIR}/entries_${_c}.inc"
+done >> "${DISP}"
+unset _c
cat >> "${DISP}" << 'DISPATCH_TAIL'
{ NULL, NULL, NULL }