git: bd914cea9e5e - stable/13 - amd64: Only build aout.ko when COMPAT_FREEBSD32 is enabled

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 14 Dec 2021 00:44:54 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=bd914cea9e5eafdbd182b4388a73e1002113cede

commit bd914cea9e5eafdbd182b4388a73e1002113cede
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-12-06 23:11:10 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-12-14 00:44:01 +0000

    amd64: Only build aout.ko when COMPAT_FREEBSD32 is enabled
    
    (cherry picked from commit 0f2d88d1ebbba796adb0492781b683cbfe25bd2d)
---
 sys/conf/kern.post.mk | 4 ++++
 sys/conf/kern.pre.mk  | 2 ++
 sys/modules/Makefile  | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index 7df67e24f445..79a6d3b516ca 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -50,6 +50,10 @@ MKMODULESENV+=	SAN_CFLAGS="${SAN_CFLAGS}"
 MKMODULESENV+=	GCOV_CFLAGS="${GCOV_CFLAGS}"
 .endif
 
+.if !empty(COMPAT_FREEBSD32_ENABLED)
+MKMODULESENV+=	COMPAT_FREEBSD32_ENABLED="yes"
+.endif
+
 # Allow overriding the kernel debug directory, so kernel and user debug may be
 # installed in different directories. Setting it to "" restores the historical
 # behavior of installing debug files in the kernel directory.
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 9730ade8a8b9..d6ab5e17a82a 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -108,6 +108,8 @@ PROF=		-pg
 .endif
 DEFINED_PROF=	${PROF}
 
+COMPAT_FREEBSD32_ENABLED!= grep COMPAT_FREEBSD32 opt_global.h || true ; echo
+
 KASAN_ENABLED!=	grep KASAN opt_global.h || true ; echo
 .if !empty(KASAN_ENABLED)
 SAN_CFLAGS+=	-fsanitize=kernel-address \
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 4db2b7311ee1..d2ff9b5405c2 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -627,7 +627,9 @@ _sdhci_fdt=	sdhci_fdt
 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
 _agp=		agp
 _an=		an
+.if ${MACHINE_CPUARCH} == "i386" || !empty(COMPAT_FREEBSD32_ENABLED)
 _aout=		aout
+.endif
 _bios=		bios
 .if ${MK_SOURCELESS_UCODE} != "no"
 _bxe=		bxe