3 .if !targets(__<${_this:T}>__)
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.
10 # -------------------------------------------------------------------
12 .if ${TARGET_ARCH} == "amd64"
13 .if empty(TARGET_CPUTYPE)
14 LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
16 LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
18 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
19 MACHINE_CPU="i686 mmx sse sse2"
22 LD="${XLD} -m elf_i386_fbsd -Y P,${LIBCOMPATTMP}/usr/lib32" \
25 .elif ${TARGET_ARCH} == "powerpc64"
26 .if empty(TARGET_CPUTYPE)
27 LIB32CPUFLAGS= -mcpu=powerpc
29 LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
31 LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
33 LD="${XLD} -m elf32ppc_fbsd" \
38 LIB32CFLAGS= -m32 -DCOMPAT_32BIT
39 LIB32DTRACE= ${DTRACE} -32
40 LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
42 # -------------------------------------------------------------------
44 .if ${TARGET_ARCH} == "armv6"
45 LIBSOFTCFLAGS= -DCOMPAT_SOFTFP
46 LIBSOFTCPUFLAGS= -mfloat-abi=softfp
47 LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=armv6
48 LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP
51 # -------------------------------------------------------------------
52 # Generic code for each type.
53 # Set defaults based on type.
54 libcompat= ${LIBCOMPAT:tl}
55 _LIBCOMPAT_MAKEVARS= _OBJTREE TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \
57 .for _var in ${_LIBCOMPAT_MAKEVARS}
58 .if !empty(LIB${LIBCOMPAT}${_var})
59 LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}}
64 LIBCOMPAT_OBJTREE?= ${OBJTREE}${.CURDIR}/world${libcompat}
65 LIBCOMPATTMP?= ${OBJTREE}${.CURDIR}/lib${libcompat}
67 LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \
68 -L${LIBCOMPATTMP}/usr/lib${libcompat} \
69 --sysroot=${LIBCOMPATTMP} \
72 # -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for
74 LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat}
75 # GCC requires -isystem when using a cross-compiler.
76 LIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include
78 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
79 # Force using libc++ for external GCC.
80 LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \
81 -nostdinc++ -L${LIBCOMPAT_OBJTREE}${.CURDIR}/lib/libc++
84 # Yes, the flags are redundant.
85 LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \
86 INSTALL="sh ${.CURDIR}/tools/install.sh" \
88 LIBDIR=/usr/lib${libcompat} \
89 SHLIBDIR=/usr/lib${libcompat} \
90 DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
91 .if ${MK_META_MODE} != "no"
92 # Don't rebuild build-tools targets during normal build.
93 LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA_CMP
95 LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
96 CXX="${XCXX} ${LIBCOMPATCFLAGS} ${LIBCOMPATCXXFLAGS}" \
97 CPP="${XCPP} ${LIBCOMPATCFLAGS}" \
98 DESTDIR=${LIBCOMPATTMP} \
103 LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
105 LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \
106 MK_TOOLCHAIN=no ${IMAKE_INSTALL} \
109 _LC_LIBDIRS.yes= lib gnu/lib
110 _LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib
111 _LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib
112 _LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib
116 lib/ncurses/ncursesw \
120 build${libcompat}: .PHONY
122 @echo "--------------------------------------------------------------"
123 @echo ">>> stage 5.1: building lib${libcompat} shim libraries"
124 @echo "--------------------------------------------------------------"
125 mkdir -p ${LIBCOMPATTMP}/usr/include
126 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
127 -p ${LIBCOMPATTMP}/usr >/dev/null
128 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
129 -p ${LIBCOMPATTMP}/usr/include >/dev/null
130 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
131 -p ${LIBCOMPATTMP}/usr >/dev/null
132 .if ${MK_DEBUG_FILES} != "no"
133 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
134 -p ${LIBCOMPATTMP}/usr/lib >/dev/null
135 mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
136 -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null
139 ln -sf ${.CURDIR}/sys ${WORLDTMP}
140 .for _t in obj includes
141 .for _dir in ${_LC_INCDIRS}
142 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \
143 DIRPRFX=${_dir}/ ${_t}
146 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
147 ${_+_}cd ${.CURDIR}/${_dir}; \
148 WORLDTMP=${WORLDTMP} \
149 MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
150 MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
151 DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
154 ${_+_}cd ${.CURDIR}; \
155 ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
156 .if ${libcompat} == "32"
158 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \
159 -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
160 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \
161 DIRPRFX=usr.bin/ldd ${_t}
165 distribute${libcompat} install${libcompat}: .PHONY
166 .for _dir in ${_LC_LIBDIRS.yes}
167 ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
169 .if ${libcompat} == "32"
170 ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
171 PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//}
172 ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \