git: ff8d9d9c5618 - main - config.mk: Add opt_platform.h support

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 05 Apr 2022 19:55:59 UTC
The branch main has been updated by imp:

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

commit ff8d9d9c56185d38f507ffe2659cfd13633b9a12
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-04-05 19:39:09 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-04-05 19:52:55 +0000

    config.mk: Add opt_platform.h support
    
    opt_platform.h is now included from miivar.h, so add support for
    generating it in the standalone build case.
    
    Sponsored by:           Netflix
---
 sys/conf/config.mk    |  6 +++++-
 sys/conf/kern.opts.mk | 11 +++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/sys/conf/config.mk b/sys/conf/config.mk
index 96b03da27980..90e8934d1908 100644
--- a/sys/conf/config.mk
+++ b/sys/conf/config.mk
@@ -37,7 +37,11 @@ opt_ratelimit.h:
 	@echo "#define RATELIMIT 1" > ${.TARGET}
 .endif
 opt_mrouting.h:
-	echo "#define MROUTING 1" > ${.TARGET}
+	@echo "#define MROUTING 1" > ${.TARGET}
+.if ${MK_FDT} != "no"
+opt_platform.h:
+	@echo "#define FDT 1" > ${.TARGET}
+.endif
 opt_printf.h:
 	echo "#define PRINTF_BUFR_SIZE 128" > ${.TARGET}
 opt_scsi.h:
diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk
index 532c282edc34..077009baebf0 100644
--- a/sys/conf/kern.opts.mk
+++ b/sys/conf/kern.opts.mk
@@ -102,6 +102,12 @@ BROKEN_OPTIONS+= KERNEL_RETPOLINE
 BROKEN_OPTIONS+=EFI
 .endif
 
+.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+__DEFAULT_NO_OPTIONS += FDT
+.else
+__DEFAULT_YES_OPTIONS += FDT
+.endif
+
 # expanded inline from bsd.mkopt.mk to avoid share/mk dependency
 
 # Those that default to yes
@@ -178,4 +184,9 @@ MK_${var}_SUPPORT:= yes
 .if !defined(OPT_FDT) && defined(KERNBUILDDIR)
 OPT_FDT!= sed -n '/FDT/p' ${KERNBUILDDIR}/opt_platform.h
 .export OPT_FDT
+.if empty(OPT_FDT)
+MK_FDT:=no
+.else
+MK_FDT:=yes
+.endif
 .endif