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: build-tools
58build-tools: build-tools-public-headers
59	$(MAKE) -C tools build
60
61.PHONY: build-stubdom
62build-stubdom: mini-os-dir build-tools-public-headers
63	$(MAKE) -C stubdom build
64ifeq (x86_64,$(XEN_TARGET_ARCH))
65	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub
66endif
67
68.PHONY: build-docs
69build-docs:
70	$(MAKE) -C docs build
71
72# The test target is for unit tests that can run without an installation.  Of
73# course, many tests require a machine running Xen itself, and these are
74# handled elsewhere.
75.PHONY: test
76test:
77	$(MAKE) -C tools/python test
78
79# For most targets here,
80#   make COMPONENT-TARGET
81# is implemented, more or less, by
82#   make -C COMPONENT TARGET
83#
84# Each rule that does this needs to have dependencies on any
85# other COMPONENTs that have to be processed first.  See
86# The install-tools target here for an example.
87#
88# dist* targets are special: these do not occur in lower-level
89# Makefiles.  Instead, these are all implemented only here.
90# They run the appropriate install targets with DESTDIR set.
91#
92# Also, we have a number of targets COMPONENT which run
93# dist-COMPONENT, for convenience.
94#
95# The Makefiles invoked with -C from the toplevel should
96# generally have the following targets:
97#       all  build  install  clean  distclean
98
99
100.PHONY: dist
101dist: DESTDIR=$(DISTDIR)/install
102dist: $(TARGS_DIST) dist-misc
103
104dist-misc:
105	$(INSTALL_DIR) $(DISTDIR)/
106	$(INSTALL_DATA) ./COPYING $(DISTDIR)
107	$(INSTALL_DATA) ./README $(DISTDIR)
108	$(INSTALL_PROG) ./install.sh $(DISTDIR)
109
110
111dist-%: DESTDIR=$(DISTDIR)/install
112dist-%: install-%
113	@: # do nothing
114
115.PHONY: xen tools stubdom docs
116xen: dist-xen
117tools: dist-tools
118stubdom: dist-stubdom
119docs: dist-docs
120
121.PHONY: install-xen
122install-xen:
123	$(MAKE) -C xen install
124
125.PHONY: install-tools
126install-tools: install-tools-public-headers
127	$(MAKE) -C tools install
128
129.PHONY: install-stubdom
130install-stubdom: mini-os-dir install-tools-public-headers
131	$(MAKE) -C stubdom install
132ifeq (x86_64,$(XEN_TARGET_ARCH))
133	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom install-grub
134endif
135
136.PHONY: tools/firmware/seabios-dir-force-update
137tools/firmware/seabios-dir-force-update:
138	$(MAKE) -C tools/firmware seabios-dir-force-update
139
140.PHONY: tools/firmware/ovmf-dir-force-update
141tools/firmware/ovmf-dir-force-update:
142	$(MAKE) -C tools/firmware ovmf-dir-force-update
143
144.PHONY: install-docs
145install-docs:
146	$(MAKE) -C docs install
147
148# We only have build-tests install-tests, not uninstall-tests etc.
149.PHONY: build-tests
150build-tests: build-xen
151	export BASEDIR=$(XEN_ROOT)/xen; \
152	$(MAKE) -f $$BASEDIR/Rules.mk -C xen/test build
153
154.PHONY: install-tests
155install-tests: install-xen
156	export BASEDIR=$(XEN_ROOT)/xen; \
157	$(MAKE) -f $$BASEDIR/Rules.mk -C xen/test install
158
159# build xen and the tools and place them in the install
160# directory. 'make install' should then copy them to the normal system
161# directories
162.PHONY: world
163world:
164	$(MAKE) clean
165	$(MAKE) dist
166
167# Package a build in a debball file, that is inside a .deb format
168# container to allow for easy and clean removal. This is not intended
169# to be a full featured policy compliant .deb package.
170.PHONY: debball
171debball: dist
172	fakeroot sh ./tools/misc/mkdeb $(XEN_ROOT) $$($(MAKE) -C xen xenversion --no-print-directory)
173
174# Package a build in an rpmball file, that is inside a .rpm format
175# container to allow for easy and clean removal. This is not intended
176# to be a full featured policy compliant .rpm package.
177.PHONY: rpmball
178rpmball: dist
179	bash ./tools/misc/mkrpm $(XEN_ROOT) $$($(MAKE) -C xen xenversion --no-print-directory)
180
181.PHONY: subtree-force-update
182subtree-force-update: mini-os-dir-force-update
183	$(MAKE) -C tools subtree-force-update
184
185.PHONY: subtree-force-update-all
186subtree-force-update-all: mini-os-dir-force-update
187	$(MAKE) -C tools subtree-force-update-all
188
189# Make a source tarball, including qemu sub-trees.
190#
191# src-tarball will use "git describe" for the version number.  This
192# will have the most recent tag, number of commits since that tag, and
193# git commit id of the head.  This is suitable for a "snapshot"
194# tarball of an unreleased tree.
195#
196# src-tarball-release will use "make xenversion" as the version
197# number.  This is suitable for release tarballs.
198.PHONY: src-tarball-release
199src-tarball-release: subtree-force-update-all
200	bash ./tools/misc/mktarball $(XEN_ROOT) $$($(MAKE) -C xen xenversion --no-print-directory)
201
202.PHONY: src-tarball
203src-tarball: subtree-force-update-all
204	bash ./tools/misc/mktarball $(XEN_ROOT) $$(git describe)
205
206.PHONY: clean
207clean: $(TARGS_CLEAN)
208
209.PHONY: clean-xen
210clean-xen:
211	$(MAKE) -C xen clean
212
213.PHONY: clean-tools
214clean-tools: clean-tools-public-headers
215	$(MAKE) -C tools clean
216
217.PHONY: clean-stubdom
218clean-stubdom: clean-tools-public-headers
219	$(MAKE) -C stubdom crossclean
220ifeq (x86_64,$(XEN_TARGET_ARCH))
221	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom crossclean
222endif
223
224.PHONY: clean-docs
225clean-docs:
226	$(MAKE) -C docs clean
227
228# clean, but blow away tarballs
229.PHONY: distclean
230distclean: $(TARGS_DISTCLEAN)
231	$(MAKE) -C tools/include distclean
232	rm -f config/Toplevel.mk
233	rm -rf dist
234	rm -rf config.log config.status config.cache autom4te.cache
235
236.PHONY: distclean-xen
237distclean-xen:
238	$(MAKE) -C xen distclean
239
240.PHONY: distclean-tools
241distclean-tools:
242	$(MAKE) -C tools distclean
243
244.PHONY: distclean-stubdom
245distclean-stubdom:
246	$(MAKE) -C stubdom distclean
247ifeq (x86_64,$(XEN_TARGET_ARCH))
248	XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom distclean
249endif
250	rm -rf extras/mini-os extras/mini-os-remote
251
252.PHONY: distclean-docs
253distclean-docs:
254	$(MAKE) -C docs distclean
255
256# Linux name for GNU distclean
257.PHONY: mrproper
258mrproper: distclean
259
260.PHONY: help
261help:
262	@echo 'Installation targets:'
263	@echo '  install               - build and install everything'
264	@echo '  install-xen           - build and install the Xen hypervisor'
265	@echo '  install-tools         - build and install the control tools'
266	@echo '  install-stubdom       - build and install the stubdomain images'
267	@echo '  install-docs          - build and install user documentation'
268	@echo ''
269	@echo 'Local dist targets:'
270	@echo '  dist                  - build and install everything into local dist directory'
271	@echo '  world                 - clean everything then make dist'
272	@echo '  dist-xen              - build Xen hypervisor and install into local dist'
273	@echo '  dist-tools            - build the tools and install into local dist'
274	@echo '  dist-stubdom          - build the stubdomain images and install into local dist'
275	@echo '  dist-docs             - build user documentation and install into local dist'
276	@echo ''
277	@echo 'Building targets:'
278	@echo '  build                 - build everything'
279	@echo '  build-xen             - build Xen hypervisor'
280	@echo '  build-tools           - build the tools'
281	@echo '  build-stubdom         - build the stubdomain images'
282	@echo '  build-docs            - build user documentation'
283	@echo ''
284	@echo 'Cleaning targets:'
285	@echo '  clean                 - clean the Xen, tools and docs'
286	@echo '  distclean             - clean plus delete kernel build trees and'
287	@echo '                          local downloaded files'
288	@echo '  subtree-force-update  - Call *-force-update on all git subtrees (qemu, seabios, ovmf)'
289	@echo ''
290	@echo 'Miscellaneous targets:'
291	@echo '  uninstall             - attempt to remove installed Xen tools'
292	@echo '                          (use with extreme care!)'
293	@echo
294	@echo 'Trusted Boot (tboot) targets:'
295	@echo '  build-tboot           - download and build the tboot module'
296	@echo '  install-tboot         - download, build, and install the tboot module'
297	@echo '  clean-tboot           - clean the tboot module if it exists'
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	rm -rf $(D)/boot/tboot*
328
329.PHONY: xenversion
330xenversion:
331	@$(MAKE) --no-print-directory -C xen xenversion
332
333#
334# tboot targets
335#
336
337TBOOT_TARFILE = tboot-20090330.tar.gz
338#TBOOT_BASE_URL = http://downloads.sourceforge.net/tboot
339TBOOT_BASE_URL = $(XEN_EXTFILES_URL)
340
341.PHONY: build-tboot
342build-tboot: download_tboot
343	$(MAKE) -C tboot build
344
345.PHONY: install-tboot
346install-tboot: download_tboot
347	$(MAKE) -C tboot install
348
349.PHONY: dist-tboot
350dist-tboot: download_tboot
351	$(MAKE) DESTDIR=$(DISTDIR)/install -C tboot dist
352
353.PHONY: clean-tboot
354clean-tboot:
355	[ ! -d tboot ] || $(MAKE) -C tboot clean
356
357.PHONY: distclean-tboot
358distclean-tboot:
359	[ ! -d tboot ] || $(MAKE) -C tboot distclean
360
361.PHONY: download_tboot
362download_tboot: tboot/Makefile
363
364tboot/Makefile: tboot/$(TBOOT_TARFILE)
365	[ -e tboot/Makefile ] || tar -xzf tboot/$(TBOOT_TARFILE) -C tboot/ --strip-components 1
366
367tboot/$(TBOOT_TARFILE):
368	mkdir -p tboot
369	wget -O tboot/$(TBOOT_TARFILE) $(TBOOT_BASE_URL)/$(TBOOT_TARFILE)
370