consmirror.c: the BSD notice is replaced (Makronix's own file). Files with changes of other sessions pending are left for their commit. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
48 lines
2.2 KiB
Bash
Executable File
48 lines
2.2 KiB
Bash
Executable File
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
#
|
|
# Makronix/Linux's C library into its own sysroot (build/mxsysroot-<dev>):
|
|
# the recipe ext/src/glibc/mx/Makefile, run with the tooldir's nbmake and
|
|
# gcc, into NetBSD's hierarchy. The kernel headers must be there first
|
|
# (make mxheaders), and the tooldir (make tooldir).
|
|
#
|
|
# Usage: mkglibc.sh DEVICEDIR (make glibc in mobile/)
|
|
|
|
set -eu
|
|
. "$(dirname "$0")/lib.sh"
|
|
|
|
[ $# -eq 1 ] || { echo "usage: $0 DEVICEDIR" >&2; exit 2; }
|
|
load_device "$1"
|
|
dev=$(basename "$DEVDIR")
|
|
target=aarch64-linux-gnu
|
|
tooldir=$(ls -d "$ROOT"/build/tooldir.*-$target 2>/dev/null | head -n 1)
|
|
[ -n "$tooldir" ] && [ -x "$tooldir/bin/$target-gcc" ] || die "no tooldir (make tooldir)"
|
|
sysroot=$ROOT/build/mxsysroot-$dev
|
|
[ -f "$sysroot/usr/include/linux/version.h" ] || die "no kernel headers in $sysroot (make mxheaders)"
|
|
|
|
# NetBSD's hierarchy first, laid down from src/etc/mtree/NetBSD.dist.base and
|
|
# NetBSD.dist.aarch64 with the tooldir's nbmtree, as build.sh's distrib-dirs
|
|
# does: the userland is the same on every kernel, and so is its layout
|
|
# (hier(7)) -- /bin, /sbin, /lib, /libexec are directories, not links to /usr.
|
|
repo=$(cd "$ROOT/.." && pwd)
|
|
spec=$ROOT/build/mxsysroot-$dev.mtree
|
|
cat "$repo/src/etc/mtree/NetBSD.dist.base" \
|
|
"$repo/src/etc/mtree/NetBSD.dist.aarch64" > "$spec"
|
|
"$tooldir/bin/nbmtree" -N "$repo/src/etc" -deU -f "$spec" -p "$sysroot" >/dev/null ||
|
|
die "nbmtree failed"
|
|
rm -f "$spec"
|
|
|
|
"$tooldir/bin/nbmake" -C "$ROOT/../ext/src/glibc/mx" \
|
|
MX_TOOLDIR="$tooldir" MX_SYSROOT="$sysroot" \
|
|
MX_OBJ="$ROOT/build/ext-obj-$dev/glibc" MX_JOBS="$(nproc)" install
|
|
|
|
# The dynamic linker under the two names a program asks for: the ABI's
|
|
# /lib/ld-linux-aarch64.so.1 (glibc installs it in /usr/lib, slibdir), and
|
|
# NetBSD's /libexec/ld.elf_so -- the interpreter NetBSD's own build writes
|
|
# into every program (src/share/mk/bsd.prog.mk:69,286), so a program
|
|
# of src/ built by the normal build runs unchanged (measured with
|
|
# src/bin/cat, 2026-11-12).
|
|
ln -sf ../usr/lib/ld-linux-aarch64.so.1 "$sysroot/lib/ld-linux-aarch64.so.1"
|
|
ln -sf ../lib/ld-linux-aarch64.so.1 "$sysroot/libexec/ld.elf_so"
|
|
echo "$sysroot: glibc, /lib/ld-linux-aarch64.so.1, /libexec/ld.elf_so"
|