Files
buildroot/package/xen/xen.mk
Neal Frager 16462dee66 package/xen: fix build error when BR2_PACKAGE_XEN_TOOLS not enabled
The 0002-Update-linker-flags.patch assumes that the qemu-xen files are included
in the xen source tree. However, if BR2_PACKAGE_XEN_TOOLS is not enabled, the
qemu-xen dependency will not be handled and the patch will fail to apply with
the following error.

Fixes: build error below
Applying 0002-Update-linker-flags.patch using patch:
patching file tools/Makefile
Hunk #1 succeeded at 36 (offset -1 lines).
Hunk #2 succeeded at 185 (offset -8 lines).
can't find file to patch at input line 76
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/tools/qemu-xen/include/hw/xen/xen_native.h b/tools/qemu-xen/include/hw/xen/xen_native.h
|index 6bcc83ba..2590904e 100644
|--- a/tools/qemu-xen/include/hw/xen/xen_native.h
|+++ b/tools/qemu-xen/include/hw/xen/xen_native.h
--------------------------
No file to patch.  Skipping patch.
1 out of 1 hunk ignored
make: *** [package/pkg-generic.mk:239: output/build/xen-4.21.1/.stamp_patched] Error 1

To avoid making BR2_PACKAGE_XEN_TOOLS a required option, fix the
0002-Update-linker-flags.patch so that modifying source from the qemu-xen
package is no longer included.

Instead of patching qemu-xen, a better solution is undefining the
__XEN_INTERFACE_VERSION__ from the qemu-xen package.

To test:
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_AARCH64_GLIBC_STABLE=y
BR2_PACKAGE_XEN=y
 # BR2_PACKAGE_XEN_TOOLS is not set

Signed-off-by: Neal Frager <neal.frager@amd.com>
Tested-by: Matt Weber <matt@thewebers.ws>
Reviewed-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
(cherry picked from commit f63e572432)
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
2026-09-23 17:54:50 +02:00

95 lines
2.4 KiB
Makefile

################################################################################
#
# Xen
#
################################################################################
XEN_VERSION = 4.21.1
XEN_SITE = https://downloads.xenproject.org/release/xen/$(XEN_VERSION)
XEN_SELINUX_MODULES = systemd udev xen
XEN_LICENSE = GPL-2.0
XEN_LICENSE_FILES = COPYING LICENSES/GPL-2.0
XEN_CPE_ID_VENDOR = xen
XEN_CPE_ID_PREFIX = cpe:2.3:o
XEN_DEPENDENCIES = \
host-acpica \
host-meson \
host-pkgconf \
host-python3 \
host-python-distlib
# Calculate XEN_ARCH
ifeq ($(ARCH),aarch64)
XEN_ARCH = arm64
else ifeq ($(ARCH),arm)
XEN_ARCH = arm32
endif
XEN_CONF_OPTS = \
--disable-golang \
--disable-ocamltools \
--with-initddir=/etc/init.d \
--disable-werror
# Xen 4.20+ would normally fetch qemu-xen via git at build time; we
# pre-provide it via the qemu-xen package instead.
XEN_CONF_ENV = PYTHON=$(HOST_DIR)/bin/python3
XEN_MAKE_ENV = \
XEN_TARGET_ARCH=$(XEN_ARCH) \
CROSS_COMPILE=$(TARGET_CROSS) \
HOST_EXTRACFLAGS="-Wno-error" \
XEN_HAS_CHECKPOLICY=n \
$(TARGET_CONFIGURE_OPTS) \
EXTRA_CFLAGS_QEMU_XEN="-U__XEN_INTERFACE_VERSION__"
ifeq ($(BR2_PACKAGE_XEN_HYPERVISOR),y)
XEN_MAKE_OPTS += dist-xen
XEN_INSTALL_IMAGES = YES
define XEN_INSTALL_IMAGES_CMDS
cp $(@D)/xen/xen $(BINARIES_DIR)
endef
else
XEN_CONF_OPTS += --disable-xen
endif
ifeq ($(BR2_PACKAGE_XEN_TOOLS),y)
XEN_DEPENDENCIES += \
dtc \
libaio \
libglib2 \
ncurses \
openssl \
pixman \
qemu-xen \
slirp \
util-linux \
yajl
ifeq ($(BR2_PACKAGE_ARGP_STANDALONE),y)
XEN_DEPENDENCIES += argp-standalone
endif
XEN_INSTALL_TARGET_OPTS += DESTDIR=$(TARGET_DIR) install-tools
XEN_MAKE_OPTS += dist-tools
XEN_CONF_OPTS += --with-extra-qemuu-configure-args="--disable-sdl --disable-opengl"
# Place the pre-downloaded qemu-xen source where the Xen build expects it.
# This prevents Xen from trying to git-clone qemu-xen during the build.
# Use cp -a (not symlink) so meson can write into subprojects/.
define XEN_INSTALL_QEMU_XEN_SRC
rm -rf $(@D)/tools/qemu-xen
cp -a $(QEMU_XEN_DIR) $(@D)/tools/qemu-xen
endef
XEN_POST_EXTRACT_HOOKS += XEN_INSTALL_QEMU_XEN_SRC
define XEN_INSTALL_INIT_SYSV
mv $(TARGET_DIR)/etc/init.d/xencommons $(TARGET_DIR)/etc/init.d/S50xencommons
mv $(TARGET_DIR)/etc/init.d/xen-watchdog $(TARGET_DIR)/etc/init.d/S50xen-watchdog
mv $(TARGET_DIR)/etc/init.d/xendomains $(TARGET_DIR)/etc/init.d/S60xendomains
endef
else
XEN_INSTALL_TARGET = NO
XEN_CONF_OPTS += --disable-tools
endif
$(eval $(autotools-package))