The phone's userland is NetBSD's own source built with NetBSD's build against glibc, and more and more of src/ asks for libc symbols glibc does not have, so libmxlinux takes them over from the same tree: db(3) (Berkeley DB 1.85, which glibc dropped), md2/md4/rmd160 and the *File/*End helpers the hash tools link, glob(3) (renamed __glob30, so beside glibc's), stringlist, errc/warnc, fmtcheck, shquote, getcap, strtonum, heapsort/merge/radixsort, base64, stresep, and the <db.h>/<md2.h>/<ndbm.h>/<stringlist.h> frames that reach over to src/include. -mx_cdefs.h: __strong_alias/__weak_alias stay off inside libmxlinux (-D_MX_LIBMXLINUX). The libc sources it compiles alias their public names to libc-internal ones in hashhl.c before namespace.h can withdraw the macro, and those names do not exist outside libc -- every program linked against the library had undefined _MD2FileChunk. src/tools/compat builds the same sources without them for the same reason. -mxlinux.h: the feature set is asked for the way NetBSD's <sys/featuretest.h> asks for it. A program with -std=c99 alone asks for no standard, which on NetBSD means _NETBSD_SOURCE (everything); glibc gives ISO C only, so _DEFAULT_SOURCE and _NETBSD_SOURCE are set before the first glibc header. -mobile/conf/mk.conf: the NetBSD subsystems with a NetBSD kernel underneath are off for a Linux target -- MKAUDIO, MKBLUETOOTH, MKUSB, MKNFS, MKYP, MKHESIOD, MKSKEY, MKKERBEROS, MKPAM -- and libpthread is glibc's (LIBDO.pthread=_external), not NetBSD's LWP threads. -mobile/tools/mxsrc.sh: USE_FILEMON=no on the command line, because make(1) decides on filemon before bsd.own.mk reads mk.conf and traces with ktrace(2)/filemon(4), which Linux has neither of. Measured: make src DIR=lib/libmxlinux -> mxsrc lib/libmxlinux exit=0, 0 errors (mobile/build/logs/mxsrc-libmxlinux-2026-11-12-b.log).
58 lines
2.2 KiB
Bash
Executable File
58 lines
2.2 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# NetBSD's normal build of a directory of src/ for Makronix/Linux
|
|
# (docs/NETBSD-USERLAND.md, phase L): the tooldir's nbmake-evbarm64
|
|
# wrapper (tools/mktooldir.sh, build.sh tools for aarch64-linux-gnu) with
|
|
# MAKECONF=mobile/conf/mk.conf what a Linux target needs (start files,
|
|
# libmxlinux, NOGCCERROR)
|
|
# DESTDIR=build/mxsysroot-<dev> the sysroot, which is the destdir, as
|
|
# on NetBSD
|
|
# MKUNPRIVED=yes owners and modes into DESTDIR/METALOG
|
|
# and the objects in build/tools-obj/<dir> -- build.sh's -O directory,
|
|
# which holds tools/ and the distribution alike, as on NetBSD. "obj"
|
|
# always runs first: without it the wrapper's MAKEOBJDIR finds no
|
|
# directory and make writes its objects into src/ (2026-11-12, cleaned
|
|
# with cleandir).
|
|
#
|
|
# Usage: mxsrc.sh DEVICEDIR DIR [target ...] (make src DIR=bin [TARGETS=...])
|
|
# DIR is relative to src/ (bin, bin/cat, lib/libmxlinux); the targets
|
|
# default to "dependall install", NetBSD's order (build.sh distribution).
|
|
# -k: the log of a whole directory names every program that fails.
|
|
|
|
set -eu
|
|
. "$(dirname "$0")/lib.sh"
|
|
|
|
[ $# -ge 2 ] || { echo "usage: $0 DEVICEDIR DIR [target ...]" >&2; exit 2; }
|
|
load_device "$1"
|
|
dir=$2
|
|
shift 2
|
|
dev=$(basename "$DEVDIR")
|
|
repo=$(cd "$ROOT/.." && pwd)
|
|
target=aarch64-linux-gnu
|
|
tooldir=$(ls -d "$ROOT"/build/tooldir.*-$target 2>/dev/null | head -n 1)
|
|
mk=$tooldir/bin/nbmake-evbarm64
|
|
[ -x "$mk" ] || die "no $mk (make tooldir)"
|
|
sysroot=$ROOT/build/mxsysroot-$dev
|
|
[ -f "$sysroot/usr/lib/libc.so.6" ] || die "no glibc in $sysroot (make glibc)"
|
|
[ -d "$repo/src/$dir" ] || die "no src/$dir"
|
|
|
|
[ $# -gt 0 ] || set -- dependall install
|
|
|
|
cd "$repo/src/$dir"
|
|
"$mk" obj >/dev/null
|
|
# one pass per target, as build.sh runs them: -j inside a pass only.
|
|
# USE_FILEMON=no on the command line, not in mk.conf: make(1)'s filemon
|
|
# traces with NetBSD's ktrace(2) or filemon(4), which Linux has neither of,
|
|
# and usr.bin/make/Makefile:65-66 decides on it before bsd.own.mk reads
|
|
# mk.conf.
|
|
rc=0
|
|
for t; do
|
|
echo "===> mxsrc: $dir $t"
|
|
"$mk" -k -j "$(nproc)" \
|
|
MAKECONF="$ROOT/conf/mk.conf" DESTDIR="$sysroot" MKUNPRIVED=yes \
|
|
USE_FILEMON=no \
|
|
"$t" || rc=1
|
|
done
|
|
echo "mxsrc $dir exit=$rc"
|
|
exit $rc
|