1XEN_ROOT=$(CURDIR)/../..
2include $(XEN_ROOT)/tools/Rules.mk
3
4CFLAGS += -Werror
5# Include configure output (config.h)
6CFLAGS += -include $(XEN_ROOT)/tools/config.h
7CFLAGS += $(CFLAGS_libxenevtchn)
8CFLAGS += $(CFLAGS_libxenctrl)
9CFLAGS += $(CFLAGS_xeninclude)
10CFLAGS += $(CFLAGS_libxenstore)
11
12# Everything to be installed in regular bin/
13INSTALL_BIN-$(CONFIG_X86)      += xen-cpuid
14INSTALL_BIN-$(CONFIG_X86)      += xen-detect
15INSTALL_BIN                    += xencons
16INSTALL_BIN                    += xencov_split
17INSTALL_BIN += $(INSTALL_BIN-y)
18
19# Everything to be installed in regular sbin/
20INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
21INSTALL_SBIN-$(CONFIG_X86)     += xen-hvmcrash
22INSTALL_SBIN-$(CONFIG_X86)     += xen-hvmctx
23INSTALL_SBIN-$(CONFIG_X86)     += xen-lowmemd
24INSTALL_SBIN-$(CONFIG_X86)     += xen-mfndump
25INSTALL_SBIN-$(CONFIG_X86)     += xen-ucode
26INSTALL_SBIN                   += xencov
27INSTALL_SBIN                   += xenhypfs
28INSTALL_SBIN                   += xenlockprof
29INSTALL_SBIN                   += xenperf
30INSTALL_SBIN                   += xenpm
31INSTALL_SBIN                   += xenwatchdogd
32INSTALL_SBIN                   += xen-livepatch
33INSTALL_SBIN                   += xen-diag
34INSTALL_SBIN += $(INSTALL_SBIN-y)
35
36# Everything to be installed in a private bin/
37INSTALL_PRIVBIN                += xenpvnetboot
38
39# Everything to be installed
40TARGETS_ALL := $(INSTALL_BIN) $(INSTALL_SBIN) $(INSTALL_PRIVBIN)
41
42# Everything which only needs copying to install
43TARGETS_COPY += xencons
44TARGETS_COPY += xencov_split
45TARGETS_COPY += xenpvnetboot
46
47# Everything which needs to be built
48TARGETS_BUILD := $(filter-out $(TARGETS_COPY),$(TARGETS_ALL))
49
50.PHONY: all build
51all build: $(TARGETS_BUILD)
52
53.PHONY: install
54install: build
55	$(INSTALL_DIR) $(DESTDIR)$(bindir)
56	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
57	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
58	$(INSTALL_PYTHON_PROG) $(INSTALL_BIN) $(DESTDIR)$(bindir)
59	$(INSTALL_PYTHON_PROG) $(INSTALL_SBIN) $(DESTDIR)$(sbindir)
60	$(INSTALL_PYTHON_PROG) $(INSTALL_PRIVBIN) $(DESTDIR)$(LIBEXEC_BIN)
61
62.PHONY: uninstall
63uninstall:
64	rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(INSTALL_PRIVBIN))
65	rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(INSTALL_SBIN))
66	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(INSTALL_BIN))
67
68.PHONY: clean
69clean:
70	$(RM) *.o $(TARGETS_BUILD) *~ $(DEPS_RM)
71
72.PHONY: distclean
73distclean: clean
74
75xen-cpuid: xen-cpuid.o
76	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS)
77
78xen-hvmctx: xen-hvmctx.o
79	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
80
81xen-hvmcrash: xen-hvmcrash.o
82	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
83
84xenperf: xenperf.o
85	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
86
87xenpm: xenpm.o
88	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
89
90xenhypfs: xenhypfs.o
91	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenhypfs) $(APPEND_LDFLAGS)
92
93xenlockprof: xenlockprof.o
94	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
95
96# xen-hptool incorrectly uses libxc internals
97xen-hptool.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
98xen-hptool: xen-hptool.o
99	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
100
101xenhypfs.o: CFLAGS += $(CFLAGS_libxenhypfs)
102
103# xen-mfndump incorrectly uses libxc internals
104xen-mfndump.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
105xen-mfndump: xen-mfndump.o
106	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS)
107
108xenwatchdogd: xenwatchdogd.o
109	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
110
111xen-livepatch: xen-livepatch.o
112	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
113
114xen-diag: xen-diag.o
115	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
116
117xen-lowmemd: xen-lowmemd.o
118	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
119
120xencov: xencov.o
121	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
122
123xen-ucode: xen-ucode.o
124	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
125
126-include $(DEPS_INCLUDE)
127