1# $FreeBSD$ 2 3.if !targets(__<${_this:T}>__) 4__<${_this:T}>__: 5 6# Makefile for the compatibility libraries. 7# - 32-bit compat libraries on PowerPC and AMD64. 8# could also be for mips, but that doesn't work today. 9 10# ------------------------------------------------------------------- 11# 32 bit world 12.if ${TARGET_ARCH} == "amd64" 13.if empty(TARGET_CPUTYPE) 14LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 15.else 16LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} 17.endif 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 -Y P,${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 31LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc 32LIB32WMAKEFLAGS= \ 33 LD="${XLD} -m elf32ppc_fbsd" \ 34 OBJCOPY="${XOBJCOPY}" 35.endif 36 37 38LIB32CFLAGS= -m32 -DCOMPAT_32BIT 39LIB32DTRACE= ${DTRACE} -32 40LIB32WMAKEFLAGS+= -DCOMPAT_32BIT 41 42# ------------------------------------------------------------------- 43# soft-fp world 44.if ${TARGET_ARCH} == "armv6" 45LIBSOFTCFLAGS= -DCOMPAT_SOFTFP 46LIBSOFTCPUFLAGS= -mfloat-abi=softfp 47LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=armv6 48LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP 49.endif 50 51# ------------------------------------------------------------------- 52# Generic code for each type. 53# Set defaults based on type. 54libcompat= ${LIBCOMPAT:tl} 55_LIBCOMPAT_MAKEVARS= _OBJTREE TMP CPUFLAGS CFLAGS WMAKEENV WMAKEFLAGS WMAKE 56.for _var in ${_LIBCOMPAT_MAKEVARS} 57.if !empty(LIB${LIBCOMPAT}${_var}) 58LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}} 59.endif 60.endfor 61 62# Shared flags 63LIBCOMPAT_OBJTREE?= ${OBJTREE}${.CURDIR}/world${libcompat} 64LIBCOMPATTMP?= ${OBJTREE}${.CURDIR}/lib${libcompat} 65 66LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ 67 -isystem ${LIBCOMPATTMP}/usr/include/ \ 68 -L${LIBCOMPATTMP}/usr/lib${libcompat} \ 69 -B${LIBCOMPATTMP}/usr/lib${libcompat} 70 71# Yes, the flags are redundant. 72LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \ 73 _LDSCRIPTROOT=${LIBCOMPATTMP} \ 74 INSTALL="sh ${.CURDIR}/tools/install.sh" \ 75 PATH=${TMPPATH} \ 76 LIBDIR=/usr/lib${libcompat} \ 77 SHLIBDIR=/usr/lib${libcompat} \ 78 DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}" 79LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ 80 CXX="${XCXX} ${LIBCOMPATCFLAGS}" \ 81 DESTDIR=${LIBCOMPATTMP} \ 82 -DLIBRARIES_ONLY \ 83 -DNO_CPU_CFLAGS \ 84 MK_CTF=no \ 85 -DNO_LINT \ 86 MK_TESTS=no 87LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \ 88 MK_MAN=no MK_HTML=no 89LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \ 90 MK_TOOLCHAIN=no ${IMAKE_INSTALL} 91 92.if ${XCC:N${CCACHE_BIN}:M/*} 93LIBCOMPATCFLAGS+= --sysroot=${WORLDTMP} 94.endif 95 96_LC_LIBDIRS.yes= lib gnu/lib 97_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib 98_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib 99_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib 100 101# Shared logic 102build${libcompat}: .PHONY 103 @echo 104 @echo "--------------------------------------------------------------" 105 @echo ">>> stage 5.1: building lib${libcompat} shim libraries" 106 @echo "--------------------------------------------------------------" 107 mkdir -p ${LIBCOMPATTMP}/usr/include 108 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 109 -p ${LIBCOMPATTMP}/usr >/dev/null 110 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 111 -p ${LIBCOMPATTMP}/usr/include >/dev/null 112 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 113 -p ${LIBCOMPATTMP}/usr >/dev/null 114.if ${MK_DEBUG_FILES} != "no" 115 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 116 -p ${LIBCOMPATTMP}/usr/lib >/dev/null 117 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 118 -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null 119.endif 120 mkdir -p ${WORLDTMP} 121 ln -sf ${.CURDIR}/sys ${WORLDTMP} 122.for _t in obj includes 123 ${_+_}cd ${.CURDIR}/include; ${LIBCOMPATWMAKE} DIRPRFX=include/ ${_t} 124.for _dir in ${_LC_LIBDIRS.yes} 125 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} DIRPRFX=${_dir}/ ${_t} 126.endfor 127.endfor 128.for _dir in usr.bin/lex/lib 129 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} DIRPRFX=${_dir}/ obj 130.endfor 131.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic 132 ${_+_}cd ${.CURDIR}/${_dir}; \ 133 WORLDTMP=${WORLDTMP} \ 134 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ 135 MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \ 136 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \ 137 build-tools 138.endfor 139 ${_+_}cd ${.CURDIR}; \ 140 ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries 141.if ${libcompat} == "32" 142.for _t in obj depend all 143 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ 144 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} 145 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ 146 DIRPRFX=usr.bin/ldd ${_t} 147.endfor 148.endif 149 150distribute${libcompat} install${libcompat}: .PHONY 151.for _dir in ${_LC_LIBDIRS.yes} 152 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} 153.endfor 154.if ${libcompat} == "32" 155 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ 156 PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} 157 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ 158 ${.TARGET:S/32$//} 159.endif 160 161.endif 162