From 96d1c8148bbc3d7fbe6438d34dbd0ceb85fab3ff Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Sat, 6 Feb 2021 22:40:28 +0100
Subject: Debian: only build XDP for amd64 architecture

---
 Makefile     |  2 +-
 debian/rules | 18 +++++++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index a984f88db..ad71219eb 100644
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,7 @@ vyxdp:
 	$(MAKE) -C $(XDP_DIR)
 
 .PHONY: all
-all: clean interface_definitions op_mode_definitions component_versions vyshim vyxdp
+all: clean interface_definitions op_mode_definitions component_versions vyshim
 
 .PHONY: clean
 clean:
diff --git a/debian/rules b/debian/rules
index ab0df7201..8e5aee3e6 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,6 +12,8 @@ MIGRATION_SCRIPTS_DIR := opt/vyatta/etc/config-migrate/migrate
 SYSTEM_SCRIPTS_DIR := usr/libexec/vyos/system
 SERVICES_DIR := usr/libexec/vyos/services
 
+DEB_TARGET_ARCH := $(shell dpkg-architecture -qDEB_TARGET_ARCH)
+
 %:
 	dh $@ --with python3, --with quilt
 
@@ -20,6 +22,10 @@ override_dh_gencontrol:
 
 override_dh_auto_build:
 	make all
+ifeq ($(DEB_TARGET_ARCH),amd64)
+	# Only build XDP on amd64 systems
+	make vyxdp
+endif
 
 override_dh_auto_install:
 	dh_auto_install
@@ -78,11 +84,6 @@ override_dh_auto_install:
 	mkdir -p $(DIR)/$(VYOS_DATA_DIR)
 	cp -r data/* $(DIR)/$(VYOS_DATA_DIR)
 
-	# Install XDP plugins
-	mkdir -p $(DIR)/$(VYOS_DATA_DIR)/xdp
-	cp -r src/xdp/xdp_prog_kern.o $(DIR)/$(VYOS_DATA_DIR)/xdp
-	find src/xdp -perm /a+x -exec cp {} $(DIR)/$(VYOS_SBIN_DIR) \;
-
 	# Install etc configuration files
 	mkdir -p $(DIR)/etc
 	cp -r src/etc/* $(DIR)/etc
@@ -109,3 +110,10 @@ override_dh_auto_install:
 	# Install system programs
 	mkdir -p $(DIR)/$(VYOS_BIN_DIR)
 	cp -r smoketest/bin/* $(DIR)/$(VYOS_BIN_DIR)
+
+ifeq ($(DEB_TARGET_ARCH),amd64)
+	# We only install XDP on amd64 systems
+	mkdir -p $(DIR)/$(VYOS_DATA_DIR)/xdp
+	cp -r src/xdp/xdp_prog_kern.o $(DIR)/$(VYOS_DATA_DIR)/xdp
+	find src/xdp -perm /a+x -exec cp {} $(DIR)/$(VYOS_SBIN_DIR) \;
+endif
-- 
cgit v1.2.3