Make _TO_CPUARCH macro for ARCH to CPUARCH conversions

Consolidate all the regular expressions to convert from MACHINE_ARCH
to MACHINE_CPUARCH into a variable and use that variable in preference
to the almost identical copies in the tree (which should have been
identical).

Differential Revision: https://reviews.freebsd.org/D11986
This commit is contained in:
Warner Losh 2017-08-12 17:07:27 +00:00
parent b9c0f39213
commit 7709b2ae16
6 changed files with 14 additions and 8 deletions

View File

@ -245,12 +245,17 @@ _MAKE+= MK_META_MODE=no
.endif # !exists(/dev/filemon) && !defined(NO_FILEMON) .endif # !exists(/dev/filemon) && !defined(NO_FILEMON)
.endif # !defined(_CAN_USE_META_MODE) .endif # !defined(_CAN_USE_META_MODE)
# Guess machine architecture from machine type, and vice versa. # Guess target architecture from target type, and vice versa, based on
# historic FreeBSD practice of tending to have TARGET == TARGET_ARCH
# expanding to TARGET == TARGET_CPUARCH in recent times, with known
# exceptions.
.if !defined(TARGET_ARCH) && defined(TARGET) .if !defined(TARGET_ARCH) && defined(TARGET)
# T->TA mapping is usually TARGET with arm64 the odd man out
_TARGET_ARCH= ${TARGET:S/arm64/aarch64/} _TARGET_ARCH= ${TARGET:S/arm64/aarch64/}
.elif !defined(TARGET) && defined(TARGET_ARCH) && \ .elif !defined(TARGET) && defined(TARGET_ARCH) && \
${TARGET_ARCH} != ${MACHINE_ARCH} ${TARGET_ARCH} != ${MACHINE_ARCH}
_TARGET= ${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/aarch64/arm64/:C/powerpc64/powerpc/:C/powerpcspe/powerpc/:C/riscv64(sf)?/riscv/} # TA->T mapping is accidentally CPUARCH with aarch64 the odd man out
_TARGET= ${TARGET_ARCH:${__TO_CPUARCH}:C/aarch64/arm64/}
.endif .endif
.if defined(TARGET) && !defined(_TARGET) .if defined(TARGET) && !defined(_TARGET)
_TARGET=${TARGET} _TARGET=${TARGET}

View File

@ -7,7 +7,7 @@
VERSION= "2.17.50 [FreeBSD] 2007-07-03" VERSION= "2.17.50 [FreeBSD] 2007-07-03"
.if defined(TARGET_ARCH) .if defined(TARGET_ARCH)
TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}}
.else .else
TARGET_CPUARCH=${MACHINE_CPUARCH} TARGET_CPUARCH=${MACHINE_CPUARCH}
.endif .endif

View File

@ -4,7 +4,7 @@
# MACHINE_CPUARCH, but there's no easy way to export make functions... # MACHINE_CPUARCH, but there's no easy way to export make functions...
.if defined(TARGET_ARCH) .if defined(TARGET_ARCH)
TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64(sf)?/riscv64/} TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}}
.else .else
TARGET_CPUARCH=${MACHINE_CPUARCH} TARGET_CPUARCH=${MACHINE_CPUARCH}
.endif .endif

View File

@ -23,7 +23,7 @@ OBJ_RL= ${OBJTOP}/gnu/lib/libreadline/readline
# MACHINE_CPUARCH, but there's no easy way to export make functions... # MACHINE_CPUARCH, but there's no easy way to export make functions...
.if defined(TARGET_ARCH) .if defined(TARGET_ARCH)
TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}}
.else .else
TARGET_CPUARCH=${MACHINE_CPUARCH} TARGET_CPUARCH=${MACHINE_CPUARCH}
.endif .endif

View File

@ -4,7 +4,7 @@
# MACHINE_CPUARCH, but there's no easy way to export make functions... # MACHINE_CPUARCH, but there's no easy way to export make functions...
.if defined(TARGET_ARCH) .if defined(TARGET_ARCH)
TARGET_CPUARCH=${TARGET_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/} TARGET_CPUARCH=${TARGET_ARCH:${__TO_CPUARCH}}
.else .else
TARGET_CPUARCH=${MACHINE_CPUARCH} TARGET_CPUARCH=${MACHINE_CPUARCH}
.endif .endif

View File

@ -8,12 +8,13 @@ unix ?= We run FreeBSD, not UNIX.
# #
# MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with # MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with
# the same MACHINE_ARCH can run each other's binaries, so it necessarily # the same MACHINE_ARCH can run each other's binaries, so it necessarily
# has word size and endian swizzled in. However, support files for # has word size and endian swizzled in. However, the source files for
# these machines often are shared amongst all combinations of size # these machines often are shared amongst all combinations of size
# and/or endian. This is called MACHINE_CPU in NetBSD, but that's used # and/or endian. This is called MACHINE_CPU in NetBSD, but that's used
# for something different in FreeBSD. # for something different in FreeBSD.
# #
MACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64(sf)?/riscv/} __TO_CPUARCH=C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64(sf)?/riscv/
MACHINE_CPUARCH=${MACHINE_ARCH:${__TO_CPUARCH}}
.endif .endif