1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-07 09:20:11 +00:00
freebsd/share/mk/bsd.compat.mk

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

140 lines
3.5 KiB
Makefile
Raw Normal View History

# $FreeBSD$
.if !targets(__<${_this:T}>__)
__<${_this:T}>__:
.if defined(_LIBCOMPAT)
COMPAT_ARCH?= ${TARGET_ARCH}
COMPAT_CPUTYPE?= ${CPUTYPE_${_LIBCOMPAT}}
.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
.else
COMPAT_ARCH= ${MACHINE_ARCH}
COMPAT_CPUTYPE= ${CPUTYPE}
.include <bsd.compiler.mk>
COMPAT_COMPILER_TYPE=${COMPILER_TYPE}
.endif
# -------------------------------------------------------------------
# 32 bit world
.if ${COMPAT_ARCH} == "amd64"
HAS_COMPAT=32
.if empty(COMPAT_CPUTYPE)
LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
.else
LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE}
.endif
.if ${COMPAT_COMPILER_TYPE} == gcc
.else
LIB32CPUFLAGS+= -target x86_64-unknown-freebsd${OS_REVISION}
.endif
LIB32CPUFLAGS+= -m32
LIB32_MACHINE= i386
LIB32_MACHINE_ARCH= i386
LIB32WMAKEENV= MACHINE_CPU="i686 mmx sse sse2"
LIB32WMAKEFLAGS= \
AS="${XAS} --32" \
LD="${XLD} -m elf_i386_fbsd"
.elif ${COMPAT_ARCH} == "powerpc64"
HAS_COMPAT=32
.if empty(COMPAT_CPUTYPE)
LIB32CPUFLAGS= -mcpu=powerpc
.else
LIB32CPUFLAGS= -mcpu=${COMPAT_CPUTYPE}
.endif
.if ${COMPAT_COMPILER_TYPE} == "gcc"
LIB32CPUFLAGS+= -m32
.else
LIB32CPUFLAGS+= -target powerpc-unknown-freebsd${OS_REVISION}
.endif
LIB32_MACHINE= powerpc
LIB32_MACHINE_ARCH= powerpc
LIB32WMAKEFLAGS= \
LD="${XLD} -m elf32ppc_fbsd"
.endif
LIB32WMAKEFLAGS+= NM="${XNM}"
LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}"
LIB32CFLAGS= -DCOMPAT_32BIT
LIB32DTRACE= ${DTRACE} -32
LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
LIB32_MACHINE_ABI= ${MACHINE_ABI:N*64} long32 ptr32
.if ${COMPAT_ARCH} == "amd64"
LIB32_MACHINE_ABI+= time32
.else
LIB32_MACHINE_ABI+= time64
.endif
# -------------------------------------------------------------------
# In the program linking case, select LIBCOMPAT
.if defined(NEED_COMPAT)
.ifndef HAS_COMPAT
.warning NEED_COMPAT defined, but no LIBCOMPAT is available (COMPAT_ARCH == ${COMPAT_ARCH})
.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
# -------------------------------------------------------------------
# Generic code for each type.
# Set defaults based on type.
libcompat= ${_LIBCOMPAT:tl}
_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS LDFLAGS \
_MACHINE _MACHINE_ARCH _MACHINE_ABI \
WMAKEENV WMAKEFLAGS WMAKE WORLDTMP
.for _var in ${_LIBCOMPAT_MAKEVARS}
.if !empty(LIB${_LIBCOMPAT}${_var})
LIBCOMPAT${_var}?= ${LIB${_LIBCOMPAT}${_var}}
.endif
.endfor
WORLDTMP?= ${SYSROOT}
# Shared flags
LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat}
LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \
--sysroot=${WORLDTMP} \
${BFLAGS}
LIBCOMPATLDFLAGS+= -L${WORLDTMP}/usr/lib${libcompat}
LIBCOMPATWMAKEENV+= MACHINE=${LIBCOMPAT_MACHINE}
LIBCOMPATWMAKEENV+= MACHINE_ARCH=${LIBCOMPAT_MACHINE_ARCH}
# -B is needed to find /usr/lib32/crti.o for gcc.
LIBCOMPATCFLAGS+= -B${WORLDTMP}/usr/lib${libcompat}
.if defined(WANT_COMPAT)
LIBDIR_BASE:= /usr/lib${libcompat}
LIBDATADIR:= /usr/lib${libcompat}
_LIB_OBJTOP= ${LIBCOMPAT_OBJTOP}
CFLAGS+= ${LIBCOMPATCFLAGS}
LDFLAGS+= ${CFLAGS} ${LIBCOMPATLDFLAGS}
MACHINE= ${LIBCOMPAT_MACHINE}
MACHINE_ARCH= ${LIBCOMPAT_MACHINE_ARCH}
.endif
.endif