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