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