diff --git a/AGENTS.md b/AGENTS.md index 72908a4217..7454e85c41 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -68,8 +68,9 @@ in a fork gets the CNCL line; a changed upstream file keeps the notice it has. ## Building -Everything builds from the root `Makefile`. The interface is meant to stay -this small -- **do not add targets**: +Everything builds from the root `Makefile`. It is NetBSD make (Konrad, +2026-11-19): `make` on Makronix, `bmake` on a Linux host; GNU make does not +read it. The interface is meant to stay this small -- **do not add targets**: make the build (sets) make release the release: sets, kernels, ramdisks, media diff --git a/Makefile b/Makefile index 7118effcee..ed746357e6 100644 --- a/Makefile +++ b/Makefile @@ -9,34 +9,43 @@ # ARCH is the name a person types (amd64, sparc64, evbarm); MACHINE is # NetBSD's internal name for the same thing. When the host is NetBSD and ARCH # is not given, the host decides; otherwise amd64. +# +# This file is NetBSD make (make(1), bmake on other systems; Konrad, +# 2026-11-19: "bmake natuerlich"). GNU make does not read it. -TOP := $(CURDIR) +TOP := ${.CURDIR} SRC := $(TOP)/src # X for the base, as NetBSD builds it (build.sh -x -X, src/BUILDING): imported # like src/, its upstream commit in xsrc/BASE (Konrad, 2026-11-13). XSRC := $(TOP)/xsrc OBJ := $(TOP)/build/obj -JOBS ?= $(shell nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2) +# sysctl(8) is in /sbin, which a non-login shell's PATH may lack. +.if !defined(JOBS) +JOBS != nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || \ + /sbin/sysctl -n hw.ncpu 2>/dev/null || echo 2 +.endif -ARCH ?= $(shell uname -m 2>/dev/null | sed -e 's/x86_64/amd64/' -e 's/aarch64/evbarm/' || echo amd64) +.if !defined(ARCH) +ARCH != uname -m 2>/dev/null | sed -e 's/x86_64/amd64/' -e 's/aarch64/evbarm/' || echo amd64 +.endif # build.sh wants NetBSD's machine name. For the architectures where the two # names differ, this is the mapping; everything else is passed through. MACHINE := $(ARCH) -ifeq ($(ARCH),amd64) +.if ${ARCH} == "amd64" MACHINE := amd64 -endif -ifeq ($(ARCH),i386) +.elif ${ARCH} == "i386" MACHINE := i386 -endif +.endif BUILD_SH := cd $(SRC) && ./build.sh \ -U -u -j $(JOBS) -m $(MACHINE) \ -M $(OBJ) -O $(OBJ) -x -X $(XSRC) -# The recursive make for cdtest. Not spelled $(MAKE): GNU make runs a recipe -# that contains $(MAKE) even with -n, and the rest of the cdtest line would -# start a VM; MAKE_CMD is only printed. +# The recursive make for cdtest and release. With -n, make(1) runs a command +# only for a .MAKE target or a line starting with `+' (make(1), -n), so `make -n +# cdtest' prints the line and starts no VM. MAKE_CMD keeps it that way should +# the recipe ever be marked .MAKE. MAKE_CMD := $(MAKE) .PHONY: all build release install tools kernel clean-sanity stamp test compress \ @@ -174,7 +183,7 @@ install: @uname -s | grep -qx NetBSD || { \ echo "make install: this installs over the running system,"; \ echo "make install: which only makes sense on Makronix/NetBSD."; \ - echo "make install: on $(shell uname -s), build with 'make' instead."; \ + echo "make install: on $$(uname -s), build with 'make' instead."; \ exit 1; } @tools/build-lock.sh '$(BUILD_SH) install=/'