3 .if !targets(__<${_this:T}>__)
6 .if defined(_LIBCOMPAT)
7 COMPAT_ARCH?= ${TARGET_ARCH}
8 COMPAT_CPUTYPE?= ${CPUTYPE_${_LIBCOMPAT}}
9 .if (defined(WANT_COMPILER_TYPE) && ${WANT_COMPILER_TYPE} == gcc) || \
10 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
11 COMPAT_COMPILER_TYPE= gcc
13 COMPAT_COMPILER_TYPE= clang
16 COMPAT_ARCH= ${MACHINE_ARCH}
17 COMPAT_CPUTYPE= ${CPUTYPE}
18 .include <bsd.compiler.mk>
19 COMPAT_COMPILER_TYPE=${COMPILER_TYPE}
22 # -------------------------------------------------------------------
24 .if ${COMPAT_ARCH} == "amd64"
26 .if empty(COMPAT_CPUTYPE)
27 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
29 LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE}
31 .if ${COMPAT_COMPILER_TYPE} == gcc
33 LIB32CPUFLAGS+= -target x86_64-unknown-freebsd13.1
37 LIB32_MACHINE_ARCH= i386
38 LIB32WMAKEENV= MACHINE_CPU="i686 mmx sse sse2"
41 LD="${XLD} -m elf_i386_fbsd"
43 .elif ${COMPAT_ARCH} == "powerpc64"
45 .if empty(COMPAT_CPUTYPE)
46 LIB32CPUFLAGS= -mcpu=powerpc
48 LIB32CPUFLAGS= -mcpu=${COMPAT_CPUTYPE}
51 .if ${COMPAT_COMPILER_TYPE} == "gcc"
54 LIB32CPUFLAGS+= -target powerpc-unknown-freebsd13.1
57 LIB32_MACHINE= powerpc
58 LIB32_MACHINE_ARCH= powerpc
60 LD="${XLD} -m elf32ppc_fbsd"
62 .elif ${COMPAT_ARCH:Mmips64*} != ""
64 .if ${COMPAT_COMPILER_TYPE} == gcc
65 .if empty(COMPAT_CPUTYPE)
66 LIB32CPUFLAGS= -march=mips3
68 LIB32CPUFLAGS= -march=${COMPAT_CPUTYPE}
71 .if ${COMPAT_ARCH:Mmips64el*} != ""
72 LIB32CPUFLAGS= -target mipsel-unknown-freebsd13.1
74 LIB32CPUFLAGS= -target mips-unknown-freebsd13.1
77 LIB32CPUFLAGS+= -mabi=32
79 LIB32_MACHINE_ARCH:= ${COMPAT_ARCH:S/64//}
80 .if ${COMPAT_ARCH:Mmips64el*} != ""
81 _EMULATION= elf32ltsmip_fbsd
83 _EMULATION= elf32btsmip_fbsd
85 LIB32WMAKEFLAGS= LD="${XLD} -m ${_EMULATION}"
86 LIB32LDFLAGS= -Wl,-m${_EMULATION}
89 LIB32WMAKEFLAGS+= NM="${XNM}"
90 LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}"
92 LIB32CFLAGS= -DCOMPAT_32BIT
93 LIB32DTRACE= ${DTRACE} -32
94 LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
96 # -------------------------------------------------------------------
98 .if ${COMPAT_ARCH:Marmv[67]*} != ""
100 LIBSOFTCFLAGS= -DCOMPAT_SOFTFP
101 LIBSOFTCPUFLAGS= -mfloat-abi=softfp
103 LIBSOFT_MACHINE_ARCH= ${COMPAT_ARCH}
104 LIBSOFTWMAKEENV= CPUTYPE=soft
105 LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP
108 # -------------------------------------------------------------------
109 # In the program linking case, select LIBCOMPAT
110 .if defined(NEED_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"
118 .error Both WANT_COMPAT and NEED_COMPAT defined
120 WANT_COMPAT:= ${NEED_COMPAT}
123 .if defined(HAS_COMPAT) && defined(WANT_COMPAT)
124 .if ${WANT_COMPAT} == "any"
125 _LIBCOMPAT:= ${HAS_COMPAT:[1]}
127 _LIBCOMPAT:= ${WANT_COMPAT}
131 # -------------------------------------------------------------------
132 # Generic code for each type.
133 # Set defaults based on type.
134 libcompat= ${_LIBCOMPAT:tl}
135 _LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS LDFLAGS \
136 _MACHINE _MACHINE_ARCH WMAKEENV WMAKEFLAGS WMAKE
137 .for _var in ${_LIBCOMPAT_MAKEVARS}
138 .if !empty(LIB${_LIBCOMPAT}${_var})
139 LIBCOMPAT${_var}?= ${LIB${_LIBCOMPAT}${_var}}
144 LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat}
145 LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp
147 LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \
148 --sysroot=${LIBCOMPATTMP} \
151 LIBCOMPATLDFLAGS+= -L${LIBCOMPATTMP}/usr/lib${libcompat}
153 LIBCOMPATWMAKEENV+= MACHINE=${LIBCOMPAT_MACHINE}
154 LIBCOMPATWMAKEENV+= MACHINE_ARCH=${LIBCOMPAT_MACHINE_ARCH}
156 # -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for
158 LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat}
160 .if defined(WANT_COMPAT)
161 LIBDIR_BASE:= /usr/lib${libcompat}
162 _LIB_OBJTOP= ${LIBCOMPAT_OBJTOP}
163 LIBDESTDIR:= ${LIBCOMPATTMP}
164 CFLAGS+= ${LIBCOMPATCFLAGS}
165 LDFLAGS+= ${CFLAGS} ${LIBCOMPATLDFLAGS}
166 MACHINE= ${LIBCOMPAT_MACHINE}
167 MACHINE_ARCH= ${LIBCOMPAT_MACHINE_ARCH}