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>
77 lines
3.4 KiB
Bash
77 lines
3.4 KiB
Bash
#!/bin/sh
|
|
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
|
|
#
|
|
# NetBSD make for the phone's userland (docs/NETBSD-USERLAND.md, A4-A6):
|
|
# what build.sh's nbmake-<machine> wrapper is for the desktop, with one
|
|
# difference -- the "host" of NetBSD's host-program machinery
|
|
# (src/tools/Makefile.host, bsd.hostprog.mk, src/tools/compat) is the phone:
|
|
# HOST_CC is the aarch64 compiler of tools/mktoolchain.sh. So a program is
|
|
# built exactly the way build.sh builds its nbcat or nbsed for this Linux
|
|
# host, only for aarch64 Linux.
|
|
#
|
|
# Usage: mxmake.sh DEVICEDIR [make arguments] (run in the directory to build)
|
|
#
|
|
# Objects go to build/userland/<device>/obj/<path under the repository>,
|
|
# never into src/. TOOLDIR is the phone's own (tools/mktooldir.sh: build.sh
|
|
# tools for aarch64-linux-gnu) -- nbmake, nbmtree, install, host-mkdep and the
|
|
# compiler all come from there; the desktop's tooldir is not needed (A4).
|
|
|
|
set -eu
|
|
. "$(dirname "$0")/lib.sh"
|
|
|
|
[ $# -ge 1 ] || { echo "usage: $0 DEVICEDIR [make arguments]" >&2; exit 2; }
|
|
load_device "$1"
|
|
shift
|
|
dev=$(basename "$DEVDIR")
|
|
|
|
repo=$(cd "$ROOT/.." && pwd)
|
|
target=aarch64-linux-gnu
|
|
tooldir=$(ls -d "$ROOT"/build/tooldir.*-$target 2>/dev/null | head -n 1)
|
|
[ -n "$tooldir" ] && [ -x "$tooldir/bin/nbmake" ] ||
|
|
die "no tooldir for $target with nbmake (make tooldir)"
|
|
tc=$ROOT/build/toolchain-$dev
|
|
[ -x "$tc/bin/cc" ] || die "no $tc/bin/cc (tools/mktoolchain.sh)"
|
|
ub=$ROOT/build/userland/$dev
|
|
|
|
BSHELL=/bin/sh HOST_SH=/bin/sh CONFIG_SHELL=/bin/sh LC_ALL=C
|
|
NETBSDSRCDIR=$repo/src
|
|
TOOLDIR=$tooldir
|
|
USETOOLS=yes
|
|
MKUNPRIVED=yes MKUPDATE=yes MKHTML=no MAKE_OBJDIR_CHECK_WRITABLE=no
|
|
# The phone, for what bsd.own.mk wants to know; host programs do not use it.
|
|
# MACHINE_GNU_PLATFORM as tools/mktooldir.sh built the tooldir: bsd.own.mk
|
|
# names the tooldir's programs after it (INSTALL, bsd.own.mk:482).
|
|
MACHINE=evbarm MACHINE_ARCH=aarch64 MACHINE_GNU_PLATFORM=$target
|
|
HOST_CC=$tc/bin/cc
|
|
HOST_CPP=$tc/bin/cpp
|
|
HOST_AR=$tooldir/bin/$target-ar
|
|
HOST_RANLIB=$tooldir/bin/$target-ranlib
|
|
MX_READELF=$tooldir/bin/$target-readelf
|
|
HOST_CFLAGS=-O2
|
|
MAKEOBJDIR="\${.CURDIR:C,^$repo/,$ub/obj/,}"
|
|
MAKEFLAGS="-m $repo/src/share/mk MKOBJDIRS=yes"
|
|
MX_DESTDIR=$ub/destdir
|
|
# Everything that is not the program itself (man pages ...) installs under
|
|
# DESTDIR; unset, bsd.man.mk aimed at the host's /usr/share/man as
|
|
# root:wheel (2026-11-11, stopped by "unknown group wheel"). MKUNPRIVED
|
|
# makes install(1) record owner and mode in ${DESTDIR}/METALOG instead.
|
|
DESTDIR=$MX_DESTDIR
|
|
MX_SYSROOT=$ROOT/build/mxsysroot-$dev
|
|
MX_TOOLCHAIN=$tc
|
|
MX_TOOLS=$ROOT/tools
|
|
# configure scripts (src/tools/compat) run the test programs they compile;
|
|
# binfmt hands an aarch64 binary to qemu-user, which finds the phone's
|
|
# dynamic linker and glibc through QEMU_LD_PREFIX -- the sysroot.
|
|
QEMU_LD_PREFIX=$MX_SYSROOT
|
|
export QEMU_LD_PREFIX
|
|
export BSHELL HOST_SH CONFIG_SHELL LC_ALL NETBSDSRCDIR TOOLDIR USETOOLS \
|
|
MKUNPRIVED MKUPDATE MKHTML MAKE_OBJDIR_CHECK_WRITABLE MACHINE MACHINE_ARCH MACHINE_GNU_PLATFORM \
|
|
HOST_CC HOST_CPP HOST_AR HOST_RANLIB MX_READELF HOST_CFLAGS MAKEOBJDIR MAKEFLAGS \
|
|
MX_DESTDIR MX_SYSROOT MX_TOOLCHAIN MX_TOOLS DESTDIR
|
|
unset MAKEOBJDIRPREFIX C_INCLUDE_PATH CPLUS_INCLUDE_PATH
|
|
# HOST_MKDEP only a variable on make's command line overrides:
|
|
# src/tools/compat/Makefile:163 wants the uninstalled host-mkdep in its own
|
|
# object directory; the tooldir has it installed.
|
|
exec "$tooldir/bin/nbmake" \
|
|
HOST_MKDEP="CC=$HOST_CC $tooldir/bin/nbhost-mkdep" "$@"
|