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-freebsd${OS_REVISION} 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-freebsd${OS_REVISION} 55.endif 56 57LIB32_MACHINE= powerpc 58LIB32_MACHINE_ARCH= powerpc 59LIB32WMAKEFLAGS= \ 60 LD="${XLD} -m elf32ppc_fbsd" 61.endif 62 63LIB32WMAKEFLAGS+= NM="${XNM}" 64LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}" 65 66LIB32CFLAGS= -DCOMPAT_32BIT 67LIB32DTRACE= ${DTRACE} -32 68LIB32WMAKEFLAGS+= -DCOMPAT_32BIT 69 70# ------------------------------------------------------------------- 71# In the program linking case, select LIBCOMPAT 72.if defined(NEED_COMPAT) 73.ifndef HAS_COMPAT 74.warning NEED_COMPAT defined, but no LIBCOMPAT is available (COMPAT_ARCH == ${COMPAT_ARCH}) 75.elif !${HAS_COMPAT:M${NEED_COMPAT}} && ${NEED_COMPAT} != "any" 76.error NEED_COMPAT (${NEED_COMPAT}) defined, but not in HAS_COMPAT (${HAS_COMPAT}) 77.elif ${NEED_COMPAT} == "any" 78.endif 79.ifdef WANT_COMPAT 80.error Both WANT_COMPAT and NEED_COMPAT defined 81.endif 82WANT_COMPAT:= ${NEED_COMPAT} 83.endif 84 85.if defined(HAS_COMPAT) && defined(WANT_COMPAT) 86.if ${WANT_COMPAT} == "any" 87_LIBCOMPAT:= ${HAS_COMPAT:[1]} 88.else 89_LIBCOMPAT:= ${WANT_COMPAT} 90.endif 91.endif 92 93# ------------------------------------------------------------------- 94# Generic code for each type. 95# Set defaults based on type. 96libcompat= ${_LIBCOMPAT:tl} 97_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS LDFLAGS \ 98 _MACHINE _MACHINE_ARCH \ 99 WMAKEENV WMAKEFLAGS WMAKE WORLDTMP 100.for _var in ${_LIBCOMPAT_MAKEVARS} 101.if !empty(LIB${_LIBCOMPAT}${_var}) 102LIBCOMPAT${_var}?= ${LIB${_LIBCOMPAT}${_var}} 103.endif 104.endfor 105 106WORLDTMP?= ${SYSROOT} 107 108# Shared flags 109LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat} 110 111LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ 112 --sysroot=${WORLDTMP} \ 113 ${BFLAGS} 114 115LIBCOMPATLDFLAGS+= -L${WORLDTMP}/usr/lib${libcompat} 116 117LIBCOMPATWMAKEENV+= MACHINE=${LIBCOMPAT_MACHINE} 118LIBCOMPATWMAKEENV+= MACHINE_ARCH=${LIBCOMPAT_MACHINE_ARCH} 119 120# -B is needed to find /usr/lib32/crti.o for gcc. 121LIBCOMPATCFLAGS+= -B${WORLDTMP}/usr/lib${libcompat} 122 123.if defined(WANT_COMPAT) 124LIBDIR_BASE:= /usr/lib${libcompat} 125LIBDATADIR:= /usr/lib${libcompat} 126_LIB_OBJTOP= ${LIBCOMPAT_OBJTOP} 127CFLAGS+= ${LIBCOMPATCFLAGS} 128LDFLAGS+= ${CFLAGS} ${LIBCOMPATLDFLAGS} 129MACHINE= ${LIBCOMPAT_MACHINE} 130MACHINE_ARCH= ${LIBCOMPAT_MACHINE_ARCH} 131.endif 132 133.endif 134