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 empty(TARGET_CPUTYPE) 39LIB32CPUFLAGS= -march=mips3 40.else 41LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} 42.endif 43LIB32CPUFLAGS+= -mabi=32 44LIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips 45.if ${TARGET_ARCH:Mmips64el*} != "" 46LIB32WMAKEFLAGS= LD="${XLD} -m elf32ltsmip_fbsd" 47.else 48LIB32WMAKEFLAGS= LD="${XLD} -m elf32btsmip_fbsd" 49.endif 50LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}" 51.endif 52 53LIB32WMAKEFLAGS+= NM="${XNM}" 54 55 56LIB32CFLAGS= -DCOMPAT_32BIT 57LIB32DTRACE= ${DTRACE} -32 58LIB32WMAKEFLAGS+= -DCOMPAT_32BIT 59 60# ------------------------------------------------------------------- 61# soft-fp world 62.if ${TARGET_ARCH} == "armv6" 63LIBSOFTCFLAGS= -DCOMPAT_SOFTFP 64LIBSOFTCPUFLAGS= -mfloat-abi=softfp 65LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=armv6 66LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP 67.endif 68 69# ------------------------------------------------------------------- 70# Generic code for each type. 71# Set defaults based on type. 72libcompat= ${LIBCOMPAT:tl} 73_LIBCOMPAT_MAKEVARS= _OBJTREE TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \ 74 WMAKEFLAGS WMAKE 75.for _var in ${_LIBCOMPAT_MAKEVARS} 76.if !empty(LIB${LIBCOMPAT}${_var}) 77LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}} 78.endif 79.endfor 80 81# Shared flags 82LIBCOMPAT_OBJTREE?= ${OBJTREE}${.CURDIR}/world${libcompat} 83LIBCOMPATTMP?= ${OBJTREE}${.CURDIR}/lib${libcompat} 84 85LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ 86 -L${LIBCOMPATTMP}/usr/lib${libcompat} \ 87 --sysroot=${LIBCOMPATTMP} \ 88 ${BFLAGS} 89 90# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for 91# Clang/GCC. 92LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat} 93 94.if ${WANT_COMPILER_TYPE} == gcc || \ 95 (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 96# GCC requires -isystem when using a cross-compiler and --sysroot. Note that 97# Makefile.inc1 only applies this with an external compiler but libcompat 98# always does since even in-tree GCC 4.2 needs this to override the built-in 99# sysroot path which --sysroot does not actually do for headers. 100LIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include 101# Force using libc++ for external GCC. 102# XXX: This should be checking MK_GNUCXX == no 103.if ${X_COMPILER_VERSION} >= 40800 && \ 104 (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no") 105LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \ 106 -nostdinc++ 107.endif 108.endif 109 110# Yes, the flags are redundant. 111LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \ 112 INSTALL="sh ${.CURDIR}/tools/install.sh" \ 113 PATH=${TMPPATH} \ 114 SYSROOT=${LIBCOMPATTMP} \ 115 LIBDIR=/usr/lib${libcompat} \ 116 SHLIBDIR=/usr/lib${libcompat} \ 117 DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}" 118.if ${MK_META_MODE} != "no" 119# Don't rebuild build-tools targets during normal build. 120LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA 121.endif 122LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ 123 CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \ 124 CPP="${XCPP} ${LIBCOMPATCFLAGS}" \ 125 DESTDIR=${LIBCOMPATTMP} \ 126 -DNO_CPU_CFLAGS \ 127 MK_CTF=no \ 128 -DNO_LINT \ 129 MK_TESTS=no 130LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \ 131 MK_MAN=no MK_HTML=no 132LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \ 133 MK_TOOLCHAIN=no ${IMAKE_INSTALL} \ 134 -DLIBRARIES_ONLY 135 136_LC_LIBDIRS.yes= lib gnu/lib 137_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib 138_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib 139_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib 140 141_LC_INCDIRS= \ 142 include \ 143 lib/ncurses/ncursesw \ 144 ${_LC_LIBDIRS.yes} 145 146# Shared logic 147build${libcompat}: .PHONY 148 @echo 149 @echo "--------------------------------------------------------------" 150 @echo ">>> stage 5.1: building lib${libcompat} shim libraries" 151 @echo "--------------------------------------------------------------" 152 mkdir -p ${LIBCOMPATTMP}/usr/include 153 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 154 -p ${LIBCOMPATTMP}/usr >/dev/null 155 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 156 -p ${LIBCOMPATTMP}/usr/include >/dev/null 157 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 158 -p ${LIBCOMPATTMP}/usr >/dev/null 159.if ${MK_DEBUG_FILES} != "no" 160 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 161 -p ${LIBCOMPATTMP}/usr/lib >/dev/null 162 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 163 -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null 164.endif 165 mkdir -p ${WORLDTMP} 166 ln -sf ${.CURDIR}/sys ${WORLDTMP} 167.for _t in ${_obj} includes 168.for _dir in ${_LC_INCDIRS} 169 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \ 170 DIRPRFX=${_dir}/ ${_t} 171.endfor 172.endfor 173.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic 174 ${_+_}cd ${.CURDIR}/${_dir}; \ 175 WORLDTMP=${WORLDTMP} \ 176 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ 177 MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \ 178 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ 179 build-tools 180.endfor 181 ${_+_}cd ${.CURDIR}; \ 182 ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries 183.if ${libcompat} == "32" 184.for _t in ${_obj} all 185 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ 186 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} 187 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ 188 DIRPRFX=usr.bin/ldd ${_t} 189.endfor 190.endif 191 192distribute${libcompat} install${libcompat}: .PHONY 193.for _dir in ${_LC_LIBDIRS.yes} 194 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} 195.endfor 196.if ${libcompat} == "32" 197 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ 198 PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} 199 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ 200 ${.TARGET:S/32$//} 201.endif 202 203.endif 204