#
# Grand Unified Makefile for Xen.
#

#KERNELS ?= linux-2.6-xen
# You may use wildcards in the above e.g. KERNELS=*2.6*

#XKERNELS := $(foreach kernel, $(KERNELS), $(patsubst buildconfigs/mk.%,%,$(wildcard buildconfigs/mk.$(kernel))) )

# Export target architecture overrides to Xen and Linux sub-trees.
ifeq ($(XEN_TARGET_ARCH),arm)
ifndef XEN_TARGET_SUBARCH
$(error "Unknown platform")
endif
SUBARCH := $(subst arch-,,$(XEN_TARGET_SUBARCH))
endif

ifneq ($(XEN_TARGET_ARCH),)
SUBARCH := $(subst x86_32,i386,$(XEN_TARGET_ARCH))
export XEN_TARGET_ARCH SUBARCH XEN_SYSTYPE
endif

# Default target must appear before any include lines
all: dist

XEN_ROOT=$(CURDIR)
export XEN_ROOT
include Config.mk

ifeq ($(XEN_TARGET_X86_PAE),y)
export pae=y
endif

.PHONY:	all dist install xen kernels tools world clean
.PHONY:	mkpatches mrproper kbuild kdelete kclean

# build and install everything into the standard system directories
install: install-xen install-kernels install-tools 

# The test target is for unit tests that can run without an installation.  Of
# course, many tests require a machine running Xen itself, and these are
# handled elsewhere.
test:
#	$(MAKE) -C tools/python test

# build and install everything into local dist directory
dist: DESTDIR=$(DISTDIR)/install
dist: dist-xen dist-tools
dist-%: DESTDIR=$(DISTDIR)/install
dist-%: install-%
	@: # do nothing

# Legacy dist targets
xen: dist-xen
tools: dist-tools

install-xen:
	$(MAKE) -C xen

install-tools:
	$(MAKE) -C tools

# clean doesn't do a kclean
clean:: 
	$(MAKE) -C xen clean
	$(MAKE) -C tools clean

menuconfig:
	$(MAKE) -C xen menuconfig

