Move MACHINE/MACHINE_ARCH handling to sys.machine.mk

Rather than define the TARGETS and TARGET_ARCHES in src/Makefile
put them in sys.machine.mk so they can also be leveraged by
non-top-level builds.

We have TARGET_MACHINE_LIST as the list of MACHINES we build for.

For each MACHINE we have a MACHINE_ARCH_LIST_${MACHINE}
and the first entry of each list is used as default for
MACHINE_ARCH_${MACHINE}

We can now remove a bunch of MACHINE_ARCH.* handling from
local.sys.dirdeps*mk

Reviewed by:	imp
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D40083
This commit is contained in:
Simon J. Gerraty 2023-05-13 08:15:49 -07:00
parent f2b3bf5c4d
commit da1ef2d619
4 changed files with 30 additions and 33 deletions

View File

@ -530,14 +530,10 @@ worlds: .PHONY
# powerpcspe excluded from main list until clang fixed
EXTRA_ARCHES_powerpc= powerpcspe
.endif
TARGETS?=amd64 arm arm64 i386 powerpc riscv
TARGETS?= ${TARGET_MACHINE_LIST}
_UNIVERSE_TARGETS= ${TARGETS}
TARGET_ARCHES_arm?= armv6 armv7
TARGET_ARCHES_arm64?= aarch64
TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpc64le ${EXTRA_ARCHES_powerpc}
TARGET_ARCHES_riscv?= riscv64
.for target in ${TARGETS}
TARGET_ARCHES_${target}?= ${target}
TARGET_ARCHES_${target}= ${MACHINE_ARCH_LIST_${target}}
.endfor
.if defined(USE_GCC_TOOLCHAINS)

View File

@ -12,41 +12,17 @@ TARGET_SPEC_VARS?= MACHINE MACHINE_ARCH
${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \
${.MAKE.DEPENDFILE_PREFIX}
# before we process TARGET_SPEC
# we assume that MK_DIRDEPS_BUILD=yes
# from src/Makefile (for universe)
# would be nice to have this sort of info in sys.machine.mk
TARGET_ARCHES_arm?= armv6 armv7
TARGET_ARCHES_arm64?= aarch64
TARGET_ARCHES_powerpc?= powerpc powerpc64 powerpc64le powerpcspe
TARGET_ARCHES_riscv?= riscv64
# some corner cases
BOOT_MACHINE_DIR.amd64 = boot/i386
MACHINE_ARCH.host = ${_HOST_ARCH}
# the list of machines we support
ALL_MACHINE_LIST?= amd64 arm arm64 i386 powerpc riscv
.-include <site.sys.dirdeps.env.mk>
ALL_MACHINE_LIST?= ${TARGET_MACHINE_LIST}
.for m in ${ALL_MACHINE_LIST:O:u}
MACHINE_ARCH_LIST.$m?= ${TARGET_ARCHES_${m}:U$m}
MACHINE_ARCH.$m?= ${MACHINE_ARCH_LIST.$m:[1]}
BOOT_MACHINE_DIR.$m ?= boot/$m
.endfor
.if empty(MACHINE_ARCH)
.if !empty(TARGET_ARCH)
MACHINE_ARCH= ${TARGET_ARCH}
.else
MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
.endif
.endif
MACHINE_ARCH?= ${MACHINE_ARCH.${MACHINE}}
MACHINE_ARCH:= ${MACHINE_ARCH}
HOST_OBJTOP ?= ${OBJROOT}${HOST_TARGET}
.if ${REQUESTED_MACHINE:U${MACHINE}} == "host"
@ -58,7 +34,7 @@ TARGET_MACHINE= host
.endif
.if ${MACHINE} == "host"
OBJTOP := ${HOST_OBJTOP}
MACHINE_ARCH= ${MACHINE_ARCH.${MACHINE}}
MACHINE_ARCH= ${MACHINE_ARCH_${MACHINE}}
.endif

View File

@ -56,3 +56,5 @@ ECHO_TRACE?= true
.include <host-target.mk>
.export HOST_TARGET
.endif
.include <sys.machine.mk>

23
share/mk/sys.machine.mk Normal file
View File

@ -0,0 +1,23 @@
.-include <local.sys.machine.mk>
PSEUDO_MACHINE_LIST?= common host
TARGET_MACHINE_LIST?= amd64 arm arm64 i386 powerpc riscv
MACHINE_ARCH_host?= ${_HOST_ARCH}
MACHINE_ARCH_LIST_arm?= armv6 armv7
MACHINE_ARCH_LIST_arm64?= aarch64
MACHINE_ARCH_LIST_powerpc?= powerpc powerpc64 powerpc64le ${EXTRA_ARCHES_powerpc}
MACHINE_ARCH_LIST_riscv?= riscv64
.for m in ${TARGET_MACHINE_LIST}
MACHINE_ARCH_LIST_$m?= $m
MACHINE_ARCH_$m?= ${MACHINE_ARCH_LIST_$m:[1]}
# for backwards comatability
MACHINE_ARCH.$m?= ${MACHINE_ARCH_$m}
.endfor
.if empty(MACHINE_ARCH)
MACHINE_ARCH:= ${MACHINE_ARCH_${MACHINE}}
.endif