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                   += xen-bugtool
21INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
22INSTALL_SBIN-$(CONFIG_X86)     += xen-hvmcrash
23INSTALL_SBIN-$(CONFIG_X86)     += xen-hvmctx
24INSTALL_SBIN-$(CONFIG_X86)     += xen-lowmemd
25INSTALL_SBIN-$(CONFIG_X86)     += xen-mfndump
26INSTALL_SBIN                   += xen-ringwatch
27INSTALL_SBIN                   += xen-tmem-list-parse
28INSTALL_SBIN                   += xencov
29INSTALL_SBIN                   += xenlockprof
30INSTALL_SBIN                   += xenperf
31INSTALL_SBIN                   += xenpm
32INSTALL_SBIN                   += xenwatchdogd
33INSTALL_SBIN                   += xen-livepatch
34INSTALL_SBIN                   += xen-diag
35INSTALL_SBIN += $(INSTALL_SBIN-y)
36
37# Everything to be installed in a private bin/
38INSTALL_PRIVBIN                += xenpvnetboot
39
40# Everything to be installed
41TARGETS_ALL := $(INSTALL_BIN) $(INSTALL_SBIN) $(INSTALL_PRIVBIN)
42
43# Everything which only needs copying to install
44TARGETS_COPY += xen-bugtool
45TARGETS_COPY += xen-ringwatch
46TARGETS_COPY += xencons
47TARGETS_COPY += xencov_split
48TARGETS_COPY += xenpvnetboot
49
50# Everything which needs to be built
51TARGETS_BUILD := $(filter-out $(TARGETS_COPY),$(TARGETS_ALL))
52
53.PHONY: all build
54all build: $(TARGETS_BUILD)
55
56.PHONY: install
57install: build
58	$(INSTALL_DIR) $(DESTDIR)$(bindir)
59	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
60	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
61	$(INSTALL_PYTHON_PROG) $(INSTALL_BIN) $(DESTDIR)$(bindir)
62	$(INSTALL_PYTHON_PROG) $(INSTALL_SBIN) $(DESTDIR)$(sbindir)
63	$(INSTALL_PYTHON_PROG) $(INSTALL_PRIVBIN) $(DESTDIR)$(LIBEXEC_BIN)
64
65.PHONY: uninstall
66uninstall:
67	rm -f $(addprefix $(DESTDIR)$(LIBEXEC_BIN)/, $(INSTALL_PRIVBIN))
68	rm -f $(addprefix $(DESTDIR)$(sbindir)/, $(INSTALL_SBIN))
69	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(INSTALL_BIN))
70
71.PHONY: clean
72clean:
73	$(RM) *.o $(TARGETS_BUILD) *~ $(DEPS_RM)
74
75.PHONY: distclean
76distclean: clean
77
78xen-cpuid: xen-cpuid.o
79	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS)
80
81xen-hvmctx: xen-hvmctx.o
82	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
83
84xen-hvmcrash: xen-hvmcrash.o
85	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
86
87xenperf: xenperf.o
88	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
89
90xenpm: xenpm.o
91	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(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
101# xen-mfndump incorrectly uses libxc internals
102xen-mfndump.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
103xen-mfndump: xen-mfndump.o
104	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS)
105
106xenwatchdogd: xenwatchdogd.o
107	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
108
109xen-livepatch: xen-livepatch.o
110	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
111
112xen-diag: xen-diag.o
113	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
114
115xen-lowmemd: xen-lowmemd.o
116	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
117
118xencov: xencov.o
119	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
120
121-include $(DEPS_INCLUDE)
122