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