1# $FreeBSD$ 2 3.if !targets(__<${_this:T}>__) 4__<${_this:T}>__: 5 6.if defined(_LIBCOMPAT) 7COMPAT_ARCH?= ${TARGET_ARCH} 8COMPAT_CPUTYPE?= ${CPUTYPE_${_LIBCOMPAT}} 9.if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \ 10 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 11COMPAT_COMPILER_TYPE= gcc 12.else 13COMPAT_COMPILER_TYPE= clang 14.endif 15.else 16COMPAT_ARCH= ${MACHINE_ARCH} 17COMPAT_CPUTYPE= ${CPUTYPE} 18.include <bsd.compiler.mk> 19COMPAT_COMPILER_TYPE=${COMPILER_TYPE} 20.endif 21 22# ------------------------------------------------------------------- 23# 32 bit world 24.if ${COMPAT_ARCH} == "amd64" 25HAS_COMPAT=32 26.if empty(COMPAT_CPUTYPE) 27LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 28.else 29LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE} 30.endif 31.if ${COMPAT_COMPILER_TYPE} == gcc 32.else 33LIB32CPUFLAGS+= -target x86_64-unknown-freebsd14.0 34.endif 35LIB32CPUFLAGS+= -m32 36LIB32_MACHINE= i386 37LIB32_MACHINE_ARCH= i386 38LIB32WMAKEENV= MACHINE_CPU="i686 mmx sse sse2" 39LIB32WMAKEFLAGS= \ 40 AS="${XAS} --32" \ 41 LD="${XLD} -m elf_i386_fbsd" 42 43.elif ${COMPAT_ARCH} == "powerpc64" 44HAS_COMPAT=32 45.if empty(COMPAT_CPUTYPE) 46LIB32CPUFLAGS= -mcpu=powerpc 47.else 48LIB32CPUFLAGS= -mcpu=${COMPAT_CPUTYPE} 49.endif 50 51.if ${COMPAT_COMPILER_TYPE} == "gcc" 52LIB32CPUFLAGS+= -m32 53.else 54LIB32CPUFLAGS+= -target powerpc-unknown-freebsd14.0 55.endif 56 57LIB32_MACHINE= powerpc 58LIB32_MACHINE_ARCH= powerpc 59LIB32WMAKEFLAGS= \ 60 LD="${XLD} -m elf32ppc_fbsd" 61 62.elif ${COMPAT_ARCH:Mmips64*} != "" 63HAS_COMPAT=32 64.if ${COMPAT_COMPILER_TYPE} == gcc 65.if empty(COMPAT_CPUTYPE) 66LIB32CPUFLAGS= -march=mips3 67.else 68LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE} 69.endif 70.else 71.if ${COMPAT_ARCH:Mmips64el*} != "" 72LIB32CPUFLAGS= -target mipsel-unknown-freebsd14.0 73.else 74LIB32CPUFLAGS= -target mips-unknown-freebsd14.0 75.endif 76.endif 77LIB32CPUFLAGS+= -mabi=32 78LIB32_MACHINE= mips 79LIB32_MACHINE_ARCH:= ${COMPAT_ARCH:S/64//} 80.if ${COMPAT_ARCH:Mmips64el*} != "" 81_EMULATION= elf32ltsmip_fbsd 82.else 83_EMULATION= elf32btsmip_fbsd 84.endif 85LIB32WMAKEFLAGS= LD="${XLD} -m ${_EMULATION}" 86LIB32LDFLAGS= -Wl,-m${_EMULATION} 87.endif 88 89LIB32WMAKEFLAGS+= NM="${XNM}" 90LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}" 91 92LIB32CFLAGS= -DCOMPAT_32BIT 93LIB32DTRACE= ${DTRACE} -32 94LIB32WMAKEFLAGS+= -DCOMPAT_32BIT 95 96# ------------------------------------------------------------------- 97# soft-fp world 98.if ${COMPAT_ARCH:Marmv[67]*} != "" 99HAS_COMPAT=SOFT 100LIBSOFTCFLAGS= -DCOMPAT_SOFTFP 101LIBSOFTCPUFLAGS= -mfloat-abi=softfp 102LIBSOFT_MACHINE= arm 103LIBSOFT_MACHINE_ARCH= ${COMPAT_ARCH} 104LIBSOFTWMAKEENV= CPUTYPE=soft 105LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP 106.endif 107 108# ------------------------------------------------------------------- 109# In the program linking case, select LIBCOMPAT 110.if defined(NEED_COMPAT) 111.ifndef HAS_COMPAT 112.warning NEED_COMPAT defined, but no LIBCOMPAT is available (COMPAT_ARCH == ${COMPAT_ARCH} 113.elif !${HAS_COMPAT:M${NEED_COMPAT}} && ${NEED_COMPAT} != "any" 114.error NEED_COMPAT (${NEED_COMPAT}) defined, but not in HAS_COMPAT ($HAS_COMPAT) 115.elif ${NEED_COMPAT} == "any" 116.endif 117.ifdef WANT_COMPAT 118.error Both WANT_COMPAT and NEED_COMPAT defined 119.endif 120WANT_COMPAT:= ${NEED_COMPAT} 121.endif 122 123.if defined(HAS_COMPAT) && defined(WANT_COMPAT) 124.if ${WANT_COMPAT} == "any" 125_LIBCOMPAT:= ${HAS_COMPAT:[1]} 126.else 127_LIBCOMPAT:= ${WANT_COMPAT} 128.endif 129.endif 130 131 132# ------------------------------------------------------------------- 133# Generic code for each type. 134# Set defaults based on type. 135libcompat= ${_LIBCOMPAT:tl} 136_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS LDFLAGS \ 137 _MACHINE _MACHINE_ARCH WMAKEENV WMAKEFLAGS WMAKE 138.for _var in ${_LIBCOMPAT_MAKEVARS} 139.if !empty(LIB${_LIBCOMPAT}${_var}) 140LIBCOMPAT${_var}?= ${LIB${_LIBCOMPAT}${_var}} 141.endif 142.endfor 143 144# Shared flags 145LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat} 146LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp 147 148LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ 149 --sysroot=${LIBCOMPATTMP} \ 150 ${BFLAGS} 151 152LIBCOMPATLDFLAGS+= -L${LIBCOMPATTMP}/usr/lib${libcompat} 153 154LIBCOMPATWMAKEENV+= MACHINE=${LIBCOMPAT_MACHINE} 155LIBCOMPATWMAKEENV+= MACHINE_ARCH=${LIBCOMPAT_MACHINE_ARCH} 156 157# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for 158# Clang/GCC. 159LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat} 160 161.if defined(WANT_COMPAT) 162LIBDIR_BASE:= /usr/lib${libcompat} 163_LIB_OBJTOP= ${LIBCOMPAT_OBJTOP} 164LIBDESTDIR:= ${LIBCOMPATTMP} 165SYSROOT:= ${LIBCOMPATTMP} 166CFLAGS+= ${LIBCOMPATCFLAGS} 167LDFLAGS+= ${CFLAGS} ${LIBCOMPATLDFLAGS} 168MACHINE= ${LIBCOMPAT_MACHINE} 169MACHINE_ARCH= ${LIBCOMPAT_MACHINE_ARCH} 170.endif 171 172.endif 173