| git.druid.rocks | index | druid520 | ports | ports/ | build-tools/ | bmake/ | add.sh |
ports/build-tools/bmake/add.sh
set -e
git clone --filter=blob:none --no-checkout --depth=1 https://github.com/NetBSD/src.git bmake
cd bmake
git sparse-checkout init --cone
git sparse-checkout set usr.bin/make share/mk
git checkout trunk
cd usr.bin/make
# HAVE_VSNPRINTF/HAVE_STRERROR: Makefile.boot is a configure-free
# bootstrap path (no config.h, no real autoconf-style detection at
# all) -- util.c's own portability fallbacks for vsnprintf/strerror are
# gated on "#if !defined(MAKE_NATIVE) && !defined(HAVE_XXX)", and
# neither macro is ever defined by this bootstrap path on any system,
# so BOTH broken fallbacks always compile in otherwise. Confirmed for
# real: vsnprintf's own fallback ends in a deliberately-invalid
# "::: \"error: vsnprintf must be available\";" (a hard compile
# failure, not a runtime one), and strerror's own fallback references
# sys_nerr/sys_errlist -- both real, but deliberately-removed-decades-
# ago glibc-only globals that musl (correctly, per current POSIX) does
# not provide, so it just fails to LINK instead. musl provides working
# implementations of both real functions; these two defines just skip
# NetBSD's own legacy-libc-detection fallbacks entirely in favor of
# musl's real ones.
#
# TARGET_MACHINE/TARGET_MACHINE_ARCH/MAKE_MACHINE all still hardcode
# "i386" (Makefile.boot's own uname-less default) -- cosmetic only for
# this port's actual use (nothing here cross-compiles or branches
# machine-specific code based on these macros), left as-is rather than
# widening scope to also fix NetBSD's own machine-detection logic.
# NOT "make -f Makefile.boot": this is bmake's OWN bootstrap, self-
# referential the same way languages/perl5, coreutils/sbase, etc. are
# -- something has to build the very first "make" this system ever
# has, and it can't be make itself. Replicated Makefile.boot's own
# (tiny, stable) build recipe directly in shell instead, so this port
# never depends on any make variant already being present.
BOOT_CFLAGS="-DTARGET_MACHINE=\"i386\" -DTARGET_MACHINE_ARCH=\"i386\" -DMAKE_MACHINE=\"i386\" -DHAVE_VSNPRINTF -DHAVE_STRERROR $CFLAGS"
for f in arch buf compat cond dir for hash job lst main make make_malloc metachar parse str suff targ trace var util; do
${CC:-cc} $BOOT_CFLAGS -c $f.c -o $f.o
done
${CC:-cc} $CFLAGS arch.o buf.o compat.o cond.o dir.o for.o hash.o job.o lst.o main.o make.o make_malloc.o metachar.o parse.o str.o suff.o targ.o trace.o var.o util.o -o bmake
install -m 755 bmake $MP_PREFIX/bin/make
# bmake needs its own system rules (sys.mk, bsd.*.mk -- standard BSD
# make convention for built-in suffix rules etc) to function AT ALL,
# not just for BSD-style Makefiles specifically -- confirmed for real:
# "bmake: no system rules (sys.mk)" on a completely plain, no-BSD-isms
# test Makefile, immediately, before even getting to parse it.
mkdir -p $MP_PREFIX/share/mk
install -m 644 ../../share/mk/*.mk $MP_PREFIX/share/mk/
cd ../../..