1XEN_ROOT = $(CURDIR)/../..
2include $(XEN_ROOT)/tools/Rules.mk
3
4# Relative to $(XEN_ROOT)/xen/xsm/flask
5FLASK_H_DEPEND := policy/initial_sids
6
7.PHONY: all all-y build
8all build: all-y xen-foreign xen/.dir xen-xsm/.dir
9all-y:
10
11.PHONY: xen-foreign
12xen-foreign:
13	$(MAKE) -C xen-foreign
14
15XEN_PUBLIC_INCLUDES = $(wildcard $(XEN_ROOT)/xen/include/public/*.h)
16XEN_LIB_X86_INCLUDES = $(filter-out %autogen.h, $(XEN_ROOT)/xen/include/xen/lib/x86/Makefile $(wildcard $(XEN_ROOT)/xen/include/xen/lib/x86/*.h))
17
18xen/.dir: $(XEN_PUBLIC_INCLUDES) $(XEN_LIB_X86_INCLUDES)
19	@rm -rf xen
20	mkdir -p xen/libelf
21	ln -sf $(XEN_ROOT)/xen/include/public/COPYING xen
22	ln -sf $(XEN_PUBLIC_INCLUDES) xen
23	ln -sf $(addprefix $(XEN_ROOT)/xen/include/public/,arch-x86 arch-arm hvm io xsm) xen
24	ln -sf ../xen-sys/$(XEN_OS) xen/sys
25	ln -sf $(addprefix $(XEN_ROOT)/xen/include/xen/,libelf.h elfstructs.h) xen/libelf/
26	ln -s ../xen-foreign xen/foreign
27	ln -sf $(XEN_ROOT)/xen/include/acpi acpi
28ifeq ($(CONFIG_X86),y)
29	ln -sf $(XEN_ROOT)/xen/include/asm-x86 xen/asm
30	mkdir -p xen/lib/x86
31	for f in $(patsubst $(XEN_ROOT)/xen/include/xen/lib/x86/%,%,$(XEN_LIB_X86_INCLUDES)); do \
32		ln -sf $(XEN_ROOT)/xen/include/xen/lib/x86/$$f xen/lib/x86/$$f; \
33	done
34endif
35	touch $@
36
37all-$(CONFIG_X86): xen/.dir
38	$(MAKE) -C xen/lib/x86 all XEN_ROOT=$(XEN_ROOT) PYTHON=$(PYTHON)
39
40# Not xen/xsm as that clashes with link to
41# $(XEN_ROOT)/xen/include/public/xsm above.
42xen-xsm/.dir: $(XEN_ROOT)/xen/xsm/flask/policy/mkflask.sh \
43	      $(patsubst %,$(XEN_ROOT)/xen/xsm/flask/%,$(FLASK_H_DEPEND))
44	mkdir -p xen-xsm/flask
45	cd $(XEN_ROOT)/xen/xsm/flask/ && \
46		$(SHELL) policy/mkflask.sh $(AWK) $(CURDIR)/xen-xsm/flask $(FLASK_H_DEPEND)
47	touch $@
48
49.PHONY: install
50install: all
51	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/arch-x86
52	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/arch-x86/hvm
53	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/arch-arm
54	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/arch-arm/hvm
55	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/foreign
56	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/hvm
57	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/io
58	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/sys
59	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xen/xsm
60	$(INSTALL_DATA) xen/COPYING $(DESTDIR)$(includedir)/xen
61	$(INSTALL_DATA) xen/*.h $(DESTDIR)$(includedir)/xen
62	$(INSTALL_DATA) xen/arch-x86/*.h $(DESTDIR)$(includedir)/xen/arch-x86
63	$(INSTALL_DATA) xen/arch-x86/hvm/*.h $(DESTDIR)$(includedir)/xen/arch-x86/hvm
64
65# 	xen/arch-arm doesn't contains headers for now. Uncommented the line
66# 	as soon as a new header is added
67#	$(INSTALL_DATA) xen/arch-arm/*.h $(DESTDIR)$(includedir)/xen/arch-arm
68	$(INSTALL_DATA) xen/arch-arm/hvm/*.h $(DESTDIR)$(includedir)/xen/arch-arm/hvm
69	$(INSTALL_DATA) xen/foreign/*.h $(DESTDIR)$(includedir)/xen/foreign
70	$(INSTALL_DATA) xen/hvm/*.h $(DESTDIR)$(includedir)/xen/hvm
71	$(INSTALL_DATA) xen/io/*.h $(DESTDIR)$(includedir)/xen/io
72	$(INSTALL_DATA) xen/sys/*.h $(DESTDIR)$(includedir)/xen/sys
73	$(INSTALL_DATA) xen/xsm/*.h $(DESTDIR)$(includedir)/xen/xsm
74
75.PHONY: uninstall
76uninstall:
77	echo "[FIXME] uninstall headers"
78	rm -rf $(DESTDIR)$(includedir)/xen
79
80.PHONY: clean
81clean:
82	rm -rf xen xen-xsm acpi
83	$(MAKE) -C xen-foreign clean
84
85.PHONY: dist
86dist: install
87
88.PHONY: distclean
89distclean: clean
90