Page MenuHomeFreeBSD

D62339.1796344026.diff
No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None

D62339.1796344026.diff

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -180,7 +180,8 @@
test-includes
.for libcompat in ${_ALL_libcompats}
-TGTS+= build${libcompat} distribute${libcompat} install${libcompat}
+TGTS+= build${libcompat} buildenv${libcompat} buildenvvars${libcompat} \
+ distribute${libcompat} install${libcompat}
.endfor
# These targets require a TARGET and TARGET_ARCH be defined.
diff --git a/Makefile.inc1 b/Makefile.inc1
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -1311,11 +1311,13 @@
buildenvvars: .PHONY
@echo ${WMAKEENV:Q} ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@}
-.if ${.TARGETS:Mbuildenv}
+.for _tgt in buildenv ${libcompats:S/^/buildenv/}
+.if ${.TARGETS:M${_tgt}}
.if ${.MAKEFLAGS:M-j}
-.error The buildenv target is incompatible with -j
+.error The ${_tgt} target is incompatible with -j
.endif
.endif
+.endfor
BUILDENV_DIR?= ${.CURDIR}
#
# Note: make will report any errors the shell reports. This can
diff --git a/Makefile.libcompat b/Makefile.libcompat
--- a/Makefile.libcompat
+++ b/Makefile.libcompat
@@ -30,19 +30,29 @@
-DNO_CPU_CFLAGS \
MK_BOOT=no \
MK_CTF=no \
- MK_TESTS=no
+ MK_TESTS=no \
+ OBJTOP=${LIB${_LIBCOMPAT}_OBJTOP} \
+ OBJROOT='$${OBJTOP}/' \
+ UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
+ MAKEOBJDIRPREFIX= \
+ MK_INCLUDES=no \
+ MK_MAN=no MK_HTML=no
LIB${_LIBCOMPAT}WMAKE+= ${TIME_ENV} ${LIB${_LIBCOMPAT}WMAKEENV} ${MAKE} \
- ${LIB${_LIBCOMPAT}WMAKEFLAGS} \
- OBJTOP=${LIB${_LIBCOMPAT}_OBJTOP} \
- OBJROOT='$${OBJTOP}/' \
- UNIVERSE_TOOLCHAIN_PATH=${UNIVERSE_TOOLCHAIN_PATH} \
- MAKEOBJDIRPREFIX= \
- MK_INCLUDES=no \
- MK_MAN=no MK_HTML=no
+ ${LIB${_LIBCOMPAT}WMAKEFLAGS}
LIB${_LIBCOMPAT}IMAKE+= ${LIB${_LIBCOMPAT}WMAKE:NINSTALL=*:NDESTDIR=*} \
${IMAKE_INSTALL} \
-DLIBRARIES_ONLY
+# The environment of buildenv${libcompat}: the environment and the make flags
+# of the compat world stage, with -DVAR passed as VAR=1. TARGET and
+# TARGET_ARCH, which the stage gets from MAKEFLAGS, are included because
+# src.opts.mk selects the default options by them. As for buildenv,
+# DESTDIR is not set.
+LIB${_LIBCOMPAT}BUILDENVVARS= ${LIB${_LIBCOMPAT}WMAKEENV} \
+ ${LIB${_LIBCOMPAT}WMAKEFLAGS:NDESTDIR=*:N-D*} \
+ ${LIB${_LIBCOMPAT}WMAKEFLAGS:M-D*:S/^-D//:S/$/=1/} \
+ TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}
+
# Shared logic
build${libcompat}: .PHONY
@echo
@@ -80,10 +90,33 @@
${_+_}cd ${.CURDIR}; \
${LIB${_LIBCOMPAT}IMAKE} -f Makefile.inc1 _lc_${.TARGET:S/${libcompat}$//}
+# The buildenv targets for the compat world, see buildenv and buildenvvars
+# in Makefile.inc1. The compat world variables are printed after the
+# exported ones, which include OBJROOT when Makefile.inc1 is run directly.
+buildenv${libcompat}: .PHONY
+ @echo Entering lib${libcompat} world for ${TARGET_ARCH}:${TARGET}
+ @cd ${BUILDENV_DIR} && env ${LIB${_LIBCOMPAT}BUILDENVVARS} \
+ INSTALL="${INSTALL_CMD} ${INSTALLFLAGS}" \
+ MTREE_CMD="${MTREE_CMD} ${MTREEFLAGS}" BUILDENV=1 ${BUILDENV_SHELL}
+
+buildenvvars${libcompat}: .PHONY
+ @echo ${.MAKE.EXPORTED:@v@$v=\"${$v}\"@} \
+ ${LIB${_LIBCOMPAT}BUILDENVVARS:Q}
+
.endfor # libcompatidx _LIBCOMPAT libcompat
.endif # defined(_LIBCOMPATS)
+# Fail the buildenv target of a compat world that is not built. Left
+# undefined, it would be defined by src.init.mk to run make in the
+# top-level directory again, endlessly.
+.for libcompat in ${_ALL_libcompats}
+.if !target(buildenv${libcompat})
+buildenv${libcompat}: .PHONY
+ @echo "lib${libcompat} is not built for ${TARGET_ARCH}"; false
+.endif
+.endfor
+
# These depend on MK_*, which could vary between the native and compat
# architectures. Thus targets using them are run within a compat sub-make
# rather than the native make environment.
diff --git a/share/man/man7/build.7 b/share/man/man7/build.7
--- a/share/man/man7/build.7
+++ b/share/man/man7/build.7
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 18, 2026
+.Dd December 3, 2026
.Dt BUILD 7
.Os
.Sh NAME
@@ -199,10 +199,35 @@
If that application has dependencies, though, the
.Pa devel/poudriere
package or port provides a more generic solution.
+.It Cm buildenv32
+Like
+.Cm buildenv ,
+but with the environment set up for building the 32-bit compatibility
+libraries the way
+.Cm buildworld
+builds them.
+The objects are placed in the
+.Pa obj-lib32
+subdirectory of the object directory, and the libraries are installed
+into
+.Pa /usr/lib32 .
+.Pp
+This target is only available when the 32-bit compatibility libraries
+are built, see
+.Va WITHOUT_LIB32
+in
+.Xr src.conf 5 ,
+and it is only useful after
+.Cm buildworld
+has built them.
.It Cm buildenvvars
Print the shell variables that are set for a
.Cm buildenv
environment and exit.
+.It Cm buildenvvars32
+Print the shell variables that are set for a
+.Cm buildenv32
+environment and exit.
.It Cm buildworld
Build everything but the kernel, configure files in
.Pa etc ,
@@ -1196,6 +1221,17 @@
make buildenv TARGET_ARCH=aarch64
make kernel KERNFAST=1 DESTDIR=/client
.Ed
+.Ss Example 7: Build and upgrade a single 32-bit compatibility library
+After a
+.Cm buildworld
+that built the 32-bit compatibility libraries, rebuild and reinstall
+the 32-bit version of a single library, in this case
+.Xr libthr 3 :
+.Bd -literal -offset indent
+cd /usr/src/lib/libthr
+make buildenv32
+make clean all install
+.Ed
.Sh DIAGNOSTICS
.Bl -diag
.It Bad system call (core dumped)
diff --git a/share/mk/src.init.mk b/share/mk/src.init.mk
--- a/share/mk/src.init.mk
+++ b/share/mk/src.init.mk
@@ -2,10 +2,14 @@
.if !target(__<src.init.mk>__)
__<src.init.mk>__: .NOTMAIN
-.if !target(buildenv)
-buildenv: .PHONY .NOTMAIN
- ${_+_}@env BUILDENV_DIR=${.CURDIR} ${MAKE} -C ${SRCTOP} buildenv
+.include <bsd.compat.pre.mk>
+
+.for _tgt in buildenv ${_ALL_libcompats:S/^/buildenv/}
+.if !target(${_tgt})
+${_tgt}: .PHONY .NOTMAIN
+ ${_+_}@env BUILDENV_DIR=${.CURDIR} ${MAKE} -C ${SRCTOP} ${_tgt}
.endif
+.endfor
.if ${MACHINE:Nhost*} == ""
.if ${.MAKE.OS} != "FreeBSD"

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 4, 12:27 AM (23 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42197134
Default Alt Text
D62339.1796344026.diff (5 KB)

Event Timeline