1XEN_ROOT = $(CURDIR)/../..
2include $(XEN_ROOT)/tools/Rules.mk
3
4MAJOR    = 4.10
5MINOR    = 0
6
7ifeq ($(CONFIG_LIBXC_MINIOS),y)
8# Save/restore of a domain is currently incompatible with a stubdom environment
9override CONFIG_MIGRATE := n
10endif
11
12CTRL_SRCS-y       :=
13CTRL_SRCS-y       += xc_altp2m.c
14CTRL_SRCS-y       += xc_core.c
15CTRL_SRCS-$(CONFIG_X86) += xc_core_x86.c
16CTRL_SRCS-$(CONFIG_ARM) += xc_core_arm.c
17CTRL_SRCS-y       += xc_cpupool.c
18CTRL_SRCS-y       += xc_domain.c
19CTRL_SRCS-y       += xc_evtchn.c
20CTRL_SRCS-y       += xc_gnttab.c
21CTRL_SRCS-y       += xc_misc.c
22CTRL_SRCS-y       += xc_flask.c
23CTRL_SRCS-y       += xc_physdev.c
24CTRL_SRCS-y       += xc_private.c
25CTRL_SRCS-y       += xc_csched.c
26CTRL_SRCS-y       += xc_csched2.c
27CTRL_SRCS-y       += xc_arinc653.c
28CTRL_SRCS-y       += xc_rt.c
29CTRL_SRCS-y       += xc_tbuf.c
30CTRL_SRCS-y       += xc_pm.c
31CTRL_SRCS-y       += xc_cpu_hotplug.c
32CTRL_SRCS-y       += xc_resume.c
33CTRL_SRCS-y       += xc_tmem.c
34CTRL_SRCS-y       += xc_vm_event.c
35CTRL_SRCS-y       += xc_monitor.c
36CTRL_SRCS-y       += xc_mem_paging.c
37CTRL_SRCS-y       += xc_mem_access.c
38CTRL_SRCS-y       += xc_memshr.c
39CTRL_SRCS-y       += xc_hcall_buf.c
40CTRL_SRCS-y       += xc_foreign_memory.c
41CTRL_SRCS-y       += xc_kexec.c
42CTRL_SRCS-y       += xc_resource.c
43CTRL_SRCS-$(CONFIG_X86) += xc_psr.c
44CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
45CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
46CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c
47CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
48CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c
49CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_netbsd.c
50CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c
51CTRL_SRCS-y       += xc_evtchn_compat.c
52CTRL_SRCS-y       += xc_gnttab_compat.c
53CTRL_SRCS-y       += xc_devicemodel_compat.c
54
55GUEST_SRCS-y :=
56GUEST_SRCS-y += xg_private.c xc_suspend.c
57ifeq ($(CONFIG_MIGRATE),y)
58GUEST_SRCS-y += xc_sr_common.c
59GUEST_SRCS-$(CONFIG_X86) += xc_sr_common_x86.c
60GUEST_SRCS-$(CONFIG_X86) += xc_sr_common_x86_pv.c
61GUEST_SRCS-$(CONFIG_X86) += xc_sr_restore_x86_pv.c
62GUEST_SRCS-$(CONFIG_X86) += xc_sr_restore_x86_hvm.c
63GUEST_SRCS-$(CONFIG_X86) += xc_sr_save_x86_pv.c
64GUEST_SRCS-$(CONFIG_X86) += xc_sr_save_x86_hvm.c
65GUEST_SRCS-y += xc_sr_restore.c
66GUEST_SRCS-y += xc_sr_save.c
67GUEST_SRCS-y += xc_offline_page.c xc_compression.c
68else
69GUEST_SRCS-y += xc_nomigrate.c
70endif
71
72vpath %.c ../../xen/common/libelf
73CFLAGS += -I../../xen/common/libelf
74
75ELF_SRCS-y += libelf-tools.c libelf-loader.c
76ELF_SRCS-y += libelf-dominfo.c
77
78GUEST_SRCS-y += $(ELF_SRCS-y)
79
80$(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
81$(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
82
83# new domain builder
84GUEST_SRCS-y                 += xc_dom_core.c xc_dom_boot.c
85GUEST_SRCS-y                 += xc_dom_elfloader.c
86GUEST_SRCS-$(CONFIG_X86)     += xc_dom_bzimageloader.c
87GUEST_SRCS-$(CONFIG_X86)     += xc_dom_decompress_lz4.c
88GUEST_SRCS-$(CONFIG_X86)     += xc_dom_hvmloader.c
89GUEST_SRCS-$(CONFIG_ARM)     += xc_dom_armzimageloader.c
90GUEST_SRCS-y                 += xc_dom_binloader.c
91GUEST_SRCS-y                 += xc_dom_compat_linux.c
92
93GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c
94GUEST_SRCS-$(CONFIG_X86)     += xc_cpuid_x86.c
95GUEST_SRCS-$(CONFIG_ARM)     += xc_dom_arm.c
96
97ifeq ($(CONFIG_LIBXC_MINIOS),y)
98GUEST_SRCS-y                 += xc_dom_decompress_unsafe.c
99GUEST_SRCS-y                 += xc_dom_decompress_unsafe_bzip2.c
100GUEST_SRCS-y                 += xc_dom_decompress_unsafe_lzma.c
101GUEST_SRCS-y                 += xc_dom_decompress_unsafe_lzo1x.c
102GUEST_SRCS-y                 += xc_dom_decompress_unsafe_xz.c
103endif
104
105-include $(XEN_TARGET_ARCH)/Makefile
106
107CFLAGS   += -Werror -Wmissing-prototypes
108CFLAGS   += -I. -I./include $(CFLAGS_xeninclude)
109CFLAGS   += -D__XEN_TOOLS__
110
111# Needed for posix_fadvise64() in xc_linux.c
112CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
113
114CFLAGS	+= $(PTHREAD_CFLAGS)
115CFLAGS	+= $(CFLAGS_libxentoollog)
116CFLAGS	+= $(CFLAGS_libxenevtchn)
117CFLAGS	+= $(CFLAGS_libxendevicemodel)
118
119CTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y))
120CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y))
121
122GUEST_LIB_OBJS := $(patsubst %.c,%.o,$(GUEST_SRCS-y))
123GUEST_PIC_OBJS := $(patsubst %.c,%.opic,$(GUEST_SRCS-y))
124
125$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \
126$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
127
128# libxenguest includes xc_private.h, so needs this despite not using
129# this functionality directly.
130$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \
131$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): CFLAGS += $(CFLAGS_libxencall) $(CFLAGS_libxenforeignmemory)
132
133$(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS): CFLAGS += $(CFLAGS_libxengnttab)
134
135LIB := libxenctrl.a
136ifneq ($(nosharedlibs),y)
137LIB += libxenctrl.so libxenctrl.so.$(MAJOR) libxenctrl.so.$(MAJOR).$(MINOR)
138endif
139
140LIB += libxenguest.a
141ifneq ($(nosharedlibs),y)
142LIB += libxenguest.so libxenguest.so.$(MAJOR) libxenguest.so.$(MAJOR).$(MINOR)
143endif
144
145genpath-target = $(call buildmakevars2header,_paths.h)
146$(eval $(genpath-target))
147
148xc_private.h: _paths.h
149
150ifeq ($(CONFIG_X86),y)
151
152_xc_cpuid_autogen.h: $(XEN_ROOT)/xen/include/public/arch-x86/cpufeatureset.h $(XEN_ROOT)/xen/tools/gen-cpuid.py
153	$(PYTHON) $(XEN_ROOT)/xen/tools/gen-cpuid.py -i $^ -o $@.new
154	$(call move-if-changed,$@.new,$@)
155
156build: _xc_cpuid_autogen.h
157endif
158
159$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \
160$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): xc_private.h
161
162PKG_CONFIG := xencontrol.pc xenguest.pc
163PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
164
165ifneq ($(CONFIG_LIBXC_MINIOS),y)
166PKG_CONFIG_INST := $(PKG_CONFIG)
167$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
168$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
169$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
170endif
171
172PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
173
174$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
175$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_LIBXC)/include
176$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
177$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
178
179.PHONY: all
180all: build
181
182.PHONY: build
183build:
184	$(MAKE) libs
185
186.PHONY: libs
187libs: $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
188
189.PHONY: install
190install: build
191	$(INSTALL_DIR) $(DESTDIR)$(libdir)
192	$(INSTALL_DIR) $(DESTDIR)$(includedir)
193	$(INSTALL_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
194	$(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(libdir)
195	$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
196	$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenctrl.so
197	$(INSTALL_DATA) include/xenctrl.h include/xenctrl_compat.h $(DESTDIR)$(includedir)
198	$(INSTALL_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
199	$(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir)
200	$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
201	$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenguest.so
202	$(INSTALL_DATA) include/xenguest.h $(DESTDIR)$(includedir)
203	$(INSTALL_DATA) xencontrol.pc $(DESTDIR)$(PKG_INSTALLDIR)
204	$(INSTALL_DATA) xenguest.pc $(DESTDIR)$(PKG_INSTALLDIR)
205
206.PHONY: uninstall
207uninstall:
208	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenguest.pc
209	rm -f $(DESTDIR)$(includedir)/xenguest.h
210	rm -f $(DESTDIR)$(libdir)/libxenguest.so
211	rm -f $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
212	rm -f $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR).$(MINOR)
213	rm -f $(DESTDIR)$(libdir)/libxenguest.a
214	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xencontrol.pc
215	rm -f $(DESTDIR)$(includedir)/xenctrl.h
216	rm -f $(DESTDIR)$(includedir)/xenctrl_compat.h
217	rm -f $(DESTDIR)$(libdir)/libxenctrl.so
218	rm -f $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
219	rm -f $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR).$(MINOR)
220	rm -f $(DESTDIR)$(libdir)/libxenctrl.a
221
222.PHONY: TAGS
223TAGS:
224	etags -t *.c *.h
225
226.PHONY: clean
227clean:
228	rm -rf *.rpm $(LIB) *~ $(DEPS_RM) \
229            _paths.h \
230	    xencontrol.pc xenguest.pc \
231            $(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS) \
232            $(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS)
233
234.PHONY: distclean
235distclean: clean
236
237.PHONY: rpm
238rpm: build
239	rm -rf staging
240	mkdir staging
241	mkdir staging/i386
242	rpmbuild --define "staging$$PWD/staging" --define '_builddir.' \
243		--define "_rpmdir$$PWD/staging" -bb rpm.spec
244	mv staging/i386/*.rpm .
245	rm -rf staging
246
247# libxenctrl
248
249libxenctrl.a: $(CTRL_LIB_OBJS)
250	$(AR) rc $@ $^
251
252libxenctrl.so: libxenctrl.so.$(MAJOR)
253	$(SYMLINK_SHLIB) $< $@
254libxenctrl.so.$(MAJOR): libxenctrl.so.$(MAJOR).$(MINOR)
255	$(SYMLINK_SHLIB) $< $@
256
257libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS)
258	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(LDLIBS_libxendevicemodel) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
259
260# libxenguest
261
262libxenguest.a: $(GUEST_LIB_OBJS)
263	$(AR) rc $@ $^
264
265libxenguest.so: libxenguest.so.$(MAJOR)
266	$(SYMLINK_SHLIB) $< $@
267libxenguest.so.$(MAJOR): libxenguest.so.$(MAJOR).$(MINOR)
268	$(SYMLINK_SHLIB) $< $@
269
270ifeq ($(CONFIG_MiniOS),y)
271zlib-options =
272else
273zlib-options = $(ZLIB)
274endif
275
276xc_dom_bzimageloader.o: CFLAGS += $(filter -D%,$(zlib-options))
277xc_dom_bzimageloader.opic: CFLAGS += $(filter -D%,$(zlib-options))
278
279libxenguest.so.$(MAJOR).$(MINOR): COMPRESSION_LIBS = $(filter -l%,$(zlib-options))
280libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so
281	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
282
283-include $(DEPS_INCLUDE)
284
285