xref: /freebsd/Makefile.libcompat (revision 0a5e35a7b1811308bcb2aa2e6c7e7bd49dfc9770)
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
9.if defined(_LIBCOMPATS)
10
11.include <bsd.compat.mk>
12
13.for libcompatidx _LIBCOMPAT libcompat in ${_LIBCOMPATS:range:@i@${i} ${_LIBCOMPATS:[$i]} ${libcompats:[$i]}@}
14
15# Yes, the flags are redundant.
16LIB${_LIBCOMPAT}WMAKEENV+= \
17		INSTALL="${INSTALL_CMD} -U" \
18		PATH=${TMPPATH} \
19		SYSROOT=${WORLDTMP} \
20		LIBDIR=/usr/lib${libcompat} \
21		SHLIBDIR=/usr/lib${libcompat} \
22		LIBDATADIR=/usr/lib${libcompat} \
23		DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
24.if ${MK_META_MODE} != "no"
25# Don't rebuild build-tools targets during normal build.
26LIB${_LIBCOMPAT}WMAKEENV+=	BUILD_TOOLS_META=.NOMETA
27.endif
28LIB${_LIBCOMPAT}WMAKEFLAGS+= CC="${XCC} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
29		CXX="${XCXX} ${LIB${_LIBCOMPAT}CXXFLAGS:@v@${v:Q}@} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
30		CPP="${XCPP} ${LIB${_LIBCOMPAT}CFLAGS:@v@${v:Q}@}" \
31		DESTDIR=${WORLDTMP} \
32		-DNO_CPU_CFLAGS \
33		MK_BOOT=no \
34		MK_CTF=no \
35		MK_TESTS=no
36LIB${_LIBCOMPAT}WMAKE+=	${TIME_ENV} ${LIB${_LIBCOMPAT}WMAKEENV} ${MAKE} \
37			${LIB${_LIBCOMPAT}WMAKEFLAGS} \
38			OBJTOP=${LIB${_LIBCOMPAT}_OBJTOP} \
39			OBJROOT='$${OBJTOP}/' \
40			MAKEOBJDIRPREFIX= \
41			MK_INCLUDES=no \
42			MK_MAN=no MK_HTML=no
43LIB${_LIBCOMPAT}IMAKE+=	${LIB${_LIBCOMPAT}WMAKE:NINSTALL=*:NDESTDIR=*} \
44			${IMAKE_INSTALL} \
45			-DLIBRARIES_ONLY
46
47# Shared logic
48build${libcompat}: .PHONY
49	@echo
50	@echo "--------------------------------------------------------------"
51	@echo ">>> stage 4.3.${libcompatidx}: building lib${libcompat} shim libraries"
52	@echo "--------------------------------------------------------------"
53	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
54	    -p ${WORLDTMP}/usr >/dev/null
55.if ${MK_DEBUG_FILES} != "no"
56	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
57	    -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
58.endif
59	${_+_}cd ${.CURDIR}; \
60	    WORLDTMP=${WORLDTMP} \
61	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
62	    ${MAKE} -f Makefile.inc1 \
63	    DESTDIR= \
64	    OBJTOP=${LIB${_LIBCOMPAT}_OBJTOP} \
65	    OBJROOT='$${OBJTOP}/' \
66	    MAKEOBJDIRPREFIX= \
67	    -DNO_LINT \
68	    -DNO_CPU_CFLAGS \
69	    MK_ASAN=no \
70	    MK_CTF=no \
71	    MK_RETPOLINE=no \
72	    MK_SSP=no \
73	    MK_UBSAN=no \
74	    MK_WERROR=no \
75	    _lc_build-tools
76	${_+_}cd ${.CURDIR}; \
77	    ${LIB${_LIBCOMPAT}WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
78
79distribute${libcompat} install${libcompat}: .PHONY
80	${_+_}cd ${.CURDIR}; \
81	    ${LIB${_LIBCOMPAT}IMAKE} -f Makefile.inc1 _lc_${.TARGET:S/${libcompat}$//}
82
83.endfor # libcompatidx _LIBCOMPAT libcompat
84
85.endif # defined(_LIBCOMPATS)
86
87# These depend on MK_*, which could vary between the native and compat
88# architectures. Thus targets using them are run within a compat sub-make
89# rather than the native make environment.
90
91_LC_LIBDIRS.yes=		lib
92_LC_LIBDIRS.yes+=		gnu/lib
93_LC_LIBDIRS.${MK_CDDL:tl}+=	cddl/lib
94_LC_LIBDIRS.${MK_CRYPT:tl}+=	secure/lib
95_LC_LIBDIRS.${MK_KERBEROS:tl}+=	kerberos5/lib
96
97.if ${MK_FILE} != "no"
98_libmagic=	lib/libmagic
99.endif
100.if ${MK_PMC} != "no"
101_jevents=	lib/libpmc/pmu-events
102.endif
103
104_lc_build-tools:
105.for _dir in lib/ncurses/tinfo ${_libmagic} ${_jevents}
106.for _t in ${_obj} build-tools
107	${_+_}cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ ${_t}
108.endfor
109.endfor
110
111_lc_distribute _lc_install:
112.for _dir in ${_LC_LIBDIRS.yes}
113	${_+_}cd ${.CURDIR}/${_dir}; ${MAKE} ${.TARGET:S/^_lc_//}
114.endfor
115
116.endif # !targets(__<${_this:T}>__)
117