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.if ${WANT_COMPILER_TYPE} == gcc || \ 104 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 105# GCC requires -isystem when using a cross-compiler and --sysroot. Note that 106# Makefile.inc1 only applies this with an external compiler but libcompat 107# always does since even in-tree GCC 4.2 needs this to override the built-in 108# sysroot path which --sysroot does not actually do for headers. 109LIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include 110# Force using libc++ for external GCC. 111.if defined(X_COMPILER_TYPE) && \ 112 ${X_COMPILER_TYPE} == gcc && ${X_COMPILER_VERSION} >= 40800 && \ 113 (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no") 114LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \ 115 -nostdinc++ 116.endif 117.endif 118 119# Yes, the flags are redundant. 120LIBCOMPATWMAKEENV+= \ 121 INSTALL="sh ${.CURDIR}/tools/install.sh" \ 122 PATH=${TMPPATH} \ 123 SYSROOT=${LIBCOMPATTMP} \ 124 LIBDIR=/usr/lib${libcompat} \ 125 SHLIBDIR=/usr/lib${libcompat} \ 126 DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}" 127.if ${MK_META_MODE} != "no" 128# Don't rebuild build-tools targets during normal build. 129LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA 130.endif 131LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ 132 CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \ 133 CPP="${XCPP} ${LIBCOMPATCFLAGS}" \ 134 DESTDIR=${LIBCOMPATTMP} \ 135 -DNO_CPU_CFLAGS \ 136 MK_CTF=no \ 137 -DNO_LINT \ 138 MK_TESTS=no 139LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \ 140 OBJTOP=${LIBCOMPAT_OBJTOP} \ 141 OBJROOT='$${OBJTOP}/' \ 142 MAKEOBJDIRPREFIX= \ 143 MK_MAN=no MK_HTML=no 144LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \ 145 MK_TOOLCHAIN=no ${IMAKE_INSTALL} \ 146 -DLIBRARIES_ONLY 147 148_LC_LIBDIRS.yes= lib gnu/lib 149_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib 150_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib 151_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib 152 153_LC_INCDIRS= \ 154 include \ 155 lib/ncurses/ncursesw \ 156 ${_LC_LIBDIRS.yes} 157 158# Shared logic 159build${libcompat}: .PHONY 160 @echo 161 @echo "--------------------------------------------------------------" 162 @echo ">>> stage 5.1: building lib${libcompat} shim libraries" 163 @echo "--------------------------------------------------------------" 164.if !defined(NO_CLEAN) 165 rm -rf ${LIBCOMPATTMP} 166.else 167.if exists(${LIBCOMPATTMP}) 168 ${_+_}cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ 169 DESTDIR=${LIBCOMPATTMP} \ 170 delete-old delete-old-libs >/dev/null 171.endif 172.endif # !defined(NO_CLEAN) 173 174 mkdir -p ${LIBCOMPATTMP}/usr/include 175 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 176 -p ${LIBCOMPATTMP}/usr >/dev/null 177 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 178 -p ${LIBCOMPATTMP}/usr/include >/dev/null 179 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 180 -p ${LIBCOMPATTMP}/usr >/dev/null 181.if ${MK_DEBUG_FILES} != "no" 182 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 183 -p ${LIBCOMPATTMP}/usr/lib >/dev/null 184 mtree -deU -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 lib/libmagic 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 MK_WARNS=no MK_CTF=no \ 204 build-tools 205.endfor 206 ${_+_}cd ${.CURDIR}; \ 207 ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries 208.if ${libcompat} == "32" 209.for _t in ${_obj} all 210.if !defined(NO_RTLD) 211 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ 212 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} 213.endif 214 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ 215 DIRPRFX=usr.bin/ldd ${_t} 216.endfor 217.endif 218 219distribute${libcompat} install${libcompat}: .PHONY 220.for _dir in ${_LC_LIBDIRS.yes} 221 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} 222.endfor 223.if ${libcompat} == "32" 224.if !defined(NO_RTLD) 225 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ 226 PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} 227.endif 228 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ 229 ${.TARGET:S/32$//} 230.endif 231 232.endif 233