[Pdbg] [PATCH 18/18] main: Conditionally build device trees based on arch

Amitay Isaacs amitay at ozlabs.org
Wed May 16 16:17:36 AEST 2018


From: Amitay Isaacs <amitay at gmail.com>

Signed-off-by: Amitay Isaacs <amitay at gmail.com>
---
 Makefile.am  | 18 ++++++++++++++----
 configure.ac |  3 +++
 src/main.c   | 19 ++++++++++++++-----
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a3a0331..6b0cbb1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,9 +8,18 @@ bin_PROGRAMS = pdbg
 ACLOCAL_AMFLAGS = -Im4
 AM_CFLAGS = -I$(top_srcdir)/ccan/array_size -Wall -Werror -O2
 
-DT = fake.dts \
-      p8-fsi.dts p8-i2c.dts p8-host.dts \
-      p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts p9-host.dts
+if TARGET_ARM
+DT_ARM = p8-fsi.dts p8-i2c.dts \
+	 p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts p9-kernel.dts
+ARCH_FLAGS="-DTARGET_ARM=1"
+endif
+
+if TARGET_PPC
+DT_PPC = p8-host.dts p9-host.dts
+ARCH_FLAGS="-DTARGET_PPC=1"
+endif
+
+DT = fake.dts $(DT_ARM) $(DT_PPC)
 
 DT_objects = $(DT:.dts=.dtb.o)
 DT_headers = $(DT:.dts=.dt.h)
@@ -25,7 +34,8 @@ pdbg_LDADD = $(DT_objects) libpdbg.la libfdt.la \
 	-L.libs
 
 pdbg_LDFLAGS = -Wl,--whole-archive,-lpdbg,--no-whole-archive
-pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\"
+pdbg_CFLAGS = -I$(top_srcdir)/libpdbg -Wall -Werror -DGIT_SHA1=\"${GIT_SHA1}\" \
+	      $(ARCH_FLAGS)
 
 lib_LTLIBRARIES = libpdbg.la libfdt.la
 
diff --git a/configure.ac b/configure.ac
index dcfbfde..3568535 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,4 +29,7 @@ case "$host" in
 esac
 AC_SUBST([ARCH])
 
+AM_CONDITIONAL([TARGET_ARM], [test x"$ARCH" = "xarm"])
+AM_CONDITIONAL([TARGET_PPC], [test x"$ARCH" = "xppc"])
+
 AC_OUTPUT
diff --git a/src/main.c b/src/main.c
index b007728..2d9c11c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -50,15 +50,19 @@
 
 #include "fake.dt.h"
 
+#ifdef TARGET_ARM
 #include "p8-i2c.dt.h"
 #include "p8-fsi.dt.h"
-#include "p8-host.dt.h"
-
 #include "p9w-fsi.dt.h"
 #include "p9r-fsi.dt.h"
 #include "p9z-fsi.dt.h"
 #include "p9-kernel.dt.h"
+#endif
+
+#ifdef TARGET_PPC
+#include "p8-host.dt.h"
 #include "p9-host.dt.h"
+#endif
 
 #define THREADS_PER_CORE	8
 
@@ -364,6 +368,7 @@ static int target_selection(void)
 	struct pdbg_target *fsi, *pib, *chip, *thread;
 
 	switch (backend) {
+#ifdef TARGET_ARM
 	case I2C:
 		pdbg_targets_init(&_binary_p8_i2c_dtb_o_start);
 		break;
@@ -391,10 +396,9 @@ static int target_selection(void)
 		pdbg_targets_init(&_binary_p9_kernel_dtb_o_start);
 		break;
 
-	case FAKE:
-		pdbg_targets_init(&_binary_fake_dtb_o_start);
-		break;
+#endif
 
+#ifdef TARGET_PPC
 	case HOST:
 		if (device_node == NULL) {
 			PR_ERROR("Host backend requires a device type\n");
@@ -409,6 +413,11 @@ static int target_selection(void)
 			return -1;
 		}
 		break;
+#endif
+
+	case FAKE:
+		pdbg_targets_init(&_binary_fake_dtb_o_start);
+		break;
 
 	default:
 		PR_ERROR("Invalid backend specified\n");
-- 
2.17.0



More information about the Pdbg mailing list