SchOS/ports/toybox/Makefile
Nexoniarz e04ca28812 Rename Schunix to SchOS; the kernel becomes SchIFT
Removes the "-unix" element and with it any trademark exposure to The
Open Group.

The split follows the ecosystem layout: SchOS is the system, and the
kernel has its own name. Kernel-identity strings are the only places
that take SchIFT -- uname(2) sysname, /proc/version, and the two licence
sentences that say "kernel" outright. That is what every Unix does here:
`uname -s` on Linux reports the kernel, not the distribution. Everything
a user reads as the product -- panic screen, boot menu, error prefixes,
docs, LICENSE, NOTICE -- is SchOS.

schunix.img is schos.img, the logo assets and the musl TLS patch are
renamed, and __SCHUNIX__ is __SCHOS__ (the define and the patch that
consumes it moved together).

Two things the rename broke, both found by the bootcheck suite:

  - shmtest wrote "SCHUNIX-MMAP-OK" with a hardcoded length of 15 and
    compared it back by hand-counted offsets (m[3]=='U', m[14]=='K').
    The shorter marker left the write running two bytes past the literal
    and the compare reading past the data, failing a file-backed mmap
    that was working correctly. Now written and compared through one
    constant with sizeof.
  - bootcheck asserted a 31-byte file after appending to
    "hello-from-schunix"; the shorter string makes it 29.

Both are the same mistake: a string literal whose length is written out
somewhere else. Full suite green -- base, Tty, Ps, Sock, Fb, Usb, Evdev.
2026-08-09 14:09:59 +02:00

82 lines
3.4 KiB
Makefile

# SPDX-License-Identifier: Apache-2.0
# toybox — 0BSD-licensed: https://landley.net/toybox/
# Provides SchOS's core utilities (ls, cat, cp, mv, rm, mkdir, ...) as a
# single multicall binary, installed under sysroot/bin/ once per applet name.
#
# mkfs (tools/mkfs.c) doesn't understand symlinks or hardlink dedup — each
# sysroot/bin/<name> below is a real, independent copy of the same toybox
# binary. That costs disk space per applet instead of one shared inode, but
# needs no changes to mkfs and keeps this Makefile self-contained.
include ../mk/port.mk
TOYBOX_VERSION := 0.8.12
TOYBOX_URL := http://landley.net/toybox/downloads/toybox-$(TOYBOX_VERSION).tar.gz
TOYBOX_SHA256 := ad88a921133ae2231d9f2df875ec0bd42af4429145caea7d7db9e02208a6fd2e
TARBALL := $(DISTDIR)/toybox-$(TOYBOX_VERSION).tar.gz
CFLAGS := -static -D__SCHOS__ -I$(MUSL)/include -fno-stack-protector
LDFLAGS := -static -L$(MUSL)/lib -lc
# The applet list is not hard-coded any more: `toybox` with no arguments prints
# exactly the applets the binary was built with, so the install below asks the
# binary itself. A hand-maintained list installed 57 of the ~250 available and
# silently drifted every time the toybox config changed.
$(TARBALL): | $(DISTDIR)
curl -fsSL -o $@ $(TOYBOX_URL)
echo "$(TOYBOX_SHA256) $@" | sha256sum -c -
download: $(TARBALL)
$(SRCDIR): $(TARBALL)
mkdir -p $(PORTDIR)
tar -xzf $< -C $(PORTDIR)
mv $(PORTDIR)/toybox-$(TOYBOX_VERSION) $@
# toybox has no out-of-tree build mode, so its source is copied into $(BUILDDIR)
# and built in place. $(SRCDIR) is an order-only prerequisite (|): the extracted
# tarball never changes, and depending on it normally made a directory mtime
# trigger a rebuild. The rebuild then failed anyway, because `cp -r` over a
# populated $(BUILDDIR) hits "File exists" on kconfig's symlinks — so wipe it
# first and always build from a clean copy.
$(BUILDDIR)/toybox: | $(SRCDIR)
rm -rf $(BUILDDIR)
mkdir -p $(BUILDDIR)
cp -r $(SRCDIR)/. $(BUILDDIR)/
$(MAKE) -C $(BUILDDIR) defconfig
$(MAKE) -C $(BUILDDIR) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
# Install every applet the binary provides, one name per applet.
#
# mkfs deduplicates by content, so all of these collapse to a single inode with
# many hard links in the image -- the cost is one copy, not one per name. On the
# host we try a hard link first for the same reason and fall back to a copy if
# the filesystem will not take one (NTFS via WSL usually will).
#
# The work hangs off a stamp file rather than off the phony `install` target.
# port.mk declares install .PHONY for every port, so this recipe used to run on
# every single build -- re-creating 236 links whether or not toybox had been
# rebuilt. That is slow on its own, and worse, it bumped the mtime of 236 files
# in sysroot/ every time, which made the top-level build think the staged tree
# had changed and rebuild the whole filesystem image from scratch.
install: $(BUILDDIR)/toybox.installed
$(BUILDDIR)/toybox.installed: $(BUILDDIR)/toybox | $(SYSROOT)/bin
cp $< $(SYSROOT)/bin/toybox
chmod 755 $(SYSROOT)/bin/toybox
@for a in $$($(BUILDDIR)/toybox); do \
rm -f $(SYSROOT)/bin/"$$a"; \
ln $(SYSROOT)/bin/toybox $(SYSROOT)/bin/"$$a" 2>/dev/null \
|| cp $< $(SYSROOT)/bin/"$$a"; \
done
@echo "toybox: installed $$($(BUILDDIR)/toybox | wc -w) applets"
@touch $@
clean:
rm -rf $(PORTDIR)
distclean: clean
rm -f $(TARBALL)