1XEN_ROOT=$(CURDIR)/../../..
2include $(XEN_ROOT)/tools/Rules.mk
3
4TARGETS := test-pdx-mask test-pdx-offset
5
6.PHONY: all
7all: $(TARGETS)
8
9.PHONY: run
10run: $(TARGETS)
11ifeq ($(CC),$(HOSTCC))
12	set -e;             \
13	for test in $? ; do \
14		./$$test ;  \
15	done
16else
17	$(warning HOSTCC != CC, will not run test)
18endif
19
20.PHONY: clean
21clean:
22	$(RM) -- *.o $(TARGETS) $(DEPS_RM) pdx.h
23
24.PHONY: distclean
25distclean: clean
26	$(RM) -- *~
27
28.PHONY: install
29install: all
30	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC)/tests
31	$(INSTALL_PROG) $(TARGETS) $(DESTDIR)$(LIBEXEC)/tests
32
33.PHONY: uninstall
34uninstall:
35	$(RM) -- $(patsubst %,$(DESTDIR)$(LIBEXEC)/tests/%,$(TARGETS))
36
37pdx.h: $(XEN_ROOT)/xen/include/xen/pdx.h
38	sed -E -e '/^#[[:space:]]*include/d' <$< >$@
39
40CFLAGS += -D__XEN_TOOLS__
41CFLAGS += $(APPEND_CFLAGS)
42CFLAGS += $(CFLAGS_xeninclude)
43
44test-pdx-mask: CFLAGS += -DCONFIG_PDX_MASK_COMPRESSION
45test-pdx-offset: CFLAGS += -DCONFIG_PDX_OFFSET_COMPRESSION
46
47test-pdx-%: test-pdx.c pdx.h
48	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -o $@ $< $(APPEND_CFLAGS)
49
50-include $(DEPS_INCLUDE)
51