Developed from both Windows and Linux, so nothing in the build should care which host it runs on. It did, in four places. Toolchain: one path instead of two. clang is a cross-compiler by construction, so a single LLVM install targets bare-metal ELF, 16/32-bit code below 1 MB, and Linux/musl userland from any host -- which is how the Windows build already worked. The GNU branch beside it had drifted into passing --no-warn-rwx-segments, a hard error on lld, which is the default linker on both FreeBSD and macOS; and it required a brewed x86_64-elf-gcc before anything built on a Mac at all. GNU is kept as a fallback (USE_GNU=1) but clang+lld is chosen whenever both are present. Host tools use the host's own cc; only mingw needs naming explicitly. tools/mkschfs.c included <sys/sysmacros.h> unconditionally on non-mingw hosts. That header is glibc/musl only -- macOS and the BSDs have neither the header nor a need for it, since major()/minor() come from <sys/types.h> there. Now guarded on __linux__. Ports verified tarballs with `sha256sum -c -`, which does not exist on macOS (shasum), FreeBSD/NetBSD (sha256), or OpenBSD (cksum -a sha256), and each spells its check mode differently. tools/sha256check.sh picks whichever of the five the host has and compares digests itself. nproc is coreutils, so absent on macOS and BSD; falls through to sysctl -n hw.ncpu before defaulting to 4. The PowerShell tools now run under pwsh on any OS: QEMU is found on PATH (the scoop location is a Windows-only fallback), and path literals use forward slashes -- Join-Path $root 'build\x' produces a *filename containing a backslash* on a Unix host. The backslash sweep is limited to known directory prefixes on purpose: bootcheck sends printf 'caf\303\251' to the guest to test UTF-8, and a blanket substitution would have quietly changed what that asserts. Also fixes six tools left booting build/fs.img, which stopped being bootable when SchFS became the root filesystem: crashshot, dispshot, fbshot, splashshot, textshot and ttyshot all take build/schfs.img now, and the -SchFS switches that used to select it are gone. Verified on Windows: full build, and bootcheck green. The Linux, macOS and BSD paths are written from their documented behaviour and are NOT executed here -- this machine has no WSL and no second host.
54 lines
1.6 KiB
Makefile
54 lines
1.6 KiB
Makefile
# SPDX-License-Identifier: Apache-2.0
|
|
# musl libc — MIT-licensed: https://musl.libc.org/
|
|
#
|
|
# Installs into $(PREFIX) (= build/ports/musl/prefix), which port.mk exports
|
|
# to every other port as $(MUSL). Nothing is written into this directory.
|
|
|
|
include ../mk/port.mk
|
|
|
|
MUSL_VERSION := 1.2.5
|
|
MUSL_URL := https://musl.libc.org/releases/musl-$(MUSL_VERSION).tar.gz
|
|
MUSL_SHA256 := a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4
|
|
|
|
TARBALL := $(DISTDIR)/musl-$(MUSL_VERSION).tar.gz
|
|
|
|
$(TARBALL): | $(DISTDIR)
|
|
curl -fsSL -o $@ $(MUSL_URL)
|
|
sh $(SHA256CHECK) "$(MUSL_SHA256)" "$@"
|
|
|
|
download: $(TARBALL)
|
|
|
|
$(SRCDIR): $(TARBALL)
|
|
mkdir -p $(PORTDIR)
|
|
tar -xzf $< -C $(PORTDIR)
|
|
mv $(PORTDIR)/musl-$(MUSL_VERSION) $@
|
|
|
|
# $(SRCDIR) is order-only (|) on purpose. The stamp lives INSIDE $(SRCDIR),
|
|
# so creating it bumps that directory's mtime — making the directory forever
|
|
# newer than the stamp it contains, and re-running this rule on every single
|
|
# build. The second run then fails, because the patch does not apply twice.
|
|
$(SRCDIR)/.patched: patches/0001-schos-tls.patch | $(SRCDIR)
|
|
cd $(SRCDIR) && patch -p1 < $(CURDIR)/patches/0001-schos-tls.patch
|
|
touch $@
|
|
|
|
$(BUILDDIR)/config.mak: $(SRCDIR)/.patched
|
|
mkdir -p $(BUILDDIR)
|
|
cd $(BUILDDIR) && $(SRCDIR)/configure \
|
|
--prefix=$(PREFIX) \
|
|
--disable-shared \
|
|
CC=$(CC) \
|
|
CFLAGS="-D__SCHOS__ -fno-stack-protector"
|
|
|
|
$(BUILDDIR)/lib/libc.a: $(BUILDDIR)/config.mak
|
|
$(MAKE) -C $(BUILDDIR)
|
|
|
|
$(PREFIX)/lib/libc.a: $(BUILDDIR)/lib/libc.a
|
|
$(MAKE) -C $(BUILDDIR) install
|
|
|
|
install: $(PREFIX)/lib/libc.a
|
|
|
|
clean:
|
|
rm -rf $(PORTDIR)
|
|
|
|
distclean: clean
|
|
rm -f $(TARBALL)
|