1# $FreeBSD$ 2 3.if !targets(__<${_this:T}>__) 4__<${_this:T}>__: 5 6# Makefile for the compatibility libraries. 7# - 32-bit compat libraries on MIPS, PowerPC, and AMD64. 8 9# ------------------------------------------------------------------- 10# 32 bit world 11.if ${TARGET_ARCH} == "amd64" 12.if empty(TARGET_CPUTYPE) 13LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 14.else 15LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} 16.endif 17.if ${WANT_COMPILER_TYPE} == gcc || \ 18 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 19.else 20LIB32CPUFLAGS+= -target x86_64-unknown-freebsd13.0 21.endif 22LIB32CPUFLAGS+= -m32 23LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ 24 MACHINE_CPU="i686 mmx sse sse2" 25LIB32WMAKEFLAGS= \ 26 AS="${XAS} --32" \ 27 LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" \ 28 OBJCOPY="${XOBJCOPY}" 29 30.elif ${TARGET_ARCH} == "powerpc64" 31.if empty(TARGET_CPUTYPE) 32LIB32CPUFLAGS= -mcpu=powerpc 33.else 34LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} 35.endif 36LIB32CPUFLAGS+= -m32 37LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc 38LIB32WMAKEFLAGS= \ 39 LD="${XLD} -m elf32ppc_fbsd" \ 40 OBJCOPY="${XOBJCOPY}" 41 42.elif ${TARGET_ARCH:Mmips64*} != "" 43.if ${WANT_COMPILER_TYPE} == gcc || \ 44 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 45.if empty(TARGET_CPUTYPE) 46LIB32CPUFLAGS= -march=mips3 47.else 48LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} 49.endif 50.else 51.if ${TARGET_ARCH:Mmips64el*} != "" 52LIB32CPUFLAGS= -target mipsel-unknown-freebsd13.0 53.else 54LIB32CPUFLAGS= -target mips-unknown-freebsd13.0 55.endif 56.endif 57LIB32CPUFLAGS+= -mabi=32 58LIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips 59.if ${TARGET_ARCH:Mmips64el*} != "" 60LIB32WMAKEFLAGS= LD="${XLD} -m elf32ltsmip_fbsd" 61.else 62LIB32WMAKEFLAGS= LD="${XLD} -m elf32btsmip_fbsd" 63.endif 64LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}" 65.endif 66 67LIB32WMAKEFLAGS+= NM="${XNM}" 68 69 70LIB32CFLAGS= -DCOMPAT_32BIT 71LIB32DTRACE= ${DTRACE} -32 72LIB32WMAKEFLAGS+= -DCOMPAT_32BIT 73 74# ------------------------------------------------------------------- 75# soft-fp world 76.if ${TARGET_ARCH:Marmv[67]*} != "" 77LIBSOFTCFLAGS= -DCOMPAT_SOFTFP 78LIBSOFTCPUFLAGS= -mfloat-abi=softfp 79LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${TARGET_ARCH} 80LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP 81.endif 82 83# ------------------------------------------------------------------- 84# Generic code for each type. 85# Set defaults based on type. 86libcompat= ${LIBCOMPAT:tl} 87_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \ 88 WMAKEFLAGS WMAKE 89.for _var in ${_LIBCOMPAT_MAKEVARS} 90.if !empty(LIB${LIBCOMPAT}${_var}) 91LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}} 92.endif 93.endfor 94 95# Shared flags 96LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat} 97LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp 98 99LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ 100 -L${LIBCOMPATTMP}/usr/lib${libcompat} \ 101 --sysroot=${LIBCOMPATTMP} \ 102 ${BFLAGS} 103 104# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for 105# Clang/GCC. 106LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat} 107 108# Yes, the flags are redundant. 109LIBCOMPATWMAKEENV+= \ 110 INSTALL="sh ${.CURDIR}/tools/install.sh" \ 111 PATH=${TMPPATH} \ 112 SYSROOT=${LIBCOMPATTMP} \ 113 LIBDIR=/usr/lib${libcompat} \ 114 SHLIBDIR=/usr/lib${libcompat} \ 115 DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}" 116.if ${MK_META_MODE} != "no" 117# Don't rebuild build-tools targets during normal build. 118LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA 119.endif 120LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ 121 CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \ 122 CPP="${XCPP} ${LIBCOMPATCFLAGS}" \ 123 DESTDIR=${LIBCOMPATTMP} \ 124 -DNO_CPU_CFLAGS \ 125 MK_CTF=no \ 126 -DNO_LINT \ 127 MK_TESTS=no 128LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \ 129 OBJTOP=${LIBCOMPAT_OBJTOP} \ 130 OBJROOT='$${OBJTOP}/' \ 131 MAKEOBJDIRPREFIX= \ 132 MK_MAN=no MK_HTML=no 133LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \ 134 ${IMAKE_INSTALL} \ 135 -DLIBRARIES_ONLY 136 137_LC_LIBDIRS.yes= lib 138_LC_LIBDIRS.yes+= gnu/lib 139_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib 140_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib 141_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib 142 143_LC_INCDIRS= \ 144 include \ 145 lib/ncurses/ncursesw \ 146 ${_LC_LIBDIRS.yes} 147 148.if ${MK_FILE} != "no" 149_libmagic= lib/libmagic 150.endif 151.if ${MK_PMC} != "no" && ${TARGET_ARCH} == "amd64" 152_jevents= lib/libpmc/pmu-events 153.endif 154 155 156# Shared logic 157build${libcompat}: .PHONY 158 @echo 159 @echo "--------------------------------------------------------------" 160 @echo ">>> stage 5.1: building lib${libcompat} shim libraries" 161 @echo "--------------------------------------------------------------" 162.if !defined(NO_CLEAN) 163 rm -rf ${LIBCOMPATTMP} 164.else 165 ${_+_}@if [ -e "${LIBCOMPATTMP}" ]; then \ 166 echo ">>> Deleting stale files in build${libcompat} tree..."; \ 167 cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ 168 DESTDIR=${LIBCOMPATTMP} \ 169 delete-old delete-old-libs >/dev/null; \ 170 fi 171.endif # !defined(NO_CLEAN) 172 173 mkdir -p ${LIBCOMPATTMP}/usr/include 174 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 175 -p ${LIBCOMPATTMP}/usr >/dev/null 176 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 177 -p ${LIBCOMPATTMP}/usr/include >/dev/null 178 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 179 -p ${LIBCOMPATTMP}/usr >/dev/null 180.if ${MK_DEBUG_FILES} != "no" 181 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 182 -p ${LIBCOMPATTMP}/usr/lib >/dev/null 183 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 184 -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null 185.endif 186 mkdir -p ${WORLDTMP} 187 ln -sf ${.CURDIR}/sys ${WORLDTMP} 188.for _t in ${_obj} includes 189.for _dir in ${_LC_INCDIRS} 190 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \ 191 DIRPRFX=${_dir}/ ${_t} 192.endfor 193.endfor 194.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw ${_libmagic} ${_jevents} 195.for _t in ${_obj} build-tools 196 ${_+_}cd ${.CURDIR}/${_dir}; \ 197 WORLDTMP=${WORLDTMP} \ 198 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ 199 ${MAKE} SSP_CFLAGS= DESTDIR= \ 200 OBJTOP=${LIBCOMPAT_OBJTOP} \ 201 OBJROOT='$${OBJTOP}/' \ 202 MAKEOBJDIRPREFIX= \ 203 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \ 204 MK_CTF=no MK_RETPOLINE=no MK_WARNS=no \ 205 ${_t} 206.endfor 207.endfor 208 ${_+_}cd ${.CURDIR}; \ 209 ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries 210.if ${libcompat} == "32" 211.for _t in ${_obj} all 212.if !defined(NO_RTLD) 213 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ 214 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} 215.endif 216 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ 217 DIRPRFX=usr.bin/ldd ${_t} 218.endfor 219.endif 220 221distribute${libcompat} install${libcompat}: .PHONY 222.for _dir in ${_LC_LIBDIRS.yes} 223 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} 224.endfor 225.if ${libcompat} == "32" 226.if !defined(NO_RTLD) 227 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ 228 PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} 229.endif 230 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ 231 ${.TARGET:S/32$//} 232.endif 233 234.endif 235