; Kbuild runs the target compiler from the BusyBox source directory. The ; relative link keeps the sysroot's path out of make's split command words. target-cc := "CC=gcc --sysroot=../vinix-sysroot -specs=../vinix-sysroot/usr/lib/musl-gcc-sysroot.specs" defpkgbuild(busybox, #:pkgname, "busybox", #:pkgver, "1.38.0", #:pkgrel, 2, #:pkgdesc, "Static musl shell and bootstrap utilities for Vinix", #:arch, [#:x86-64], #:url, "https://busybox.net/", #:license, "GPL-2.0-only", #:makedepends, ["musl=1.2.6-1"], #:source, ["https://busybox.net/downloads/busybox-1.38.0.tar.bz2", "bootstrap.config"], #:sha256sums, ["34f9ea6ff8636f2c9241153b9114eefa9e65674a45318ae1ef95bb5f31c53bb2", "9d8c4fb8ebad6ddbf058e151d807a90ce7687643626e0e4b5357e587718dec00"], #:prepare, fn() { root := get-environment-variable("VPAC_MAKEPKG_ROOT") if not(string?(root)) { display("Set VPAC_MAKEPKG_ROOT to the absolute path of the installed Vinix build root.") newline() run("false") } run("test", "-f", string-append(root, "/usr/lib/musl-gcc-sysroot.specs")) run("ln", "-s", root, "vinix-sysroot") ; Start with everything disabled. BusyBox allnoconfig overrides explicit ; KCONFIG_ALLCONFIG selections, so enable the selected options afterwards. run("make", "-C", "busybox-1.38.0", "allnoconfig") run("cp", "bootstrap.config", "enable.sed") run("sed", "-i", "-e", "/^#/d", "-e", "s/^\\(CONFIG_[A-Z0-9_]*\\)=y$/s|^# \\1 is not set$|\\1=y|/", "enable.sed") run("cp", "busybox-1.38.0/.config", "busybox-1.38.0/vinix.defconfig") run("sed", "-i", "-f", "enable.sed", "busybox-1.38.0/vinix.defconfig") run("make", "-C", "busybox-1.38.0", "KBUILD_DEFCONFIG=vinix.defconfig", "defconfig") ; musl supplies libc headers. Import only the Linux kernel UAPI from ; the x86-64 builder until those headers have their own Vinix package. run("mkdir", "uapi") run("ln", "-s", "/usr/include/linux", "uapi/linux") run("ln", "-s", "/usr/include/asm-generic", "uapi/asm-generic") if file-exists?("/usr/include/asm") { run("ln", "-s", "/usr/include/asm", "uapi/asm") } else { run("ln", "-s", "/usr/include/x86_64-linux-gnu/asm", "uapi/asm") } }, #:build, fn() { run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH", "make", "-C", "busybox-1.38.0", target-cc, "EXTRA_CFLAGS=-I../uapi", "busybox") }, #:check, fn() { ; Check what the final executable actually linked, and the dependencies ; emitted when compiling ash. Keep the proof in the build transcript. for-each(fn(file) { run("grep", "-Fx", string-append("LOAD ../vinix-sysroot/usr/lib/", file), "busybox-1.38.0/busybox_unstripped.map") }, list("Scrt1.o", "crti.o", "libc.a", "crtn.o")) run("grep", "-F", "../vinix-sysroot/usr/include/stdio.h", "busybox-1.38.0/shell/.ash.o.cmd") run("busybox-1.38.0/busybox", "ash", "-n", "/dev/null") run("busybox-1.38.0/busybox", "true") }, #:package, fn() { run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH", "make", "-C", "busybox-1.38.0", target-cc, "EXTRA_CFLAGS=-I../uapi", string-append("CONFIG_PREFIX=", pkgdir()), "install") run("install", "-Dm644", "busybox-1.38.0/LICENSE", string-append(pkgdir(), "/usr/share/licenses/busybox/LICENSE")) })