resolvconf(8) now needs an additional @RESTARTCMD@ replacement when installing.
[freebsd-src.git] / Makefile.libcompat
blob9fbfa075d33808da72f20570ca9b3220416d4cd8
1 # $FreeBSD$
3 .if !targets(__<${_this:T}>__)
4 __<${_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 # -------------------------------------------------------------------
11 # 32 bit world
12 .if ${TARGET_ARCH} == "amd64"
13 .if empty(TARGET_CPUTYPE)
14 LIB32CPUFLAGS=  -march=i686 -mmmx -msse -msse2
15 .else
16 LIB32CPUFLAGS=  -march=${TARGET_CPUTYPE}
17 .endif
18 LIB32WMAKEENV=  MACHINE=i386 MACHINE_ARCH=i386 \
19                 MACHINE_CPU="i686 mmx sse sse2"
20 LIB32WMAKEFLAGS=        \
21                 AS="${XAS} --32" \
22                 LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" \
23                 OBJCOPY="${XOBJCOPY}"
25 .elif ${TARGET_ARCH} == "powerpc64"
26 .if empty(TARGET_CPUTYPE)
27 LIB32CPUFLAGS=  -mcpu=powerpc
28 .else
29 LIB32CPUFLAGS=  -mcpu=${TARGET_CPUTYPE}
30 .endif
31 LIB32WMAKEENV=  MACHINE=powerpc MACHINE_ARCH=powerpc
32 LIB32WMAKEFLAGS=        \
33                 LD="${XLD} -m elf32ppc_fbsd" \
34                 OBJCOPY="${XOBJCOPY}"
35 .endif
38 LIB32CFLAGS=    -m32 -DCOMPAT_32BIT
39 LIB32DTRACE=    ${DTRACE} -32
40 LIB32WMAKEFLAGS+=       -DCOMPAT_32BIT
42 # -------------------------------------------------------------------
43 # soft-fp world
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
49 .endif
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 \
56                         WMAKEFLAGS WMAKE
57 .for _var in ${_LIBCOMPAT_MAKEVARS}
58 .if !empty(LIB${LIBCOMPAT}${_var})
59 LIBCOMPAT${_var}?=      ${LIB${LIBCOMPAT}${_var}}
60 .endif
61 .endfor
63 # Shared flags
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} \
70                         ${BFLAGS}
72 # -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for
73 # Clang/GCC.
74 LIBCOMPATCFLAGS+=       -B${LIBCOMPATTMP}/usr/lib${libcompat}
76 .if defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc
77 # GCC requires -isystem when using a cross-compiler and --sysroot.  Note that
78 # Makefile.inc1 only applies this with an external compiler but libcompat
79 # always does since even in-tree GCC 4.2 needs this to override the built-in
80 # sysroot path which --sysroot does not actually do for headers.
81 LIBCOMPATCFLAGS+=       -isystem ${LIBCOMPATTMP}/usr/include
82 # Force using libc++ for external GCC.
83 # XXX: This should be checking MK_GNUCXX == no
84 .if ${X_COMPILER_VERSION} >= 40800 && \
85     (${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no")
86 LIBCOMPATCXXFLAGS+=     -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \
87                         -nostdinc++ -L${LIBCOMPAT_OBJTREE}${.CURDIR}/lib/libc++
88 .endif
89 .endif
91 # Yes, the flags are redundant.
92 LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \
93                 INSTALL="sh ${.CURDIR}/tools/install.sh" \
94                 PATH=${TMPPATH} \
95                 LIBDIR=/usr/lib${libcompat} \
96                 SHLIBDIR=/usr/lib${libcompat} \
97                 DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
98 .if ${MK_META_MODE} != "no"
99 # Don't rebuild build-tools targets during normal build.
100 LIBCOMPATWMAKEENV+=     BUILD_TOOLS_META=.NOMETA_CMP
101 .endif
102 LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
103                 CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \
104                 CPP="${XCPP} ${LIBCOMPATCFLAGS}" \
105                 DESTDIR=${LIBCOMPATTMP} \
106                 -DNO_CPU_CFLAGS \
107                 MK_CTF=no \
108                 -DNO_LINT \
109                 MK_TESTS=no
110 LIBCOMPATWMAKE+=        ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
111                         MK_MAN=no MK_HTML=no
112 LIBCOMPATIMAKE+=        ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \
113                         MK_TOOLCHAIN=no ${IMAKE_INSTALL} \
114                         -DLIBRARIES_ONLY
116 _LC_LIBDIRS.yes=                lib gnu/lib
117 _LC_LIBDIRS.${MK_CDDL:tl}+=     cddl/lib
118 _LC_LIBDIRS.${MK_CRYPT:tl}+=    secure/lib
119 _LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib
121 _LC_INCDIRS=    \
122                 include \
123                 lib/ncurses/ncursesw \
124                 ${_LC_LIBDIRS.yes}
126 # Shared logic
127 build${libcompat}: .PHONY
128         @echo
129         @echo "--------------------------------------------------------------"
130         @echo ">>> stage 5.1: building lib${libcompat} shim libraries"
131         @echo "--------------------------------------------------------------"
132         mkdir -p ${LIBCOMPATTMP}/usr/include
133         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
134             -p ${LIBCOMPATTMP}/usr >/dev/null
135         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
136             -p ${LIBCOMPATTMP}/usr/include >/dev/null
137         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
138             -p ${LIBCOMPATTMP}/usr >/dev/null
139 .if ${MK_DEBUG_FILES} != "no"
140         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
141             -p ${LIBCOMPATTMP}/usr/lib >/dev/null
142         mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
143             -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null
144 .endif
145         mkdir -p ${WORLDTMP}
146         ln -sf ${.CURDIR}/sys ${WORLDTMP}
147 .for _t in obj includes
148 .for _dir in ${_LC_INCDIRS}
149         ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \
150             DIRPRFX=${_dir}/ ${_t}
151 .endfor
152 .endfor
153 .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
154         ${_+_}cd ${.CURDIR}/${_dir}; \
155             WORLDTMP=${WORLDTMP} \
156             MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
157             MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
158             DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
159             build-tools
160 .endfor
161         ${_+_}cd ${.CURDIR}; \
162             ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
163 .if ${libcompat} == "32"
164 .for _t in obj all
165         ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \
166             -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
167         ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \
168             DIRPRFX=usr.bin/ldd ${_t}
169 .endfor
170 .endif
172 distribute${libcompat} install${libcompat}: .PHONY
173 .for _dir in ${_LC_LIBDIRS.yes}
174         ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
175 .endfor
176 .if ${libcompat} == "32"
177         ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
178             PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//}
179         ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \
180             ${.TARGET:S/32$//}
181 .endif
183 .endif