2019-10-15 21:08:49 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
|
|
|
.if !targets(__<${_this:T}>__)
|
|
|
|
__<${_this:T}>__:
|
|
|
|
|
2019-10-31 20:37:19 +00:00
|
|
|
.if defined(_LIBCOMPAT)
|
|
|
|
COMPAT_ARCH= ${TARGET_ARCH}
|
|
|
|
COMPAT_CPUTYPE= ${TARGET_CPUTYPE}
|
2019-11-07 22:58:10 +00:00
|
|
|
.if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \
|
|
|
|
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
|
|
|
|
COMPAT_COMPILER_TYPE= gcc
|
|
|
|
.else
|
|
|
|
COMPAT_COMPILER_TYPE= clang
|
|
|
|
.endif
|
2019-10-31 20:37:19 +00:00
|
|
|
.else
|
|
|
|
COMPAT_ARCH= ${MACHINE_ARCH}
|
|
|
|
COMPAT_CPUTYPE= ${CPUTYPE}
|
2019-11-07 22:58:10 +00:00
|
|
|
.include <bsd.compiler.mk>
|
|
|
|
COMPAT_COMPILER_TYPE=${COMPILER_TYPE}
|
2019-10-31 20:37:19 +00:00
|
|
|
.endif
|
|
|
|
|
2019-10-15 21:08:49 +00:00
|
|
|
# -------------------------------------------------------------------
|
|
|
|
# 32 bit world
|
2019-10-31 20:37:19 +00:00
|
|
|
.if ${COMPAT_ARCH} == "amd64"
|
2019-10-15 21:27:06 +00:00
|
|
|
HAS_COMPAT=32
|
2019-10-31 20:37:19 +00:00
|
|
|
.if empty(COMPAT_CPUTYPE)
|
2019-10-15 21:08:49 +00:00
|
|
|
LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
|
|
|
|
.else
|
2019-10-31 20:37:19 +00:00
|
|
|
LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE}
|
2019-10-15 21:08:49 +00:00
|
|
|
.endif
|
2019-11-07 22:58:10 +00:00
|
|
|
.if ${COMPAT_COMPILER_TYPE} == gcc
|
2019-10-15 21:08:49 +00:00
|
|
|
.else
|
|
|
|
LIB32CPUFLAGS+= -target x86_64-unknown-freebsd13.0
|
|
|
|
.endif
|
|
|
|
LIB32CPUFLAGS+= -m32
|
2019-11-07 22:58:10 +00:00
|
|
|
LIB32_MACHINE= i386
|
|
|
|
LIB32_MACHINE_ARCH= i386
|
|
|
|
LIB32WMAKEENV= MACHINE_CPU="i686 mmx sse sse2"
|
2019-10-15 21:08:49 +00:00
|
|
|
LIB32WMAKEFLAGS= \
|
|
|
|
AS="${XAS} --32" \
|
|
|
|
LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32"
|
|
|
|
|
2019-10-31 20:37:19 +00:00
|
|
|
.elif ${COMPAT_ARCH} == "powerpc64"
|
2019-10-15 21:27:06 +00:00
|
|
|
HAS_COMPAT=32
|
2019-10-31 20:37:19 +00:00
|
|
|
.if empty(COMPAT_CPUTYPE)
|
2019-10-15 21:08:49 +00:00
|
|
|
LIB32CPUFLAGS= -mcpu=powerpc
|
|
|
|
.else
|
2019-10-31 20:37:19 +00:00
|
|
|
LIB32CPUFLAGS= -mcpu=${COMPAT_CPUTYPE}
|
2019-10-15 21:08:49 +00:00
|
|
|
.endif
|
2019-12-24 16:03:33 +00:00
|
|
|
|
|
|
|
.if ${COMPAT_COMPILER_TYPE} == "gcc"
|
2019-10-15 21:08:49 +00:00
|
|
|
LIB32CPUFLAGS+= -m32
|
2019-12-24 16:03:33 +00:00
|
|
|
.else
|
|
|
|
LIB32CPUFLAGS+= -target powerpc-unknown-freebsd13.0
|
|
|
|
|
|
|
|
# Use BFD to workaround ld.lld issues on PowerPC 32 bit
|
|
|
|
LIB32CPUFLAGS+= -fuse-ld=${LD_BFD}
|
|
|
|
.endif
|
|
|
|
|
2019-11-07 22:58:10 +00:00
|
|
|
LIB32_MACHINE= powerpc
|
|
|
|
LIB32_MACHINE_ARCH= powerpc
|
2019-10-15 21:08:49 +00:00
|
|
|
LIB32WMAKEFLAGS= \
|
2019-12-24 16:03:33 +00:00
|
|
|
LD="${LD_BFD} -m elf32ppc_fbsd"
|
2019-10-15 21:08:49 +00:00
|
|
|
|
2019-10-31 20:37:19 +00:00
|
|
|
.elif ${COMPAT_ARCH:Mmips64*} != ""
|
2019-10-15 21:27:06 +00:00
|
|
|
HAS_COMPAT=32
|
2019-11-07 22:58:10 +00:00
|
|
|
.if ${COMPAT_COMPILER_TYPE} == gcc
|
2019-10-31 20:37:19 +00:00
|
|
|
.if empty(COMPAT_CPUTYPE)
|
2019-10-15 21:08:49 +00:00
|
|
|
LIB32CPUFLAGS= -march=mips3
|
|
|
|
.else
|
2019-10-31 20:37:19 +00:00
|
|
|
LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE}
|
2019-10-15 21:08:49 +00:00
|
|
|
.endif
|
|
|
|
.else
|
2019-10-31 20:37:19 +00:00
|
|
|
.if ${COMPAT_ARCH:Mmips64el*} != ""
|
2019-10-15 21:08:49 +00:00
|
|
|
LIB32CPUFLAGS= -target mipsel-unknown-freebsd13.0
|
|
|
|
.else
|
|
|
|
LIB32CPUFLAGS= -target mips-unknown-freebsd13.0
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
LIB32CPUFLAGS+= -mabi=32
|
2019-11-07 22:58:10 +00:00
|
|
|
LIB32_MACHINE= mips
|
2019-10-31 20:37:19 +00:00
|
|
|
.if ${COMPAT_ARCH:Mmips64el*} != ""
|
2020-01-03 23:31:38 +00:00
|
|
|
LIB32_MACHINE_ARCH= mipsel
|
2019-11-07 22:58:10 +00:00
|
|
|
_EMULATION= elf32ltsmip_fbsd
|
2019-10-15 21:08:49 +00:00
|
|
|
.else
|
2020-01-03 23:31:38 +00:00
|
|
|
LIB32_MACHINE_ARCH= mips
|
2019-11-07 22:58:10 +00:00
|
|
|
_EMULATION= elf32btsmip_fbsd
|
2019-10-15 21:08:49 +00:00
|
|
|
.endif
|
2019-11-07 22:58:10 +00:00
|
|
|
LIB32WMAKEFLAGS= LD="${XLD} -m ${_EMULATION}"
|
|
|
|
LIB32LDFLAGS= -Wl,-m${_EMULATION}
|
2019-10-15 21:08:49 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
LIB32WMAKEFLAGS+= NM="${XNM}"
|
|
|
|
LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}"
|
|
|
|
|
|
|
|
LIB32CFLAGS= -DCOMPAT_32BIT
|
|
|
|
LIB32DTRACE= ${DTRACE} -32
|
|
|
|
LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
# soft-fp world
|
2019-10-31 20:37:19 +00:00
|
|
|
.if ${COMPAT_ARCH:Marmv[67]*} != ""
|
2019-10-15 21:27:06 +00:00
|
|
|
HAS_COMPAT=SOFT
|
2019-10-15 21:08:49 +00:00
|
|
|
LIBSOFTCFLAGS= -DCOMPAT_SOFTFP
|
|
|
|
LIBSOFTCPUFLAGS= -mfloat-abi=softfp
|
2019-11-07 22:58:10 +00:00
|
|
|
LIBSOFT_MACHINE= arm
|
|
|
|
LIBSOFT_MACHINE_ARCH= ${COMPAT_ARCH}
|
|
|
|
LIBSOFTWMAKEENV= CPUTYPE=soft
|
2019-10-15 21:08:49 +00:00
|
|
|
LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP
|
|
|
|
.endif
|
|
|
|
|
2019-10-15 21:27:06 +00:00
|
|
|
# -------------------------------------------------------------------
|
|
|
|
# In the program linking case, select LIBCOMPAT
|
|
|
|
.if defined(NEED_COMPAT)
|
|
|
|
.ifndef HAS_COMPAT
|
2019-11-08 03:14:06 +00:00
|
|
|
.warning NEED_COMPAT defined, but no LIBCOMPAT is available (COMPAT_ARCH == ${COMPAT_ARCH}
|
2019-10-15 21:27:06 +00:00
|
|
|
.elif !${HAS_COMPAT:M${NEED_COMPAT}} && ${NEED_COMPAT} != "any"
|
|
|
|
.error NEED_COMPAT (${NEED_COMPAT}) defined, but not in HAS_COMPAT ($HAS_COMPAT)
|
|
|
|
.elif ${NEED_COMPAT} == "any"
|
|
|
|
.endif
|
|
|
|
.ifdef WANT_COMPAT
|
|
|
|
.error Both WANT_COMPAT and NEED_COMPAT defined
|
|
|
|
.endif
|
|
|
|
WANT_COMPAT:= ${NEED_COMPAT}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if defined(HAS_COMPAT) && defined(WANT_COMPAT)
|
|
|
|
.if ${WANT_COMPAT} == "any"
|
|
|
|
_LIBCOMPAT:= ${HAS_COMPAT:[1]}
|
|
|
|
.else
|
|
|
|
_LIBCOMPAT:= ${WANT_COMPAT}
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2019-10-15 21:08:49 +00:00
|
|
|
|
|
|
|
# -------------------------------------------------------------------
|
|
|
|
# Generic code for each type.
|
|
|
|
# Set defaults based on type.
|
2019-10-15 21:11:22 +00:00
|
|
|
libcompat= ${_LIBCOMPAT:tl}
|
2019-11-07 22:58:10 +00:00
|
|
|
_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS LDFLAGS \
|
|
|
|
_MACHINE _MACHINE_ARCH WMAKEENV WMAKEFLAGS WMAKE
|
2019-10-15 21:08:49 +00:00
|
|
|
.for _var in ${_LIBCOMPAT_MAKEVARS}
|
2019-10-15 21:11:22 +00:00
|
|
|
.if !empty(LIB${_LIBCOMPAT}${_var})
|
|
|
|
LIBCOMPAT${_var}?= ${LIB${_LIBCOMPAT}${_var}}
|
2019-10-15 21:08:49 +00:00
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
# Shared flags
|
|
|
|
LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat}
|
|
|
|
LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp
|
|
|
|
|
|
|
|
LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \
|
|
|
|
-L${LIBCOMPATTMP}/usr/lib${libcompat} \
|
|
|
|
--sysroot=${LIBCOMPATTMP} \
|
|
|
|
${BFLAGS}
|
|
|
|
|
2019-11-07 22:58:10 +00:00
|
|
|
LIBCOMPATWMAKEENV+= MACHINE=${LIBCOMPAT_MACHINE}
|
|
|
|
LIBCOMPATWMAKEENV+= MACHINE_ARCH=${LIBCOMPAT_MACHINE_ARCH}
|
|
|
|
|
2019-10-15 21:08:49 +00:00
|
|
|
# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for
|
|
|
|
# Clang/GCC.
|
|
|
|
LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat}
|
|
|
|
|
2019-10-15 21:27:06 +00:00
|
|
|
.if defined(WANT_COMPAT)
|
|
|
|
LIBDIR_BASE:= /usr/lib${libcompat}
|
|
|
|
_LIB_OBJTOP= ${LIBCOMPAT_OBJTOP}
|
|
|
|
CFLAGS+= ${LIBCOMPATCFLAGS}
|
2019-11-07 22:58:10 +00:00
|
|
|
LDFLAGS+= ${CFLAGS} ${LIBCOMPATLDFLAGS}
|
|
|
|
MACHINE= ${LIBCOMPAT_MACHINE}
|
|
|
|
MACHINE_ARCH= ${LIBCOMPAT_MACHINE_ARCH}
|
2019-10-15 21:27:06 +00:00
|
|
|
.endif
|
|
|
|
|
2019-10-15 21:08:49 +00:00
|
|
|
.endif
|