Allow bsd.compat.mk to be reliably included outside Makefile.inc1.

Replace explicit TARGET_* variables with COMPAT_* versions defined based
on where the file is being included.

Also, require that bsd.compat.mk be included directly. It's not going to
be widely used so always loading it in bsd.prog.mk doesn't make sense.
Instead users can include it directly.

Reviewed by:	 imp, bdrewery (prior revision)
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D22059
This commit is contained in:
Brooks Davis 2019-10-31 20:37:19 +00:00
parent 2731abe8e6
commit c09aa2145a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354227
3 changed files with 35 additions and 21 deletions

View File

@ -379,10 +379,6 @@ LINKMODE Mode of links created with LINKS [${BINMODE}].
MAN Manual pages. If no MAN variable is defined,
"MAN=${PROG}.1" is assumed. See bsd.man.mk for more details.
NEED_COMPAT Build and link targeting a compatability ABI or fail if it
is not available. Supported values are "32", "soft", and
"any" being a wildcard.
PROG The name of the program to build. If not supplied, nothing
is built.
@ -445,9 +441,6 @@ SUBDIR A list of subdirectories that should be built as well.
Each of the targets will execute the same target in the
subdirectories.
WANT_COMPAT Similar to NEED_COMPAT, but build with the base ABI if
the specified ABI is not available.
The include file <bsd.prog.mk> includes the file named "../Makefile.inc"
if it exists, as well as the include file <bsd.man.mk>.
@ -473,6 +466,20 @@ If foo has multiple source files, add the line:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The include file, <bsd.compat.mk>, allows programs (built with
<bsd.prog.mk>) to be built for one the ABI(s) supported by the
top-level Makefile.libcompat. It requires that <bsd.prog.mk> also be
included.
NEED_COMPAT Build and link targeting a compatibility ABI or fail if it
is not available. Supported values are "32", "soft", and
"any" being a wildcard.
WANT_COMPAT Similar to NEED_COMPAT, but build with the base ABI if
the specified ABI is not available.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The include file, <bsd.snmpmod.mk>, handles building MIB modules for bsnmpd
from one or more source files, along with their manual pages. It has a
limited number of suffixes, consistent with the current needs of the BSD

View File

@ -3,14 +3,22 @@
.if !targets(__<${_this:T}>__)
__<${_this:T}>__:
.if defined(_LIBCOMPAT)
COMPAT_ARCH= ${TARGET_ARCH}
COMPAT_CPUTYPE= ${TARGET_CPUTYPE}
.else
COMPAT_ARCH= ${MACHINE_ARCH}
COMPAT_CPUTYPE= ${CPUTYPE}
.endif
# -------------------------------------------------------------------
# 32 bit world
.if ${TARGET_ARCH} == "amd64"
.if ${COMPAT_ARCH} == "amd64"
HAS_COMPAT=32
.if empty(TARGET_CPUTYPE)
.if empty(COMPAT_CPUTYPE)
LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
.else
LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE}
.endif
.if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
@ -24,29 +32,29 @@ LIB32WMAKEFLAGS= \
AS="${XAS} --32" \
LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32"
.elif ${TARGET_ARCH} == "powerpc64"
.elif ${COMPAT_ARCH} == "powerpc64"
HAS_COMPAT=32
.if empty(TARGET_CPUTYPE)
.if empty(COMPAT_CPUTYPE)
LIB32CPUFLAGS= -mcpu=powerpc
.else
LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
LIB32CPUFLAGS= -mcpu=${COMPAT_CPUTYPE}
.endif
LIB32CPUFLAGS+= -m32
LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
LIB32WMAKEFLAGS= \
LD="${XLD} -m elf32ppc_fbsd"
.elif ${TARGET_ARCH:Mmips64*} != ""
.elif ${COMPAT_ARCH:Mmips64*} != ""
HAS_COMPAT=32
.if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
.if empty(TARGET_CPUTYPE)
.if empty(COMPAT_CPUTYPE)
LIB32CPUFLAGS= -march=mips3
.else
LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE}
.endif
.else
.if ${TARGET_ARCH:Mmips64el*} != ""
.if ${COMPAT_ARCH:Mmips64el*} != ""
LIB32CPUFLAGS= -target mipsel-unknown-freebsd13.0
.else
LIB32CPUFLAGS= -target mips-unknown-freebsd13.0
@ -54,7 +62,7 @@ LIB32CPUFLAGS= -target mips-unknown-freebsd13.0
.endif
LIB32CPUFLAGS+= -mabi=32
LIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips
.if ${TARGET_ARCH:Mmips64el*} != ""
.if ${COMPAT_ARCH:Mmips64el*} != ""
LIB32WMAKEFLAGS= LD="${XLD} -m elf32ltsmip_fbsd"
.else
LIB32WMAKEFLAGS= LD="${XLD} -m elf32btsmip_fbsd"
@ -70,11 +78,11 @@ LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
# -------------------------------------------------------------------
# soft-fp world
.if ${TARGET_ARCH:Marmv[67]*} != ""
.if ${COMPAT_ARCH:Marmv[67]*} != ""
HAS_COMPAT=SOFT
LIBSOFTCFLAGS= -DCOMPAT_SOFTFP
LIBSOFTCPUFLAGS= -mfloat-abi=softfp
LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${TARGET_ARCH}
LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${COMPAT_ARCH}
LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP
.endif

View File

@ -2,7 +2,6 @@
# $FreeBSD$
.include <bsd.init.mk>
# .include <bsd.compat.mk>
.include <bsd.compiler.mk>
.include <bsd.linker.mk>