xref: /freebsd/Makefile.libcompat (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1
2.if !targets(__<${_this:T}>__)
3__<${_this:T}>__:
4
5# Makefile for the compatibility libraries.
6# - 32-bit compat libraries on some 64-bit architectures
7
8.if defined(_LIBCOMPATS)
9
10.include <bsd.compat.mk>
11
12.for libcompatidx _LIBCOMPAT libcompat in ${_LIBCOMPATS:range:@i@${i} ${_LIBCOMPATS:[$i]} ${libcompats:[$i]}@}
13
14# Yes, the flags are redundant.
15LIB${_LIBCOMPAT}WMAKEENV+= \
16		INSTALL="${INSTALL_CMD} -U" \
17		PATH=${TMPPATH} \
18		SYSROOT=${WORLDTMP} \
19		LIBDIR=/usr/lib${libcompat} \
20		SHLIBDIR=/usr/lib${libcompat} \
21		LIBDATADIR=/usr/lib${libcompat} \
22		DTRACE="${LIB${_LIBCOMPAT}DTRACE:U${DTRACE}}"
23.if ${MK_META_MODE} != "no"
24# Don't rebuild build-tools targets during normal build.
25LIB${_LIBCOMPAT}WMAKEENV+=	BUILD_TOOLS_META=.NOMETA
26.endif
27LIB${_LIBCOMPAT}WMAKEFLAGS+= CC=${${XCC} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
28		CXX=${${XCXX} ${LIB${_LIBCOMPAT}CXXFLAGS} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
29		CPP=${${XCPP} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
30		DESTDIR=${WORLDTMP} \
31		-DNO_CPU_CFLAGS \
32		MK_BOOT=no \
33		MK_CTF=no \
34		MK_TESTS=no
35LIB${_LIBCOMPAT}WMAKE+=	${TIME_ENV} ${LIB${_LIBCOMPAT}WMAKEENV} ${MAKE} \
36			${LIB${_LIBCOMPAT}WMAKEFLAGS} \
37			OBJTOP=${LIB${_LIBCOMPAT}_OBJTOP} \
38			OBJROOT='$${OBJTOP}/' \
39			UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
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	    UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
67	    MAKEOBJDIRPREFIX= \
68	    -DNO_LINT \
69	    -DNO_CPU_CFLAGS \
70	    MK_ASAN=no \
71	    MK_CTF=no \
72	    MK_RETPOLINE=no \
73	    MK_SSP=no \
74	    MK_UBSAN=no \
75	    MK_WERROR=no \
76	    _lc_build-tools
77	${_+_}cd ${.CURDIR}; \
78	    ${LIB${_LIBCOMPAT}WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
79
80distribute${libcompat} install${libcompat}: .PHONY
81	${_+_}cd ${.CURDIR}; \
82	    ${LIB${_LIBCOMPAT}IMAKE} -f Makefile.inc1 _lc_${.TARGET:S/${libcompat}$//}
83
84.endfor # libcompatidx _LIBCOMPAT libcompat
85
86.endif # defined(_LIBCOMPATS)
87
88# These depend on MK_*, which could vary between the native and compat
89# architectures. Thus targets using them are run within a compat sub-make
90# rather than the native make environment.
91
92_LC_LIBDIRS.yes=		lib
93_LC_LIBDIRS.yes+=		gnu/lib
94_LC_LIBDIRS.${MK_CDDL:tl}+=	cddl/lib
95_LC_LIBDIRS.${MK_CRYPT:tl}+=	secure/lib
96_LC_LIBDIRS.${MK_KERBEROS:tl}+=	kerberos5/lib
97
98.if ${MK_FILE} != "no"
99_libmagic=	lib/libmagic
100.endif
101.if ${MK_PMC} != "no"
102_jevents=	lib/libpmc/pmu-events
103.endif
104
105_lc_build-tools:
106.for _dir in lib/ncurses/tinfo ${_libmagic} ${_jevents}
107.for _t in ${_obj} build-tools
108	${_+_}cd ${.CURDIR}/${_dir}; ${MAKE} DIRPRFX=${_dir}/ ${_t}
109.endfor
110.endfor
111
112_lc_distribute _lc_install:
113.for _dir in ${_LC_LIBDIRS.yes}
114	${_+_}cd ${.CURDIR}/${_dir}; ${MAKE} ${.TARGET:S/^_lc_//}
115.endfor
116
117.endif # !targets(__<${_this:T}>__)
118