Index: Makefile =================================================================== --- Makefile +++ Makefile @@ -301,8 +301,8 @@ .if make(native-xtools*) NXB_TARGET:= ${_TARGET} NXB_TARGET_ARCH:= ${_TARGET_ARCH} -_TARGET= ${MACHINE} -_TARGET_ARCH= ${MACHINE_ARCH} +_TARGET!= tools/build/build_machine.sh +_TARGET_ARCH!= tools/build/build_machine_arch.sh _MAKE+= NXB_TARGET=${NXB_TARGET} \ NXB_TARGET_ARCH=${NXB_TARGET_ARCH} .endif Index: Makefile.inc1 =================================================================== --- Makefile.inc1 +++ Makefile.inc1 @@ -446,7 +446,7 @@ .error CPUTYPE global should be set with ?=. .endif .if make(buildworld) -BUILD_ARCH!= uname -p +BUILD_ARCH!= tools/build/build_machine_arch.sh .if ${MACHINE_ARCH} != ${BUILD_ARCH} .error To cross-build, set TARGET_ARCH. .endif Index: include/Makefile =================================================================== --- include/Makefile +++ include/Makefile @@ -393,8 +393,8 @@ .if ${MACHINE} == "host" && !defined(_SKIP_BUILD) # we're here because we are building a sysroot... # we need MACHINE et al set correctly -HOST_MACHINE!= uname -m -HOST_MACHINE_ARCH!= uname -p -MACHINE:= ${HOST_MACHINE} -MACHINE_ARCH:= ${HOST_MACHINE_ARCH} +HOST_MACHINE!= uname -m +HOST_MACHINE_ARCH!= uname -p +MACHINE!= ${SRCTOP}/tools/build/build_machine.sh +MACHINE_ARCH!= ${SRCTOP}/tools/build/build_machine_arch.sh .endif Index: share/mk/src.sys.env.mk =================================================================== --- share/mk/src.sys.env.mk +++ share/mk/src.sys.env.mk @@ -54,6 +54,15 @@ .export MAKESYSPATH .endif +# On Linux/MacOS we change MACHINE will be x86_64 by default so we need to +# change it to amd64 to allow building on those systems. +.if ${MACHINE} == "x86_64" +MACHINE:=amd64 +MACHINE_ARCH:=amd64 +.export MACHINE +.export MACHINE_ARCH +.endif + .if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0 .sinclude "${.CURDIR}/Makefile.sys.inc" .endif Index: tools/build/build_machine.sh =================================================================== --- /dev/null +++ tools/build/build_machine.sh @@ -0,0 +1,10 @@ +#!/bin/sh -e + +build_arch=$(uname -p) +if [ "${build_arch}" = "x86_64" ]; then + build_arch="amd64" +elif [ "${build_arch}" = "i386" ] && [ "$(uname -m)" = "x86_64" ]; then + # On MacOS uname -m reports i386 even on 64bit systems + build_arch="amd64" +fi +echo "${build_arch}" Index: tools/build/build_machine_arch.sh =================================================================== --- /dev/null +++ tools/build/build_machine_arch.sh @@ -0,0 +1,7 @@ +#!/bin/sh -e + +build_machine=$(uname -m) +if [ "${build_machine}" = "x86_64" ]; then + build_machine="amd64" +fi +echo "${build_machine}"