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.yes+= usr.bin/lex/lib 140_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib 141_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib 142_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib 143 144_LC_INCDIRS= \ 145 include \ 146 lib/ncurses/ncursesw \ 147 ${_LC_LIBDIRS.yes} 148 149.if ${MK_FILE} != "no" 150_libmagic= lib/libmagic 151.endif 152.if ${MK_PMC} != "no" && ${TARGET_ARCH} == "amd64" 153_jevents= lib/libpmc/pmu-events 154.endif 155 156 157# Shared logic 158build${libcompat}: .PHONY 159 @echo 160 @echo "--------------------------------------------------------------" 161 @echo ">>> stage 5.1: building lib${libcompat} shim libraries" 162 @echo "--------------------------------------------------------------" 163.if !defined(NO_CLEAN) 164 rm -rf ${LIBCOMPATTMP} 165.else 166 ${_+_}@if [ -e "${LIBCOMPATTMP}" ]; then \ 167 echo ">>> Deleting stale files in build${libcompat} tree..."; \ 168 cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ 169 DESTDIR=${LIBCOMPATTMP} \ 170 delete-old delete-old-libs >/dev/null; \ 171 fi 172.endif # !defined(NO_CLEAN) 173 174 mkdir -p ${LIBCOMPATTMP}/usr/include 175 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 176 -p ${LIBCOMPATTMP}/usr >/dev/null 177 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 178 -p ${LIBCOMPATTMP}/usr/include >/dev/null 179 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 180 -p ${LIBCOMPATTMP}/usr >/dev/null 181.if ${MK_DEBUG_FILES} != "no" 182 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 183 -p ${LIBCOMPATTMP}/usr/lib >/dev/null 184 ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 185 -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null 186.endif 187 mkdir -p ${WORLDTMP} 188 ln -sf ${.CURDIR}/sys ${WORLDTMP} 189.for _t in ${_obj} includes 190.for _dir in ${_LC_INCDIRS} 191 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \ 192 DIRPRFX=${_dir}/ ${_t} 193.endfor 194.endfor 195.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw ${_libmagic} ${_jevents} 196.for _t in ${_obj} build-tools 197 ${_+_}cd ${.CURDIR}/${_dir}; \ 198 WORLDTMP=${WORLDTMP} \ 199 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ 200 ${MAKE} SSP_CFLAGS= DESTDIR= \ 201 OBJTOP=${LIBCOMPAT_OBJTOP} \ 202 OBJROOT='$${OBJTOP}/' \ 203 MAKEOBJDIRPREFIX= \ 204 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \ 205 MK_CTF=no MK_RETPOLINE=no MK_WARNS=no \ 206 ${_t} 207.endfor 208.endfor 209 ${_+_}cd ${.CURDIR}; \ 210 ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries 211.if ${libcompat} == "32" 212.for _t in ${_obj} all 213.if !defined(NO_RTLD) 214 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ 215 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} 216.endif 217 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ 218 DIRPRFX=usr.bin/ldd ${_t} 219.endfor 220.endif 221 222distribute${libcompat} install${libcompat}: .PHONY 223.for _dir in ${_LC_LIBDIRS.yes} 224 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} 225.endfor 226.if ${libcompat} == "32" 227.if !defined(NO_RTLD) 228 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ 229 PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} 230.endif 231 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ 232 ${.TARGET:S/32$//} 233.endif 234 235.endif 236