xref: /freebsd/Makefile.libcompat (revision ce6a89e27cd190313be39bb479880aeda4778436)
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="sh ${.CURDIR}/tools/install.sh" \
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+=	${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/ncursesw \
49		${_LC_LIBDIRS.yes}
50
51.if ${MK_FILE} != "no"
52_libmagic=	lib/libmagic
53.endif
54.if ${MK_PMC} != "no" && ${TARGET_ARCH} == "amd64"
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 !defined(NO_CLEAN)
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	# !defined(NO_CLEAN)
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 lib/ncurses/ncursesw ${_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_CTF=no MK_RETPOLINE=no MK_WARNS=no \
108	    ${_t}
109.endfor
110.endfor
111	${_+_}cd ${.CURDIR}; \
112	    ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
113
114distribute${libcompat} install${libcompat}: .PHONY
115.for _dir in ${_LC_LIBDIRS.yes}
116	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
117.endfor
118
119.endif # !targets(__<${_this:T}>__)
120