xref: /freebsd/Makefile.libcompat (revision 56b17de1e8360fe131d425de20b5e75ff3ea897c)
1.if !targets(__<${_this:T}>__)
2__<${_this:T}>__:
3
4# Makefile for the compatibility libraries.
5# - 32-bit compat libraries on some 64-bit architectures
6
7.if defined(_LIBCOMPATS)
8
9.include <bsd.compat.mk>
10
11.for libcompatidx _LIBCOMPAT libcompat in ${_LIBCOMPATS:range:@i@${i} ${_LIBCOMPATS:[$i]} ${libcompats:[$i]}@}
12
13# Yes, the flags are redundant.
14LIB${_LIBCOMPAT}WMAKEENV+= \
15		INSTALL="${INSTALL_CMD} -U" \
16		PATH=${TMPPATH} \
17		SYSROOT=${WORLDTMP} \
18		LIBDIR=/usr/lib${libcompat} \
19		SHLIBDIR=/usr/lib${libcompat} \
20		LIBDATADIR=/usr/lib${libcompat} \
21		DTRACE="${LIB${_LIBCOMPAT}DTRACE:U${DTRACE}}"
22.if ${MK_META_MODE} != "no"
23# Don't rebuild build-tools targets during normal build.
24LIB${_LIBCOMPAT}WMAKEENV+=	BUILD_TOOLS_META=.NOMETA
25.endif
26LIB${_LIBCOMPAT}WMAKEFLAGS+= CC=${${XCC} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
27		CXX=${${XCXX} ${LIB${_LIBCOMPAT}CXXFLAGS} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
28		CPP=${${XCPP} ${LIB${_LIBCOMPAT}CFLAGS}:L:Q} \
29		DESTDIR=${WORLDTMP} \
30		-DNO_CPU_CFLAGS \
31		MK_BOOT=no \
32		MK_CTF=no \
33		MK_TESTS=no
34LIB${_LIBCOMPAT}WMAKE+=	${TIME_ENV} ${LIB${_LIBCOMPAT}WMAKEENV} ${MAKE} \
35			${LIB${_LIBCOMPAT}WMAKEFLAGS} \
36			OBJTOP=${LIB${_LIBCOMPAT}_OBJTOP} \
37			OBJROOT='$${OBJTOP}/' \
38			UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
39			MAKEOBJDIRPREFIX= \
40			MK_INCLUDES=no \
41			MK_MAN=no MK_HTML=no
42LIB${_LIBCOMPAT}IMAKE+=	${LIB${_LIBCOMPAT}WMAKE:NINSTALL=*:NDESTDIR=*} \
43			${IMAKE_INSTALL} \
44			-DLIBRARIES_ONLY
45
46# Shared logic
47build${libcompat}: .PHONY
48	@echo
49	@echo "--------------------------------------------------------------"
50	@echo ">>> stage 4.3.${libcompatidx}: building lib${libcompat} shim libraries"
51	@echo "--------------------------------------------------------------"
52	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
53	    -p ${WORLDTMP}/usr >/dev/null
54.if ${MK_DEBUG_FILES} != "no"
55	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
56	    -p ${WORLDTMP}/usr/lib/debug/usr >/dev/null
57.endif
58	${_+_}cd ${.CURDIR}; \
59	    WORLDTMP=${WORLDTMP} \
60	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
61	    ${MAKE} -f Makefile.inc1 \
62	    DESTDIR= \
63	    OBJTOP=${LIB${_LIBCOMPAT}_OBJTOP} \
64	    OBJROOT='$${OBJTOP}/' \
65	    UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
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