1dba75e9fSBryan Drewery# $FreeBSD$ 2dba75e9fSBryan Drewery 3dba75e9fSBryan Drewery.if !targets(__<${_this:T}>__) 4dba75e9fSBryan Drewery__<${_this:T}>__: 5dba75e9fSBryan Drewery 6dba75e9fSBryan Drewery# Makefile for the compatibility libraries. 769b4d461SJohn Baldwin# - 32-bit compat libraries on MIPS, PowerPC, and AMD64. 8dba75e9fSBryan Drewery 9dba75e9fSBryan Drewery# ------------------------------------------------------------------- 10dba75e9fSBryan Drewery# 32 bit world 11dba75e9fSBryan Drewery.if ${TARGET_ARCH} == "amd64" 12dba75e9fSBryan Drewery.if empty(TARGET_CPUTYPE) 13dba75e9fSBryan DreweryLIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 14dba75e9fSBryan Drewery.else 15dba75e9fSBryan DreweryLIB32CPUFLAGS= -march=${TARGET_CPUTYPE} 16dba75e9fSBryan Drewery.endif 17a00cd954SAlex Richardson.if ${WANT_COMPILER_TYPE} == gcc || \ 18a00cd954SAlex Richardson (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 19a00cd954SAlex Richardson.else 20a00cd954SAlex RichardsonLIB32CPUFLAGS+= -target x86_64-unknown-freebsd12.0 21a00cd954SAlex Richardson.endif 22452a3101SJohn BaldwinLIB32CPUFLAGS+= -m32 23dba75e9fSBryan DreweryLIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ 24dba75e9fSBryan Drewery MACHINE_CPU="i686 mmx sse sse2" 25f661dbeeSBryan DreweryLIB32WMAKEFLAGS= \ 26dba75e9fSBryan Drewery AS="${XAS} --32" \ 27dfaedbb2SEd Maste LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" \ 28dba75e9fSBryan Drewery OBJCOPY="${XOBJCOPY}" 29dba75e9fSBryan Drewery 30dba75e9fSBryan Drewery.elif ${TARGET_ARCH} == "powerpc64" 31dba75e9fSBryan Drewery.if empty(TARGET_CPUTYPE) 32dba75e9fSBryan DreweryLIB32CPUFLAGS= -mcpu=powerpc 33dba75e9fSBryan Drewery.else 34dba75e9fSBryan DreweryLIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} 35dba75e9fSBryan Drewery.endif 36452a3101SJohn BaldwinLIB32CPUFLAGS+= -m32 37dba75e9fSBryan DreweryLIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc 38f661dbeeSBryan DreweryLIB32WMAKEFLAGS= \ 39dba75e9fSBryan Drewery LD="${XLD} -m elf32ppc_fbsd" \ 40dba75e9fSBryan Drewery OBJCOPY="${XOBJCOPY}" 4169b4d461SJohn Baldwin 4269b4d461SJohn Baldwin.elif ${TARGET_ARCH:Mmips64*} != "" 43a1554bbaSJohn Baldwin.if ${WANT_COMPILER_TYPE} == gcc || \ 44a1554bbaSJohn Baldwin (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) 4569b4d461SJohn Baldwin.if empty(TARGET_CPUTYPE) 4669b4d461SJohn BaldwinLIB32CPUFLAGS= -march=mips3 4769b4d461SJohn Baldwin.else 4869b4d461SJohn BaldwinLIB32CPUFLAGS= -march=${TARGET_CPUTYPE} 4969b4d461SJohn Baldwin.endif 50a1554bbaSJohn Baldwin.else 51a1554bbaSJohn Baldwin.if ${TARGET_ARCH:Mmips64el*} != "" 52a1554bbaSJohn BaldwinLIB32CPUFLAGS= -target mipsel-unknown-freebsd12.0 53a1554bbaSJohn Baldwin.else 54a1554bbaSJohn BaldwinLIB32CPUFLAGS= -target mips-unknown-freebsd12.0 55a1554bbaSJohn Baldwin.endif 568d286bb9SJohn Baldwin.endif 5769b4d461SJohn BaldwinLIB32CPUFLAGS+= -mabi=32 5869b4d461SJohn BaldwinLIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips 5969b4d461SJohn Baldwin.if ${TARGET_ARCH:Mmips64el*} != "" 6069b4d461SJohn BaldwinLIB32WMAKEFLAGS= LD="${XLD} -m elf32ltsmip_fbsd" 6169b4d461SJohn Baldwin.else 6269b4d461SJohn BaldwinLIB32WMAKEFLAGS= LD="${XLD} -m elf32btsmip_fbsd" 6369b4d461SJohn Baldwin.endif 6469b4d461SJohn BaldwinLIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}" 65dba75e9fSBryan Drewery.endif 66dba75e9fSBryan Drewery 67bdb691d4SEd MasteLIB32WMAKEFLAGS+= NM="${XNM}" 68bdb691d4SEd Maste 69dba75e9fSBryan Drewery 70452a3101SJohn BaldwinLIB32CFLAGS= -DCOMPAT_32BIT 71dba75e9fSBryan DreweryLIB32DTRACE= ${DTRACE} -32 72dba75e9fSBryan DreweryLIB32WMAKEFLAGS+= -DCOMPAT_32BIT 73dba75e9fSBryan Drewery 74dba75e9fSBryan Drewery# ------------------------------------------------------------------- 75bb52d711SWarner Losh# soft-fp world 760b972ac9SWarner Losh.if ${TARGET_ARCH:Marmv[67]*} != "" 77bb52d711SWarner LoshLIBSOFTCFLAGS= -DCOMPAT_SOFTFP 78bb52d711SWarner LoshLIBSOFTCPUFLAGS= -mfloat-abi=softfp 790b972ac9SWarner LoshLIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${TARGET_ARCH} 80bb52d711SWarner LoshLIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP 81bb52d711SWarner Losh.endif 82bb52d711SWarner Losh 83bb52d711SWarner Losh# ------------------------------------------------------------------- 84dba75e9fSBryan Drewery# Generic code for each type. 85dba75e9fSBryan Drewery# Set defaults based on type. 86dba75e9fSBryan Drewerylibcompat= ${LIBCOMPAT:tl} 87dfa09989SBryan Drewery_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \ 8817e3ebb1SBryan Drewery WMAKEFLAGS WMAKE 89dba75e9fSBryan Drewery.for _var in ${_LIBCOMPAT_MAKEVARS} 90dba75e9fSBryan Drewery.if !empty(LIB${LIBCOMPAT}${_var}) 91dba75e9fSBryan DreweryLIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}} 92dba75e9fSBryan Drewery.endif 93dba75e9fSBryan Drewery.endfor 94dba75e9fSBryan Drewery 95dba75e9fSBryan Drewery# Shared flags 96dfa09989SBryan DreweryLIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat} 97dfa09989SBryan DreweryLIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp 98dba75e9fSBryan Drewery 99dba75e9fSBryan DreweryLIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ 100dba75e9fSBryan Drewery -L${LIBCOMPATTMP}/usr/lib${libcompat} \ 10117e3ebb1SBryan Drewery --sysroot=${LIBCOMPATTMP} \ 10217e3ebb1SBryan Drewery ${BFLAGS} 1031b337a34SBryan Drewery 1041b337a34SBryan Drewery# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for 1051b337a34SBryan Drewery# Clang/GCC. 1061b337a34SBryan DreweryLIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat} 10707394091SBryan Drewery 108dba75e9fSBryan Drewery# Yes, the flags are redundant. 109dfa09989SBryan DreweryLIBCOMPATWMAKEENV+= \ 110dba75e9fSBryan Drewery INSTALL="sh ${.CURDIR}/tools/install.sh" \ 111dba75e9fSBryan Drewery PATH=${TMPPATH} \ 11235fb812aSBryan Drewery SYSROOT=${LIBCOMPATTMP} \ 113dba75e9fSBryan Drewery LIBDIR=/usr/lib${libcompat} \ 114dba75e9fSBryan Drewery SHLIBDIR=/usr/lib${libcompat} \ 115dba75e9fSBryan Drewery DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}" 116d1dd034dSBryan Drewery.if ${MK_META_MODE} != "no" 117d1dd034dSBryan Drewery# Don't rebuild build-tools targets during normal build. 118dbbb03c2SBryan DreweryLIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA 119d1dd034dSBryan Drewery.endif 120f661dbeeSBryan DreweryLIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \ 12176c5029cSBryan Drewery CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \ 122f661dbeeSBryan Drewery CPP="${XCPP} ${LIBCOMPATCFLAGS}" \ 123dba75e9fSBryan Drewery DESTDIR=${LIBCOMPATTMP} \ 124dba75e9fSBryan Drewery -DNO_CPU_CFLAGS \ 125dba75e9fSBryan Drewery MK_CTF=no \ 126dba75e9fSBryan Drewery -DNO_LINT \ 127dba75e9fSBryan Drewery MK_TESTS=no 128dba75e9fSBryan DreweryLIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \ 1291031b94fSBryan Drewery OBJTOP=${LIBCOMPAT_OBJTOP} \ 1301031b94fSBryan Drewery OBJROOT='$${OBJTOP}/' \ 131996e4759SBryan Drewery MAKEOBJDIRPREFIX= \ 132dba75e9fSBryan Drewery MK_MAN=no MK_HTML=no 13391da7698SBryan DreweryLIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \ 13452f9bacbSJohn Baldwin ${IMAKE_INSTALL} \ 135429882e6SBryan Drewery -DLIBRARIES_ONLY 136dba75e9fSBryan Drewery 137ad91146cSEd Maste_LC_LIBDIRS.yes= lib 1380d849865SEd Maste_LC_LIBDIRS.yes+= gnu/lib 139048ce093SBryan Drewery_LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib 140048ce093SBryan Drewery_LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib 141048ce093SBryan Drewery_LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib 142dba75e9fSBryan Drewery 1431b337a34SBryan Drewery_LC_INCDIRS= \ 1441b337a34SBryan Drewery include \ 1451b337a34SBryan Drewery lib/ncurses/ncursesw \ 1461b337a34SBryan Drewery ${_LC_LIBDIRS.yes} 1471b337a34SBryan Drewery 148127b666cSBryan Drewery.if ${MK_FILE} != "no" 149127b666cSBryan Drewery_libmagic= lib/libmagic 150127b666cSBryan Drewery.endif 1516f1f2b19SBryan Drewery.if ${MK_PMC} != "no" && ${TARGET_ARCH} == "amd64" 1526f1f2b19SBryan Drewery_jevents= lib/libpmc/pmu-events 1536f1f2b19SBryan Drewery.endif 1546f1f2b19SBryan Drewery 1556f1f2b19SBryan Drewery 156dba75e9fSBryan Drewery# Shared logic 157dba75e9fSBryan Drewerybuild${libcompat}: .PHONY 158dba75e9fSBryan Drewery @echo 159dba75e9fSBryan Drewery @echo "--------------------------------------------------------------" 160dba75e9fSBryan Drewery @echo ">>> stage 5.1: building lib${libcompat} shim libraries" 161dba75e9fSBryan Drewery @echo "--------------------------------------------------------------" 16267d2f51aSBryan Drewery.if !defined(NO_CLEAN) 16367d2f51aSBryan Drewery rm -rf ${LIBCOMPATTMP} 16467d2f51aSBryan Drewery.else 1656e6be2bbSBryan Drewery ${_+_}@if [ -e "${LIBCOMPATTMP}" ]; then \ 1666e6be2bbSBryan Drewery echo ">>> Deleting stale files in build${libcompat} tree..."; \ 1676e6be2bbSBryan Drewery cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \ 16867d2f51aSBryan Drewery DESTDIR=${LIBCOMPATTMP} \ 1696e6be2bbSBryan Drewery delete-old delete-old-libs >/dev/null; \ 1706e6be2bbSBryan Drewery fi 17167d2f51aSBryan Drewery.endif # !defined(NO_CLEAN) 17267d2f51aSBryan Drewery 173dba75e9fSBryan Drewery mkdir -p ${LIBCOMPATTMP}/usr/include 17455a5b46aSAlex Richardson ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \ 175dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr >/dev/null 17655a5b46aSAlex Richardson ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \ 177dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr/include >/dev/null 17855a5b46aSAlex Richardson ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 179dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr >/dev/null 180dba75e9fSBryan Drewery.if ${MK_DEBUG_FILES} != "no" 18155a5b46aSAlex Richardson ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \ 182dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr/lib >/dev/null 18355a5b46aSAlex Richardson ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \ 184dba75e9fSBryan Drewery -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null 185dba75e9fSBryan Drewery.endif 186dba75e9fSBryan Drewery mkdir -p ${WORLDTMP} 187dba75e9fSBryan Drewery ln -sf ${.CURDIR}/sys ${WORLDTMP} 1886d75a7a8SBryan Drewery.for _t in ${_obj} includes 1891b337a34SBryan Drewery.for _dir in ${_LC_INCDIRS} 190ce6c8db5SBryan Drewery ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \ 191ce6c8db5SBryan Drewery DIRPRFX=${_dir}/ ${_t} 192dba75e9fSBryan Drewery.endfor 193dba75e9fSBryan Drewery.endfor 194127b666cSBryan Drewery.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw ${_libmagic} ${_jevents} 195c4273800SBryan Drewery.for _t in ${_obj} build-tools 196dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/${_dir}; \ 197dba75e9fSBryan Drewery WORLDTMP=${WORLDTMP} \ 198dba75e9fSBryan Drewery MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \ 1991031b94fSBryan Drewery ${MAKE} SSP_CFLAGS= DESTDIR= \ 2004dc89c4dSBryan Drewery OBJTOP=${LIBCOMPAT_OBJTOP} \ 2014dc89c4dSBryan Drewery OBJROOT='$${OBJTOP}/' \ 202996e4759SBryan Drewery MAKEOBJDIRPREFIX= \ 203*01b7ad04SEd Maste DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \ 204*01b7ad04SEd Maste MK_CTF=no MK_RETPOLINE=no MK_WARNS=no \ 205c4273800SBryan Drewery ${_t} 206c4273800SBryan Drewery.endfor 207dba75e9fSBryan Drewery.endfor 208dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}; \ 209dba75e9fSBryan Drewery ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries 21090d1f60eSEnji Cooper.if ${libcompat} == "32" 2116d75a7a8SBryan Drewery.for _t in ${_obj} all 21290d1f60eSEnji Cooper.if !defined(NO_RTLD) 213dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \ 214dba75e9fSBryan Drewery -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t} 21590d1f60eSEnji Cooper.endif 216dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \ 217dba75e9fSBryan Drewery DIRPRFX=usr.bin/ldd ${_t} 218dba75e9fSBryan Drewery.endfor 219dba75e9fSBryan Drewery.endif 220dba75e9fSBryan Drewery 221dba75e9fSBryan Drewerydistribute${libcompat} install${libcompat}: .PHONY 222dba75e9fSBryan Drewery.for _dir in ${_LC_LIBDIRS.yes} 223dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//} 224dba75e9fSBryan Drewery.endfor 22590d1f60eSEnji Cooper.if ${libcompat} == "32" 22690d1f60eSEnji Cooper.if !defined(NO_RTLD) 227dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \ 228dba75e9fSBryan Drewery PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//} 22990d1f60eSEnji Cooper.endif 230dba75e9fSBryan Drewery ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \ 231dba75e9fSBryan Drewery ${.TARGET:S/32$//} 232dba75e9fSBryan Drewery.endif 233dba75e9fSBryan Drewery 234dba75e9fSBryan Drewery.endif 235