Files
lotherkandClaude Sonnet 5.5 73c9de51a6 licence: the CNCL line in every file Makronix wrote (tools, docs, www, mobile, top level)
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>
2026-11-14 11:50:26 +00:00

59 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
#
# 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