git: b78edde28052 - stable/14 - libfdt: Make an internal FDT library available

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Fri, 29 Mar 2024 18:11:54 UTC
The branch stable/14 has been updated by markj:

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

commit b78edde280528102d66d55058d3e287e24800e51
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-03-21 04:21:16 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-03-29 13:53:19 +0000

    libfdt: Make an internal FDT library available
    
    This will be used by bhyve to build a device tree when booting arm64
    guests.
    
    Reviewed by:    corvink, jhb
    MFC after:      1 week
    Sponsored by:   Innovate UK
    Differential Revision:  https://reviews.freebsd.org/D40994
    
    (cherry picked from commit f29af8618bf94f1e58877feb6dbef35bd8bbf56b)
---
 lib/Makefile             |  1 +
 lib/libfdt/Makefile      | 29 +++++++++++++++++++++++++++++
 share/mk/src.libnames.mk |  4 ++++
 3 files changed, 34 insertions(+)

diff --git a/lib/Makefile b/lib/Makefile
index 49d28c1eb975..6c0574e76afb 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -169,6 +169,7 @@ SUBDIR+=	clang
 SUBDIR.${MK_CUSE}+= 	libcuse
 SUBDIR.${MK_TOOLCHAIN}+=libpe
 SUBDIR.${MK_DIALOG}+=	libdpv libfigpar
+SUBDIR.${MK_FDT}+=	libfdt
 SUBDIR.${MK_FILE}+=	libmagic
 SUBDIR.${MK_GPIO}+=	libgpio
 SUBDIR.${MK_GSSAPI}+=	libgssapi librpcsec_gss
diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile
new file mode 100644
index 000000000000..c4ada46c3b2e
--- /dev/null
+++ b/lib/libfdt/Makefile
@@ -0,0 +1,29 @@
+LIB=		fdt
+
+INTERNALLIB=
+
+LIBFDTSRCDIR=	${SRCTOP}/sys/contrib/libfdt
+.PATH:		${LIBFDTSRCDIR}
+
+SRCS=					\
+		fdt.c			\
+		fdt_addresses.c		\
+		fdt_empty_tree.c	\
+		fdt_overlay.c		\
+		fdt_ro.c		\
+		fdt_rw.c		\
+		fdt_strerror.c		\
+		fdt_sw.c		\
+		fdt_wip.c
+
+INCS=					\
+		fdt.h			\
+		libfdt.h		\
+		ibfdt_env.h
+
+CFLAGS+=	-I${LIBFDTSRCDIR}
+WARNS?=		2
+
+MAN=
+
+.include <bsd.lib.mk>
diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
index 6a79d0b864d3..8885835c0632 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -44,6 +44,7 @@ _INTERNALLIBS=	\
 		c_nossp_pic \
 		cron \
 		elftc \
+		fdt \
 		fifolog \
 		ifconfig \
 		ipf \
@@ -533,6 +534,9 @@ _LIB_OBJTOP?=	${OBJTOP}
 LIBELFTCDIR=	${_LIB_OBJTOP}/lib/libelftc
 LIBELFTC?=	${LIBELFTCDIR}/libelftc${PIE_SUFFIX}.a
 
+LIBFDTDIR=	${_LIB_OBJTOP}/lib/libfdt
+LIBFDT?=	${LIBFDTDIR}/libfdt${PIE_SUFFIX}.a
+
 LIBLUADIR=	${_LIB_OBJTOP}/lib/liblua
 LIBLUA?=	${LIBLUADIR}/liblua${PIE_SUFFIX}.a