From c09aa2145ab281567daf3364d19e044352dd85fc Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Thu, 31 Oct 2019 20:37:19 +0000 Subject: [PATCH] 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 --- share/mk/bsd.README | 21 ++++++++++++++------- share/mk/bsd.compat.mk | 34 +++++++++++++++++++++------------- share/mk/bsd.prog.mk | 1 - 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/share/mk/bsd.README b/share/mk/bsd.README index 31cfa3f7f05..e50772151d0 100644 --- a/share/mk/bsd.README +++ b/share/mk/bsd.README @@ -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 includes the file named "../Makefile.inc" if it exists, as well as the include file . @@ -473,6 +466,20 @@ If foo has multiple source files, add the line: =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +The include file, , allows programs (built with +) to be built for one the ABI(s) supported by the +top-level Makefile.libcompat. It requires that 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, , 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 diff --git a/share/mk/bsd.compat.mk b/share/mk/bsd.compat.mk index 0f91af5ebd5..4d6c8aac56f 100644 --- a/share/mk/bsd.compat.mk +++ b/share/mk/bsd.compat.mk @@ -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 diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index d1b91915029..f0368ec5d2b 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -2,7 +2,6 @@ # $FreeBSD$ .include -# .include .include .include