foundry
Foundry OS: the operating system built on the Rustbelt kernel
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 | #!/usr/bin/env bash
# Build busybox (one program that contains ~300 small Unix tools, called
# "applets") for Foundry OS:
# 1. unpack the cached tarball (with Python: no bzip2 program needed),
# 2. use the committed configuration ports/busybox/busybox.config (see
# ports/busybox/README.md for what is switched off and why),
# 3. run busybox's Makefile with our compiler:
# make CC=toolchain/foundry-cc LD=ld HOSTCC=gcc
# The result is ONE static-PIE program. It is installed as
# /usr/lib/busybox/busybox on the ext2 root, next to one symlink per applet
# (/usr/lib/busybox/awk -> busybox, ...), all OFF the default PATH, so the
# Foundry OS Rust tools stay the default. Run an applet as
# busybox awk ... (with /usr/lib/busybox/busybox spelled out)
# or as /usr/lib/busybox/awk ...
#
# Usage: ports/busybox/build.sh CACHE_DIR BUILD_DIR OUT_DIR
# OUT_DIR/busybox is the program, OUT_DIR/applets.txt lists the applet
# names, OUT_DIR/LICENSE is busybox's licence (GPL v2).
#
# Host needs (besides gcc and the musl sysroot): python3, and the Linux
# kernel's userspace headers in /usr/include/linux and /usr/include/asm
# (Debian/Ubuntu package linux-libc-dev). busybox includes a few of them
# (<linux/fs.h>, ...), and foundry-cc only searches the musl sysroot, so we
# copy them into BUILD_DIR/kernel-headers and add that with -isystem.
HERE=
ROOT=
CACHE= BUILD= OUTDIR=
&&
src=/
# Linux userspace headers. -L copies the files that symlinks point at.
kh=/kernel-headers
asm=/usr/include//asm
[ || asm=/usr/include/asm
for; do
[ || { ; ; }
done
[ &&
# busybox's build pipes its config through `bzip2 -1` (for `busybox
# --show-config`-style data). No bzip2 on the host? Use a tiny Python one.
if ! ; then
fi
# oldconfig fills in nothing new if busybox.config matches this version;
# if it had to ask anything, the committed file is stale.
{ || ; } | if ! ; then
;
fi
# LD=ld: busybox first links each directory with `ld -r`, which can't be
# combined with foundry-cc's -static-pie. The final link still uses CC.
||
{ ; ; }
if | ; then
;
fi
&&
|
|