Cross-build bootstrap BusyBox and report Vinix as the operating system
@@ -1,13 +1,19 @@
11; Kbuild runs the target compiler from the BusyBox source directory. The
22; relative link keeps the sysroot's path out of make's split command words.
3-target-cc := "CC=gcc --sysroot=../vinix-sysroot -specs=../vinix-sysroot/usr/lib/musl-gcc-sysroot.specs"
3+selected-arch := get-environment-variable("VPAC_TARGET_ARCH")
4+host-arch := if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }
5+target-arch := if string?(selected-arch) { selected-arch } else { host-arch }
6+cross-prefix := get-environment-variable("CROSS_COMPILE")
7+prefix := if string?(cross-prefix) { cross-prefix } else { "" }
8+target-cc := string-append("CC=", prefix, "gcc --sysroot=../vinix-sysroot -specs=../vinix-sysroot/usr/lib/musl-gcc-sysroot.specs")
9+run-target := if string=?(host-arch, target-arch) { list() } else { list(string-append("qemu-", target-arch)) }
410
511defpkgbuild(busybox,
612 #:pkgname, "busybox",
713 #:pkgver, "1.38.0",
8- #:pkgrel, 3,
14+ #:pkgrel, 4,
915 #:pkgdesc, "Static musl shell and bootstrap utilities for Vinix",
10- #:arch, [#:x86-64],
16+ #:arch, [#:x86-64, #:aarch64],
1117 #:url, "https://busybox.net/",
1218 #:license, "GPL-2.0-only",
1319 #:makedepends, ["musl=1.2.6-1", "linux-headers"],
@@ -34,7 +40,8 @@ defpkgbuild(busybox,
3440 run("cp", "busybox-1.38.0/.config", "busybox-1.38.0/vinix.defconfig")
3541 run("sed", "-i", "-f", "enable.sed", "busybox-1.38.0/vinix.defconfig")
3642 run("make", "-C", "busybox-1.38.0", "KBUILD_DEFCONFIG=vinix.defconfig", "defconfig")
37-
43+ run("sed", "-i", "s|^CONFIG_UNAME_OSNAME=.*|CONFIG_UNAME_OSNAME=\"Vinix\"|", "busybox-1.38.0/.config")
44+ run("grep", "-Fx", "CONFIG_UNAME_OSNAME=\"Vinix\"", "busybox-1.38.0/.config")
3845 },
3946 #:build, fn() {
4047 run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",
@@ -49,8 +56,8 @@ defpkgbuild(busybox,
4956 }, list("Scrt1.o", "crti.o", "libc.a", "crtn.o"))
5057 run("grep", "-F", "../vinix-sysroot/usr/include/stdio.h", "busybox-1.38.0/shell/.ash.o.cmd")
5158 run("grep", "-F", "../vinix-sysroot/usr/include/linux/vt.h", "busybox-1.38.0/init/.init.o.cmd")
52- run("busybox-1.38.0/busybox", "ash", "-n", "/dev/null")
53- run("busybox-1.38.0/busybox", "true")
59+ apply(run, append(run-target, list("busybox-1.38.0/busybox", "ash", "-n", "/dev/null")))
60+ apply(run, append(run-target, list("busybox-1.38.0/busybox", "true")))
5461 },
5562 #:package, fn() {
5663 run("env", "-u", "CPATH", "-u", "C_INCLUDE_PATH", "-u", "LIBRARY_PATH",