xref: /freebsd/Makefile.libcompat (revision a4330302f22d45d4158204b2d5d7c6738100f3a5)
1dba75e9fSBryan Drewery# $FreeBSD$
2dba75e9fSBryan Drewery
3dba75e9fSBryan Drewery.if !targets(__<${_this:T}>__)
4dba75e9fSBryan Drewery__<${_this:T}>__:
5dba75e9fSBryan Drewery
6dba75e9fSBryan Drewery# Makefile for the compatibility libraries.
769b4d461SJohn Baldwin# - 32-bit compat libraries on MIPS, PowerPC, and AMD64.
8dba75e9fSBryan Drewery
9bbcf7eddSBrooks Davis.include <bsd.compat.mk>
1007394091SBryan Drewery
11dba75e9fSBryan Drewery# Yes, the flags are redundant.
12dfa09989SBryan DreweryLIBCOMPATWMAKEENV+= \
13dba75e9fSBryan Drewery		INSTALL="sh ${.CURDIR}/tools/install.sh" \
14dba75e9fSBryan Drewery		PATH=${TMPPATH} \
1535fb812aSBryan Drewery		SYSROOT=${LIBCOMPATTMP} \
16dba75e9fSBryan Drewery		LIBDIR=/usr/lib${libcompat} \
17dba75e9fSBryan Drewery		SHLIBDIR=/usr/lib${libcompat} \
18dba75e9fSBryan Drewery		DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
19d1dd034dSBryan Drewery.if ${MK_META_MODE} != "no"
20d1dd034dSBryan Drewery# Don't rebuild build-tools targets during normal build.
21dbbb03c2SBryan DreweryLIBCOMPATWMAKEENV+=	BUILD_TOOLS_META=.NOMETA
22d1dd034dSBryan Drewery.endif
23f661dbeeSBryan DreweryLIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
2476c5029cSBryan Drewery		CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \
25f661dbeeSBryan Drewery		CPP="${XCPP} ${LIBCOMPATCFLAGS}" \
26dba75e9fSBryan Drewery		DESTDIR=${LIBCOMPATTMP} \
27dba75e9fSBryan Drewery		-DNO_CPU_CFLAGS \
28dba75e9fSBryan Drewery		MK_CTF=no \
29dba75e9fSBryan Drewery		-DNO_LINT \
30dba75e9fSBryan Drewery		MK_TESTS=no
31dba75e9fSBryan DreweryLIBCOMPATWMAKE+=	${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
321031b94fSBryan Drewery			OBJTOP=${LIBCOMPAT_OBJTOP} \
331031b94fSBryan Drewery			OBJROOT='$${OBJTOP}/' \
34996e4759SBryan Drewery			MAKEOBJDIRPREFIX= \
35dba75e9fSBryan Drewery			MK_MAN=no MK_HTML=no
3691da7698SBryan DreweryLIBCOMPATIMAKE+=	${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \
3752f9bacbSJohn Baldwin			${IMAKE_INSTALL} \
38429882e6SBryan Drewery			-DLIBRARIES_ONLY
39dba75e9fSBryan Drewery
40ad91146cSEd Maste_LC_LIBDIRS.yes=		lib
410d849865SEd Maste_LC_LIBDIRS.yes+=		gnu/lib
4289ebdc94STijl Coosemans_LC_LIBDIRS.yes+=		usr.bin/lex/lib
43048ce093SBryan Drewery_LC_LIBDIRS.${MK_CDDL:tl}+=	cddl/lib
44048ce093SBryan Drewery_LC_LIBDIRS.${MK_CRYPT:tl}+=	secure/lib
45048ce093SBryan Drewery_LC_LIBDIRS.${MK_KERBEROS:tl}+=	kerberos5/lib
46dba75e9fSBryan Drewery
471b337a34SBryan Drewery_LC_INCDIRS=	\
481b337a34SBryan Drewery		include \
491b337a34SBryan Drewery		lib/ncurses/ncursesw \
501b337a34SBryan Drewery		${_LC_LIBDIRS.yes}
511b337a34SBryan Drewery
52127b666cSBryan Drewery.if ${MK_FILE} != "no"
53127b666cSBryan Drewery_libmagic=	lib/libmagic
54127b666cSBryan Drewery.endif
556f1f2b19SBryan Drewery.if ${MK_PMC} != "no" && ${TARGET_ARCH} == "amd64"
566f1f2b19SBryan Drewery_jevents=	lib/libpmc/pmu-events
576f1f2b19SBryan Drewery.endif
586f1f2b19SBryan Drewery
596f1f2b19SBryan Drewery
60dba75e9fSBryan Drewery# Shared logic
61dba75e9fSBryan Drewerybuild${libcompat}: .PHONY
62dba75e9fSBryan Drewery	@echo
63dba75e9fSBryan Drewery	@echo "--------------------------------------------------------------"
645dab1313SBrooks Davis	@echo ">>> stage 4.3: building lib${libcompat} shim libraries"
65dba75e9fSBryan Drewery	@echo "--------------------------------------------------------------"
6667d2f51aSBryan Drewery.if !defined(NO_CLEAN)
6767d2f51aSBryan Drewery	rm -rf ${LIBCOMPATTMP}
6867d2f51aSBryan Drewery.else
696e6be2bbSBryan Drewery	${_+_}@if [ -e "${LIBCOMPATTMP}" ]; then \
706e6be2bbSBryan Drewery		echo ">>> Deleting stale files in build${libcompat} tree..."; \
716e6be2bbSBryan Drewery		cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
7267d2f51aSBryan Drewery		    DESTDIR=${LIBCOMPATTMP} \
736e6be2bbSBryan Drewery		    delete-old delete-old-libs >/dev/null; \
746e6be2bbSBryan Drewery	fi
7567d2f51aSBryan Drewery.endif	# !defined(NO_CLEAN)
7667d2f51aSBryan Drewery
77dba75e9fSBryan Drewery	mkdir -p ${LIBCOMPATTMP}/usr/include
7855a5b46aSAlex Richardson	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
79dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr >/dev/null
8055a5b46aSAlex Richardson	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
81dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr/include >/dev/null
8255a5b46aSAlex Richardson	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
83dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr >/dev/null
84dba75e9fSBryan Drewery.if ${MK_DEBUG_FILES} != "no"
8555a5b46aSAlex Richardson	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
86dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr/lib >/dev/null
8755a5b46aSAlex Richardson	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
88dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null
89dba75e9fSBryan Drewery.endif
90dba75e9fSBryan Drewery	mkdir -p ${WORLDTMP}
91dba75e9fSBryan Drewery	ln -sf ${.CURDIR}/sys ${WORLDTMP}
926d75a7a8SBryan Drewery.for _t in ${_obj} includes
931b337a34SBryan Drewery.for _dir in ${_LC_INCDIRS}
94ce6c8db5SBryan Drewery	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \
95ce6c8db5SBryan Drewery	    DIRPRFX=${_dir}/ ${_t}
96dba75e9fSBryan Drewery.endfor
97dba75e9fSBryan Drewery.endfor
98127b666cSBryan Drewery.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw ${_libmagic} ${_jevents}
99c4273800SBryan Drewery.for _t in ${_obj} build-tools
100dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/${_dir}; \
101dba75e9fSBryan Drewery	    WORLDTMP=${WORLDTMP} \
102dba75e9fSBryan Drewery	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
1031031b94fSBryan Drewery	    ${MAKE} SSP_CFLAGS= DESTDIR= \
1044dc89c4dSBryan Drewery	    OBJTOP=${LIBCOMPAT_OBJTOP} \
1054dc89c4dSBryan Drewery	    OBJROOT='$${OBJTOP}/' \
106996e4759SBryan Drewery	    MAKEOBJDIRPREFIX= \
10701b7ad04SEd Maste	    DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \
10801b7ad04SEd Maste	    MK_CTF=no MK_RETPOLINE=no MK_WARNS=no \
109c4273800SBryan Drewery	    ${_t}
110c4273800SBryan Drewery.endfor
111dba75e9fSBryan Drewery.endfor
112dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}; \
113dba75e9fSBryan Drewery	    ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
114dba75e9fSBryan Drewery
115dba75e9fSBryan Drewerydistribute${libcompat} install${libcompat}: .PHONY
116dba75e9fSBryan Drewery.for _dir in ${_LC_LIBDIRS.yes}
117dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
118dba75e9fSBryan Drewery.endfor
119dba75e9fSBryan Drewery
120*a4330302SBrooks Davis.endif # !targets(__<${_this:T}>__)
121