1# 2# Grand Unified Makefile for Xen. 3# 4 5# Default target must appear before any include lines 6.PHONY: all 7all: dist 8 9-include config/Toplevel.mk 10SUBSYSTEMS?=xen tools stubdom docs 11TARGS_DIST=$(patsubst %, dist-%, $(SUBSYSTEMS)) 12TARGS_INSTALL=$(patsubst %, install-%, $(SUBSYSTEMS)) 13TARGS_UNINSTALL=$(patsubst %, uninstall-%, $(SUBSYSTEMS)) 14TARGS_BUILD=$(patsubst %, build-%, $(SUBSYSTEMS)) 15TARGS_CLEAN=$(patsubst %, clean-%, $(SUBSYSTEMS)) 16TARGS_DISTCLEAN=$(patsubst %, distclean-%, $(SUBSYSTEMS)) 17 18export XEN_ROOT=$(CURDIR) 19include Config.mk 20 21.PHONY: mini-os-dir 22mini-os-dir: 23 if [ ! -d $(XEN_ROOT)/extras/mini-os ]; then \ 24 GIT=$(GIT) $(XEN_ROOT)/scripts/git-checkout.sh \ 25 $(MINIOS_UPSTREAM_URL) \ 26 $(MINIOS_UPSTREAM_REVISION) \ 27 $(XEN_ROOT)/extras/mini-os ; \ 28 fi 29 30.PHONY: mini-os-dir-force-update 31mini-os-dir-force-update: mini-os-dir 32 set -ex; \ 33 if [ "$(MINIOS_UPSTREAM_REVISION)" ]; then \ 34 cd extras/mini-os-remote; \ 35 $(GIT) fetch origin; \ 36 $(GIT) reset --hard $(MINIOS_UPSTREAM_REVISION); \ 37 fi 38 39export XEN_TARGET_ARCH 40export DESTDIR 41 42.PHONY: %-tools-public-headers 43%-tools-public-headers: 44 $(MAKE) -C tools/include $* 45 46# build and install everything into the standard system directories 47.PHONY: install 48install: $(TARGS_INSTALL) 49 50.PHONY: build 51build: $(TARGS_BUILD) 52 53.PHONY: build-xen 54build-xen: 55 $(MAKE) -C xen build 56 57.PHONY: %_defconfig 58%_defconfig: 59 $(MAKE) -C xen $@ 60 61.PHONY: build-tools 62build-tools: build-tools-public-headers 63 $(MAKE) -C tools build 64 65.PHONY: build-stubdom 66build-stubdom: mini-os-dir build-tools-public-headers 67 $(MAKE) -C stubdom build 68ifeq (x86_64,$(XEN_TARGET_ARCH)) 69 XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub 70endif 71 72.PHONY: build-docs 73build-docs: 74 $(MAKE) -C docs build 75 76# The test target is for unit tests that can run without an installation. Of 77# course, many tests require a machine running Xen itself, and these are 78# handled elsewhere. 79.PHONY: test 80test: 81 $(MAKE) -C tools/python test 82 83run-tests-%: build-tools-public-headers tools/tests/%/ 84 $(MAKE) -C tools/tests/$* run 85 86# For most targets here, 87# make COMPONENT-TARGET 88# is implemented, more or less, by 89# make -C COMPONENT TARGET 90# 91# Each rule that does this needs to have dependencies on any 92# other COMPONENTs that have to be processed first. See 93# The install-tools target here for an example. 94# 95# dist* targets are special: these do not occur in lower-level 96# Makefiles. Instead, these are all implemented only here. 97# They run the appropriate install targets with DESTDIR set. 98# 99# Also, we have a number of targets COMPONENT which run 100# dist-COMPONENT, for convenience. 101# 102# The Makefiles invoked with -C from the toplevel should 103# generally have the following targets: 104# all build install clean distclean 105 106 107.PHONY: dist 108dist: DESTDIR=$(DISTDIR)/install 109dist: $(TARGS_DIST) dist-misc 110 111dist-misc: 112 $(INSTALL_DIR) $(DISTDIR)/ 113 $(INSTALL_DATA) ./COPYING $(DISTDIR) 114 $(INSTALL_DATA) ./README $(DISTDIR) 115 $(INSTALL_PROG) ./install.sh $(DISTDIR) 116 117 118dist-%: DESTDIR=$(DISTDIR)/install 119dist-%: install-% 120 @: # do nothing 121 122.PHONY: xen tools stubdom docs 123xen: dist-xen 124tools: dist-tools 125stubdom: dist-stubdom 126docs: dist-docs 127 128.PHONY: install-xen 129install-xen: 130 $(MAKE) -C xen install 131 132.PHONY: install-tools 133install-tools: install-tools-public-headers 134 $(MAKE) -C tools install 135 136.PHONY: install-stubdom 137install-stubdom: mini-os-dir install-tools 138 $(MAKE) -C stubdom install 139ifeq (x86_64,$(XEN_TARGET_ARCH)) 140 XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub 141endif 142 143.PHONY: tools/firmware/seabios-dir-force-update 144tools/firmware/seabios-dir-force-update: 145 $(MAKE) -C tools/firmware seabios-dir-force-update 146 147.PHONY: tools/firmware/ovmf-dir-force-update 148tools/firmware/ovmf-dir-force-update: 149 $(MAKE) -C tools/firmware ovmf-dir-force-update 150 151.PHONY: install-docs 152install-docs: 153 $(MAKE) -C docs install 154 155# We only have build-tests install-tests, not uninstall-tests etc. 156.PHONY: build-tests 157build-tests: build-xen 158 $(MAKE) -C xen tests 159 160.PHONY: install-tests 161install-tests: install-xen 162 $(MAKE) -C xen $@ 163 164# build xen and the tools and place them in the install 165# directory. 'make install' should then copy them to the normal system 166# directories 167.PHONY: world 168world: 169 $(MAKE) clean 170 $(MAKE) dist 171 172# Package a build in a debball file, that is inside a .deb format 173# container to allow for easy and clean removal. This is not intended 174# to be a full featured policy compliant .deb package. 175.PHONY: debball 176debball: dist 177 fakeroot sh ./tools/misc/mkdeb $(XEN_ROOT) $$($(MAKE) -C xen xenversion --no-print-directory) 178 179# Package a build in an rpmball file, that is inside a .rpm format 180# container to allow for easy and clean removal. This is not intended 181# to be a full featured policy compliant .rpm package. 182.PHONY: rpmball 183rpmball: dist 184 bash ./tools/misc/mkrpm $(XEN_ROOT) $$($(MAKE) -C xen xenversion --no-print-directory) 185 186.PHONY: subtree-force-update 187subtree-force-update: mini-os-dir-force-update 188 $(MAKE) -C tools subtree-force-update 189 190.PHONY: subtree-force-update-all 191subtree-force-update-all: mini-os-dir-force-update 192 $(MAKE) -C tools subtree-force-update-all 193 194# Make a source tarball, including qemu sub-trees. 195# 196# src-tarball will use "git describe" for the version number. This 197# will have the most recent tag, number of commits since that tag, and 198# git commit id of the head. This is suitable for a "snapshot" 199# tarball of an unreleased tree. 200# 201# src-tarball-release will use "make xenversion" as the version 202# number. This is suitable for release tarballs. 203.PHONY: src-tarball-release 204src-tarball-release: subtree-force-update-all 205 bash ./tools/misc/mktarball $(XEN_ROOT) $$($(MAKE) -C xen xenversion --no-print-directory) 206 207.PHONY: src-tarball 208src-tarball: subtree-force-update-all 209 bash ./tools/misc/mktarball $(XEN_ROOT) $$(git describe) 210 211.PHONY: clean 212clean: $(TARGS_CLEAN) 213 214.PHONY: clean-xen 215clean-xen: 216 $(MAKE) -C xen clean 217 218.PHONY: clean-tools 219clean-tools: clean-tools-public-headers 220 $(MAKE) -C tools clean 221 222.PHONY: clean-stubdom 223clean-stubdom: clean-tools-public-headers 224 $(MAKE) -C stubdom crossclean 225ifeq (x86_64,$(XEN_TARGET_ARCH)) 226 XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom crossclean 227endif 228 229.PHONY: clean-docs 230clean-docs: 231 $(MAKE) -C docs clean 232 233# clean, but blow away tarballs 234.PHONY: distclean 235distclean: $(TARGS_DISTCLEAN) 236 $(MAKE) -C tools/include distclean 237 rm -f config/Toplevel.mk 238 rm -rf dist 239 rm -rf config.log config.status config.cache autom4te.cache 240 241.PHONY: distclean-xen 242distclean-xen: 243 $(MAKE) -C xen distclean 244 245.PHONY: distclean-tools 246distclean-tools: 247 $(MAKE) -C tools distclean 248 249.PHONY: distclean-stubdom 250distclean-stubdom: 251 $(MAKE) -C stubdom distclean 252ifeq (x86_64,$(XEN_TARGET_ARCH)) 253 XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom distclean 254endif 255 rm -rf extras/mini-os extras/mini-os-remote 256 257.PHONY: distclean-docs 258distclean-docs: 259 $(MAKE) -C docs distclean 260 261# Linux name for GNU distclean 262.PHONY: mrproper 263mrproper: distclean 264 265.PHONY: help 266help: 267 @echo 'Installation targets:' 268 @echo ' install - build and install everything' 269 @echo ' install-xen - build and install the Xen hypervisor' 270 @echo ' install-tools - build and install the control tools' 271 @echo ' install-stubdom - build and install the stubdomain images' 272 @echo ' install-docs - build and install user documentation' 273 @echo '' 274 @echo 'Local dist targets:' 275 @echo ' dist - build and install everything into local dist directory' 276 @echo ' world - clean everything then make dist' 277 @echo ' dist-xen - build Xen hypervisor and install into local dist' 278 @echo ' dist-tools - build the tools and install into local dist' 279 @echo ' dist-stubdom - build the stubdomain images and install into local dist' 280 @echo ' dist-docs - build user documentation and install into local dist' 281 @echo '' 282 @echo 'Building targets:' 283 @echo ' build - build everything' 284 @echo ' build-xen - build Xen hypervisor' 285 @echo ' build-tools - build the tools' 286 @echo ' build-stubdom - build the stubdomain images' 287 @echo ' build-docs - build user documentation' 288 @echo '' 289 @echo 'Cleaning targets:' 290 @echo ' clean - clean the Xen, tools and docs' 291 @echo ' distclean - clean plus delete kernel build trees and' 292 @echo ' local downloaded files' 293 @echo ' subtree-force-update - Call *-force-update on all git subtrees (qemu, seabios, ovmf)' 294 @echo '' 295 @echo 'Miscellaneous targets:' 296 @echo ' uninstall - attempt to remove installed Xen tools' 297 @echo ' (use with extreme care!)' 298 @echo 299 @echo 'Package targets:' 300 @echo ' src-tarball-release - make a source tarball with xen and qemu tagged with a release' 301 @echo ' src-tarball - make a source tarball with xen and qemu tagged with git describe' 302 @echo 303 @echo 'Environment:' 304 @echo ' [ this documentation is sadly not complete ]' 305 306# Use this target with extreme care! 307 308.PHONY: uninstall-xen 309uninstall-xen: 310 $(MAKE) -C xen uninstall 311 312.PHONY: uninstall-tools 313uninstall-tools: 314 $(MAKE) -C tools uninstall 315 316.PHONY: uninstall-stubdom 317uninstall-stubdom: 318 $(MAKE) -C stubdom uninstall 319 320.PHONY: uninstall-docs 321uninstall-docs: 322 $(MAKE) -C docs uninstall 323 324.PHONY: uninstall 325uninstall: D=$(DESTDIR) 326uninstall: uninstall-tools-public-headers $(TARGS_UNINSTALL) 327 328.PHONY: xenversion 329xenversion: 330 @$(MAKE) --no-print-directory -C xen xenversion 331