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 LIBDIR=/usr/lib${libcompat} \ 115 SHLIBDIR=/usr/lib${libcompat} \ 116 DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}" 117.if ${MK_META_MODE} != "no" 118# Don't rebuild build-tools targets during normal build. 119LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA_CMP 120.endif 121LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ 122 CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \ 123 CPP="${XCPP} ${LIBCOMPATCFLAGS}" \ 124 DESTDIR=${LIBCOMPATTMP} \ 125 -DNO_CPU_CFLAGS \ 126 MK_CTF=no \ 127 -DNO_LINT \ 128 MK_TESTS=no 129LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \ 130 MK_MAN=no MK_HTML=no 131LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \ 132 MK_TOOLCHAIN=no ${IMAKE_INSTALL} \ 133 -DLIBRARIES_ONLY 134 135_LC_LIBDIRS.yes= lib gnu/lib 136_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib 137_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib 138_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib 139 140_LC_INCDIRS= \ 141 include \ 142 lib/ncurses/ncursesw \ 143 ${_LC_LIBDIRS.yes} 144 145# Shared logic 146build${libcompat}: .PHONY 147 @echo 148 @echo "--------------------------------------------------------------" 149 @echo ">>> stage 5.1: building lib${libcompat} shim libraries" 150 @echo "--------------------------------------------------------------" 151 mkdir -p ${LIBCOMPATTMP}/usr/include 152 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 153 -p ${LIBCOMPATTMP}/usr >/dev/null 154 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 155 -p ${LIBCOMPATTMP}/usr/include >/dev/null 156 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 157 -p ${LIBCOMPATTMP}/usr >/dev/null 158.if ${MK_DEBUG_FILES} != "no" 159 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 160 -p ${LIBCOMPATTMP}/usr/lib >/dev/null 161 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 162 -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null 163.endif 164 mkdir -p ${WORLDTMP} 165 ln -sf ${.CURDIR}/sys ${WORLDTMP} 166.for _t in obj includes 167.for _dir in ${_LC_INCDIRS} 168 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \ 169 DIRPRFX=${_dir}/ ${_t} 170.endfor 171.endfor 172.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic 173 ${_+_}cd ${.CURDIR}/${_dir}; \ 174 WORLDTMP=${WORLDTMP} \ 175 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ 176 MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \ 177 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ 178 build-tools 179.endfor 180 ${_+_}cd ${.CURDIR}; \ 181 ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries 182.if ${libcompat} == "32" 183.for _t in obj all 184 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ 185 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} 186 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ 187 DIRPRFX=usr.bin/ldd ${_t} 188.endfor 189.endif 190 191distribute${libcompat} install${libcompat}: .PHONY 192.for _dir in ${_LC_LIBDIRS.yes} 193 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} 194.endfor 195.if ${libcompat} == "32" 196 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ 197 PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} 198 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ 199 ${.TARGET:S/32$//} 200.endif 201 202.endif 203