build(libfdt): introduce include guards

In some build configurations the `libfdt.mk` file is included multiple
times. Due to the fact that rules cannot (or rather, should not) be
defined multiple times, the `MAKE_LIB` function (which this makefile
calls) cannot be called twice with the same inputs. Doing so leads to
warnings about overridden rules, e.g.:

    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt/fdt.o'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt/fdt.o'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt/fdt_addresses.o'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt/fdt_addresses.o'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt/fdt_empty_tree.o'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt/fdt_empty_tree.o'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt/fdt_ro.o'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt/fdt_ro.o'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt/fdt_rw.o'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt/fdt_rw.o'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt/fdt_strerror.o'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt/fdt_strerror.o'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt/fdt_sw.o'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt/fdt_sw.o'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target libfdt/fdt_wip.o'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target libfdt/fdt_wip.o'
    lib/libfdt/libfdt.mk:19: warning: overriding recipe for target lib/libfdt.a'
    lib/libfdt/libfdt.mk:19: warning: ignoring old recipe for target lib/libfdt.a'

This change introduces an include guard to the file to prevent it from
executing twice. This avoids redefining the rules defined by `MAKE_LIB`.

Change-Id: I07e0648b07dbd907eaa6dd6fbd0788203b19fddb
Signed-off-by: Chris Kay <chris.kay@arm.com>
diff --git a/lib/libfdt/libfdt.mk b/lib/libfdt/libfdt.mk
index 812057d..c7f5404 100644
--- a/lib/libfdt/libfdt.mk
+++ b/lib/libfdt/libfdt.mk
@@ -1,19 +1,23 @@
 #
-# Copyright (c) 2016, Arm Limited and Contributors. All rights reserved.
+# Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
 
-LIBFDT_SRCS	:=	$(addprefix lib/libfdt/,	\
-			fdt.c				\
-			fdt_addresses.c			\
-			fdt_empty_tree.c		\
-			fdt_ro.c			\
-			fdt_rw.c			\
-			fdt_strerror.c			\
-			fdt_sw.c			\
-			fdt_wip.c)			\
+ifndef libfdt-mk
+        libfdt-mk := 1
 
-INCLUDES	+=	-Iinclude/lib/libfdt
+        LIBFDT_SRCS := $(addprefix lib/libfdt/, \
+                fdt.c \
+                fdt_addresses.c \
+                fdt_empty_tree.c \
+                fdt_ro.c \
+                fdt_rw.c \
+                fdt_strerror.c \
+                fdt_sw.c \
+                fdt_wip.c)
+
+        INCLUDES += -Iinclude/lib/libfdt
 
-$(eval $(call MAKE_LIB,fdt))
+        $(eval $(call MAKE_LIB,fdt))
+endif