xref: /freebsd/Makefile.libcompat (revision 184d64af1344d6f3c370499510cede49320f4863)
1# $FreeBSD$
2
3.if !targets(__<${_this:T}>__)
4__<${_this:T}>__:
5
6# Makefile for the compatibility libraries.
7# - 32-bit compat libraries on MIPS, PowerPC, and AMD64.
8
9.include <bsd.compat.mk>
10
11# Yes, the flags are redundant.
12LIBCOMPATWMAKEENV+= \
13		INSTALL="${INSTALL_CMD} -U" \
14		PATH=${TMPPATH} \
15		SYSROOT=${LIBCOMPATTMP} \
16		LIBDIR=/usr/lib${libcompat} \
17		SHLIBDIR=/usr/lib${libcompat} \
18		DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
19.if ${MK_META_MODE} != "no"
20# Don't rebuild build-tools targets during normal build.
21LIBCOMPATWMAKEENV+=	BUILD_TOOLS_META=.NOMETA
22.endif
23LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
24		CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \
25		CPP="${XCPP} ${LIBCOMPATCFLAGS}" \
26		DESTDIR=${LIBCOMPATTMP} \
27		-DNO_CPU_CFLAGS \
28		MK_CTF=no \
29		-DNO_LINT \
30		MK_TESTS=no
31LIBCOMPATWMAKE+=	${TIME_ENV} ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
32			OBJTOP=${LIBCOMPAT_OBJTOP} \
33			OBJROOT='$${OBJTOP}/' \
34			MAKEOBJDIRPREFIX= \
35			MK_MAN=no MK_HTML=no
36LIBCOMPATIMAKE+=	${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \
37			${IMAKE_INSTALL} \
38			-DLIBRARIES_ONLY
39
40_LC_LIBDIRS.yes=		lib
41_LC_LIBDIRS.yes+=		gnu/lib
42_LC_LIBDIRS.${MK_CDDL:tl}+=	cddl/lib
43_LC_LIBDIRS.${MK_CRYPT:tl}+=	secure/lib
44_LC_LIBDIRS.${MK_KERBEROS:tl}+=	kerberos5/lib
45
46_LC_INCDIRS=	\
47		include \
48		lib/ncurses/ncurses \
49		${_LC_LIBDIRS.yes}
50
51.if ${MK_FILE} != "no"
52_libmagic=	lib/libmagic
53.endif
54.if ${MK_PMC} != "no"
55_jevents=	lib/libpmc/pmu-events
56.endif
57
58
59# Shared logic
60build${libcompat}: .PHONY
61	@echo
62	@echo "--------------------------------------------------------------"
63	@echo ">>> stage 4.3: building lib${libcompat} shim libraries"
64	@echo "--------------------------------------------------------------"
65.if ${MK_CLEAN} == "yes"
66	rm -rf ${LIBCOMPATTMP}
67.else
68	${_+_}@if [ -e "${LIBCOMPATTMP}" ]; then \
69		echo ">>> Deleting stale files in build${libcompat} tree..."; \
70		cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
71		    DESTDIR=${LIBCOMPATTMP} \
72		    delete-old delete-old-libs >/dev/null; \
73	fi
74.endif	# MK_CLEAN == "yes"
75
76	mkdir -p ${LIBCOMPATTMP}/usr/include
77	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
78	    -p ${LIBCOMPATTMP}/usr >/dev/null
79	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
80	    -p ${LIBCOMPATTMP}/usr/include >/dev/null
81	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
82	    -p ${LIBCOMPATTMP}/usr >/dev/null
83.if ${MK_DEBUG_FILES} != "no"
84	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
85	    -p ${LIBCOMPATTMP}/usr/lib >/dev/null
86	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
87	    -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null
88.endif
89	mkdir -p ${WORLDTMP}
90	ln -sf ${.CURDIR}/sys ${WORLDTMP}
91.for _t in ${_obj} includes
92.for _dir in ${_LC_INCDIRS}
93	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \
94	    DIRPRFX=${_dir}/ ${_t}
95.endfor
96.endfor
97.for _dir in lib/ncurses/ncurses ${_libmagic} ${_jevents}
98.for _t in ${_obj} build-tools
99	${_+_}cd ${.CURDIR}/${_dir}; \
100	    WORLDTMP=${WORLDTMP} \
101	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
102	    ${MAKE} SSP_CFLAGS= DESTDIR= \
103	    OBJTOP=${LIBCOMPAT_OBJTOP} \
104	    OBJROOT='$${OBJTOP}/' \
105	    MAKEOBJDIRPREFIX= \
106	    DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \
107	    MK_ASAN=no MK_UBSAN=no \
108	    MK_CTF=no MK_RETPOLINE=no MK_WERROR=no \
109	    ${_t}
110.endfor
111.endfor
112	${_+_}cd ${.CURDIR}; \
113	    ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
114
115distribute${libcompat} install${libcompat}: .PHONY
116.for _dir in ${_LC_LIBDIRS.yes}
117	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
118.endfor
119
120.endif # !targets(__<${_this:T}>__)
121