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