1XEN_ROOT=$(CURDIR)/../../..
2include $(XEN_ROOT)/tools/Rules.mk
3
4ROOT = $(XEN_ROOT)/xen/include/public
5
6architectures := arm32 arm64 x86_32 x86_64
7headers := $(patsubst %, %.h, $(architectures))
8
9.PHONY: all clean distclean check-headers
10all: $(headers) check-headers
11
12clean:
13	rm -f $(headers)
14	rm -f checker checker.c
15	rm -f *.pyc *.o *~
16	rm -rf __pycache__
17
18distclean: clean
19
20checker: checker.c $(headers)
21	$(HOSTCC) $(HOSTCFLAGS) -D__XEN_TOOLS__ -o $@ $<
22
23check-headers: checker
24	./checker > tmp.size
25	diff -u reference.size tmp.size
26	rm tmp.size
27
28arm32.h: mkheader.py structs.py $(ROOT)/arch-arm.h $(ROOT)/xen.h
29	$(PYTHON) $< $(basename $@) $@.tmp $(filter %.h,$^)
30	#Avoid mixing an alignment directive with a uint64_t cast or sizeof expression
31	sed 's/(__align8__ \(uint64_t\))/(\1)/g' < $@.tmp > $@.tmp2
32	rm $@.tmp
33	$(call move-if-changed,$@.tmp2,$@)
34
35arm64.h: mkheader.py structs.py $(ROOT)/arch-arm.h $(ROOT)/xen.h
36	$(PYTHON) $< $(basename $@) $@.tmp $(filter %.h,$^)
37	#Avoid mixing an alignment directive with a uint64_t cast or sizeof expression
38	sed 's/(__align8__ \(uint64_t\))/(\1)/g' < $@.tmp > $@.tmp2
39	rm $@.tmp
40	$(call move-if-changed,$@.tmp2,$@)
41
42x86_32.h: mkheader.py structs.py $(ROOT)/arch-x86/xen-x86_32.h $(ROOT)/arch-x86/xen.h $(ROOT)/xen.h
43	$(PYTHON) $< $(basename $@) $@.tmp $(filter %.h,$^)
44	#Avoid mixing an alignment directive with a uint64_t cast or sizeof expression
45	sed 's/(__align8__ \(uint64_t\))/(\1)/g' < $@.tmp > $@.tmp2
46	rm $@.tmp
47	$(call move-if-changed,$@.tmp2,$@)
48
49x86_64.h: mkheader.py structs.py $(ROOT)/arch-x86/xen-x86_64.h $(ROOT)/arch-x86/xen.h $(ROOT)/xen.h
50	$(PYTHON) $< $(basename $@) $@.tmp $(filter %.h,$^)
51	#Avoid mixing an alignment directive with a uint64_t cast or sizeof expression
52	sed 's/(__align8__ \(uint64_t\))/(\1)/g' < $@.tmp > $@.tmp2
53	rm $@.tmp
54	$(call move-if-changed,$@.tmp2,$@)
55
56checker.c: mkchecker.py structs.py
57	$(PYTHON) $< $@ $(architectures)
58