1dba75e9fSBryan Drewery# $FreeBSD$ 2dba75e9fSBryan Drewery 3dba75e9fSBryan Drewery.if !targets(__<${_this:T}>__) 4dba75e9fSBryan Drewery__<${_this:T}>__: 5dba75e9fSBryan Drewery 6dba75e9fSBryan Drewery# Makefile for the compatibility libraries. 7dba75e9fSBryan Drewery# - 32-bit compat libraries on PowerPC and AMD64. 8dba75e9fSBryan Drewery# could also be for mips, but that doesn't work today. 9dba75e9fSBryan Drewery 10dba75e9fSBryan Drewery# ------------------------------------------------------------------- 11dba75e9fSBryan Drewery# 32 bit world 12dba75e9fSBryan Drewery.if ${TARGET_ARCH} == "amd64" 13dba75e9fSBryan Drewery.if empty(TARGET_CPUTYPE) 14dba75e9fSBryan DreweryLIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 15dba75e9fSBryan Drewery.else 16dba75e9fSBryan DreweryLIB32CPUFLAGS= -march=${TARGET_CPUTYPE} 17dba75e9fSBryan Drewery.endif 18dba75e9fSBryan DreweryLIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ 19dba75e9fSBryan Drewery MACHINE_CPU="i686 mmx sse sse2" 20f661dbeeSBryan DreweryLIB32WMAKEFLAGS= \ 21dba75e9fSBryan Drewery AS="${XAS} --32" \ 22dfaedbb2SEd Maste LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" \ 23dba75e9fSBryan Drewery OBJCOPY="${XOBJCOPY}" 24dba75e9fSBryan Drewery 25dba75e9fSBryan Drewery.elif ${TARGET_ARCH} == "powerpc64" 26dba75e9fSBryan Drewery.if empty(TARGET_CPUTYPE) 27dba75e9fSBryan DreweryLIB32CPUFLAGS= -mcpu=powerpc 28dba75e9fSBryan Drewery.else 29dba75e9fSBryan DreweryLIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} 30dba75e9fSBryan Drewery.endif 31dba75e9fSBryan DreweryLIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc 32f661dbeeSBryan DreweryLIB32WMAKEFLAGS= \ 33dba75e9fSBryan Drewery LD="${XLD} -m elf32ppc_fbsd" \ 34dba75e9fSBryan Drewery OBJCOPY="${XOBJCOPY}" 35dba75e9fSBryan Drewery.endif 36dba75e9fSBryan Drewery 37dba75e9fSBryan Drewery 38dba75e9fSBryan DreweryLIB32CFLAGS= -m32 -DCOMPAT_32BIT 39dba75e9fSBryan DreweryLIB32DTRACE= ${DTRACE} -32 40dba75e9fSBryan DreweryLIB32WMAKEFLAGS+= -DCOMPAT_32BIT 41dba75e9fSBryan Drewery 42dba75e9fSBryan Drewery# ------------------------------------------------------------------- 43bb52d711SWarner Losh# soft-fp world 44bb52d711SWarner Losh.if ${TARGET_ARCH} == "armv6" 45bb52d711SWarner LoshLIBSOFTCFLAGS= -DCOMPAT_SOFTFP 46bb52d711SWarner LoshLIBSOFTCPUFLAGS= -mfloat-abi=softfp 47bb52d711SWarner LoshLIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=armv6 48bb52d711SWarner LoshLIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP 49bb52d711SWarner Losh.endif 50bb52d711SWarner Losh 51bb52d711SWarner Losh# ------------------------------------------------------------------- 52dba75e9fSBryan Drewery# Generic code for each type. 53dba75e9fSBryan Drewery# Set defaults based on type. 54dba75e9fSBryan Drewerylibcompat= ${LIBCOMPAT:tl} 5517e3ebb1SBryan Drewery_LIBCOMPAT_MAKEVARS= _OBJTREE TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \ 5617e3ebb1SBryan Drewery WMAKEFLAGS WMAKE 57dba75e9fSBryan Drewery.for _var in ${_LIBCOMPAT_MAKEVARS} 58dba75e9fSBryan Drewery.if !empty(LIB${LIBCOMPAT}${_var}) 59dba75e9fSBryan DreweryLIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}} 60dba75e9fSBryan Drewery.endif 61dba75e9fSBryan Drewery.endfor 62dba75e9fSBryan Drewery 63dba75e9fSBryan Drewery# Shared flags 64dba75e9fSBryan DreweryLIBCOMPAT_OBJTREE?= ${OBJTREE}${.CURDIR}/world${libcompat} 65dba75e9fSBryan DreweryLIBCOMPATTMP?= ${OBJTREE}${.CURDIR}/lib${libcompat} 66dba75e9fSBryan Drewery 67dba75e9fSBryan DreweryLIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ 68dba75e9fSBryan Drewery -L${LIBCOMPATTMP}/usr/lib${libcompat} \ 6917e3ebb1SBryan Drewery --sysroot=${LIBCOMPATTMP} \ 7017e3ebb1SBryan Drewery ${BFLAGS} 711b337a34SBryan Drewery 721b337a34SBryan Drewery# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for 731b337a34SBryan Drewery# Clang/GCC. 741b337a34SBryan DreweryLIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat} 7507394091SBryan Drewery 764d611b2bSBryan Drewery.if ${WANT_COMPILER_TYPE} == gcc || \ 774d611b2bSBryan Drewery (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 7807394091SBryan Drewery# GCC requires -isystem when using a cross-compiler and --sysroot. Note that 7907394091SBryan Drewery# Makefile.inc1 only applies this with an external compiler but libcompat 8007394091SBryan Drewery# always does since even in-tree GCC 4.2 needs this to override the built-in 8107394091SBryan Drewery# sysroot path which --sysroot does not actually do for headers. 82f661dbeeSBryan DreweryLIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include 83f661dbeeSBryan Drewery# Force using libc++ for external GCC. 8407394091SBryan Drewery# XXX: This should be checking MK_GNUCXX == no 8573371266SBryan Drewery.if ${X_COMPILER_VERSION} >= 40800 && \ 8673371266SBryan Drewery (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no") 87f661dbeeSBryan DreweryLIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \ 88*646a9763SBaptiste Daroussin -nostdinc++ 89f661dbeeSBryan Drewery.endif 9007394091SBryan Drewery.endif 9117e3ebb1SBryan Drewery 92dba75e9fSBryan Drewery# Yes, the flags are redundant. 93dba75e9fSBryan DreweryLIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \ 94dba75e9fSBryan Drewery INSTALL="sh ${.CURDIR}/tools/install.sh" \ 95dba75e9fSBryan Drewery PATH=${TMPPATH} \ 96dba75e9fSBryan Drewery LIBDIR=/usr/lib${libcompat} \ 97dba75e9fSBryan Drewery SHLIBDIR=/usr/lib${libcompat} \ 98dba75e9fSBryan Drewery DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}" 99d1dd034dSBryan Drewery.if ${MK_META_MODE} != "no" 100d1dd034dSBryan Drewery# Don't rebuild build-tools targets during normal build. 101d1dd034dSBryan DreweryLIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA_CMP 102d1dd034dSBryan Drewery.endif 103f661dbeeSBryan DreweryLIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ 10476c5029cSBryan Drewery CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \ 105f661dbeeSBryan Drewery CPP="${XCPP} ${LIBCOMPATCFLAGS}" \ 106dba75e9fSBryan Drewery DESTDIR=${LIBCOMPATTMP} \ 107dba75e9fSBryan Drewery -DNO_CPU_CFLAGS \ 108dba75e9fSBryan Drewery MK_CTF=no \ 109dba75e9fSBryan Drewery -DNO_LINT \ 110dba75e9fSBryan Drewery MK_TESTS=no 111dba75e9fSBryan DreweryLIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \ 112dba75e9fSBryan Drewery MK_MAN=no MK_HTML=no 11391da7698SBryan DreweryLIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \ 114429882e6SBryan Drewery MK_TOOLCHAIN=no ${IMAKE_INSTALL} \ 115429882e6SBryan Drewery -DLIBRARIES_ONLY 116dba75e9fSBryan Drewery 117dba75e9fSBryan Drewery_LC_LIBDIRS.yes= lib gnu/lib 118048ce093SBryan Drewery_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib 119048ce093SBryan Drewery_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib 120048ce093SBryan Drewery_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib 121dba75e9fSBryan Drewery 1221b337a34SBryan Drewery_LC_INCDIRS= \ 1231b337a34SBryan Drewery include \ 1241b337a34SBryan Drewery lib/ncurses/ncursesw \ 1251b337a34SBryan Drewery ${_LC_LIBDIRS.yes} 1261b337a34SBryan Drewery 127dba75e9fSBryan Drewery# Shared logic 128dba75e9fSBryan Drewerybuild${libcompat}: .PHONY 129dba75e9fSBryan Drewery @echo 130dba75e9fSBryan Drewery @echo "--------------------------------------------------------------" 131dba75e9fSBryan Drewery @echo ">>> stage 5.1: building lib${libcompat} shim libraries" 132dba75e9fSBryan Drewery @echo "--------------------------------------------------------------" 133dba75e9fSBryan Drewery mkdir -p ${LIBCOMPATTMP}/usr/include 134dba75e9fSBryan Drewery mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 135dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr >/dev/null 136dba75e9fSBryan Drewery mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 137dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr/include >/dev/null 138dba75e9fSBryan Drewery mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 139dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr >/dev/null 140dba75e9fSBryan Drewery.if ${MK_DEBUG_FILES} != "no" 141dba75e9fSBryan Drewery mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 142dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr/lib >/dev/null 143dba75e9fSBryan Drewery mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 144dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null 145dba75e9fSBryan Drewery.endif 146dba75e9fSBryan Drewery mkdir -p ${WORLDTMP} 147dba75e9fSBryan Drewery ln -sf ${.CURDIR}/sys ${WORLDTMP} 148dba75e9fSBryan Drewery.for _t in obj includes 1491b337a34SBryan Drewery.for _dir in ${_LC_INCDIRS} 150ce6c8db5SBryan Drewery ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \ 151ce6c8db5SBryan Drewery DIRPRFX=${_dir}/ ${_t} 152dba75e9fSBryan Drewery.endfor 153dba75e9fSBryan Drewery.endfor 154dba75e9fSBryan Drewery.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic 155dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/${_dir}; \ 156dba75e9fSBryan Drewery WORLDTMP=${WORLDTMP} \ 157dba75e9fSBryan Drewery MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ 158dba75e9fSBryan Drewery MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \ 159dba75e9fSBryan Drewery DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ 160dba75e9fSBryan Drewery build-tools 161dba75e9fSBryan Drewery.endfor 162dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}; \ 163dba75e9fSBryan Drewery ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries 164dba75e9fSBryan Drewery.if ${libcompat} == "32" 165497e8091SBryan Drewery.for _t in obj all 166dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ 167dba75e9fSBryan Drewery -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} 168dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ 169dba75e9fSBryan Drewery DIRPRFX=usr.bin/ldd ${_t} 170dba75e9fSBryan Drewery.endfor 171dba75e9fSBryan Drewery.endif 172dba75e9fSBryan Drewery 173dba75e9fSBryan Drewerydistribute${libcompat} install${libcompat}: .PHONY 174dba75e9fSBryan Drewery.for _dir in ${_LC_LIBDIRS.yes} 175dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} 176dba75e9fSBryan Drewery.endfor 177dba75e9fSBryan Drewery.if ${libcompat} == "32" 178dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ 179dba75e9fSBryan Drewery PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} 180dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ 181dba75e9fSBryan Drewery ${.TARGET:S/32$//} 182dba75e9fSBryan Drewery.endif 183dba75e9fSBryan Drewery 184dba75e9fSBryan Drewery.endif 185