git: f29af8618bf9 - main - libfdt: Make an internal FDT library available

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Thu, 21 Mar 2024 05:06:22 UTC
The branch main has been updated by markj:

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

commit f29af8618bf94f1e58877feb6dbef35bd8bbf56b
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-03-21 04:21:16 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-03-21 05:05:05 +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
---
 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 9d2531820c8b..a632a77e6071 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -171,6 +171,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 0fd349d0d00f..d9fe88146dbe 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 \
@@ -546,6 +547,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