xref: /freebsd/Makefile.libcompat (revision 034755623d3d211a82084aca3215dc1e6d103bfc)
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.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 \
31		MK_BOOT=no
32LIBCOMPATWMAKE+=	${TIME_ENV} ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
33			OBJTOP=${LIBCOMPAT_OBJTOP} \
34			OBJROOT='$${OBJTOP}/' \
35			MAKEOBJDIRPREFIX= \
36			MK_MAN=no MK_HTML=no
37LIBCOMPATIMAKE+=	${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \
38			${IMAKE_INSTALL} \
39			-DLIBRARIES_ONLY
40
41_LC_LIBDIRS.yes=		lib
42_LC_LIBDIRS.yes+=		gnu/lib
43_LC_LIBDIRS.${MK_CDDL:tl}+=	cddl/lib
44_LC_LIBDIRS.${MK_CRYPT:tl}+=	secure/lib
45_LC_LIBDIRS.${MK_KERBEROS:tl}+=	kerberos5/lib
46
47_LC_INCDIRS=	\
48		include \
49		lib/ncurses/tinfo \
50		${_LC_LIBDIRS.yes}
51
52.if ${MK_FILE} != "no"
53_libmagic=	lib/libmagic
54.endif
55.if ${MK_PMC} != "no"
56_jevents=	lib/libpmc/pmu-events
57.endif
58
59
60# Shared logic
61build${libcompat}: .PHONY
62	@echo
63	@echo "--------------------------------------------------------------"
64	@echo ">>> stage 4.3: building lib${libcompat} shim libraries"
65	@echo "--------------------------------------------------------------"
66.if ${MK_CLEAN} == "yes"
67	rm -rf ${LIBCOMPATTMP}
68.else
69	${_+_}@if [ -e "${LIBCOMPATTMP}" ]; then \
70		echo ">>> Deleting stale files in build${libcompat} tree..."; \
71		cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
72		    DESTDIR=${LIBCOMPATTMP} \
73		    delete-old delete-old-libs >/dev/null; \
74	fi
75.endif	# MK_CLEAN == "yes"
76
77	mkdir -p ${LIBCOMPATTMP}/usr/include
78	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
79	    -p ${LIBCOMPATTMP}/usr >/dev/null
80	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
81	    -p ${LIBCOMPATTMP}/usr/include >/dev/null
82	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
83	    -p ${LIBCOMPATTMP}/usr >/dev/null
84.if ${MK_DEBUG_FILES} != "no"
85	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
86	    -p ${LIBCOMPATTMP}/usr/lib >/dev/null
87	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
88	    -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null
89.endif
90	mkdir -p ${WORLDTMP}
91	ln -sf ${.CURDIR}/sys ${WORLDTMP}
92.for _t in ${_obj} includes
93.for _dir in ${_LC_INCDIRS}
94	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \
95	    DIRPRFX=${_dir}/ ${_t}
96.endfor
97.endfor
98.for _dir in lib/ncurses/tinfo ${_libmagic} ${_jevents}
99.for _t in ${_obj} build-tools
100	${_+_}cd ${.CURDIR}/${_dir}; \
101	    WORLDTMP=${WORLDTMP} \
102	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
103	    ${MAKE} DESTDIR= \
104	    OBJTOP=${LIBCOMPAT_OBJTOP} \
105	    OBJROOT='$${OBJTOP}/' \
106	    MAKEOBJDIRPREFIX= \
107	    DIRPRFX=${_dir}/ \
108	    -DNO_LINT \
109	    -DNO_CPU_CFLAGS \
110	    MK_ASAN=no \
111	    MK_CTF=no \
112	    MK_RETPOLINE=no \
113	    MK_SSP=no \
114	    MK_UBSAN=no \
115	    MK_WERROR=no \
116	    ${_t}
117.endfor
118.endfor
119	${_+_}cd ${.CURDIR}; \
120	    ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
121
122distribute${libcompat} install${libcompat}: .PHONY
123.for _dir in ${_LC_LIBDIRS.yes}
124	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
125.endfor
126
127.endif # !targets(__<${_this:T}>__)
128