1XEN_ROOT = $(CURDIR)/../../.. 2include $(XEN_ROOT)/tools/Rules.mk 3 4OBJS-y += osdeps.o 5OBJS-y += libxl_paths.o 6OBJS-y += libxl_bootloader.o 7OBJS-y += flexarray.o 8ifeq ($(CONFIG_LIBNL),y) 9OBJS-y += libxl_netbuffer.o 10else 11OBJS-y += libxl_nonetbuffer.o 12endif 13ifeq ($(CONFIG_X86),y) 14OBJS-y += libxl_convert_callout.o 15else 16OBJS-y += libxl_no_convert_callout.o 17endif 18OBJS-y += libxl_remus.o 19OBJS-y += libxl_checkpoint_device.o 20OBJS-y += libxl_remus_disk_drbd.o 21ifeq ($(CONFIG_LIBNL),y) 22OBJS-y += libxl_colo_restore.o 23OBJS-y += libxl_colo_save.o 24OBJS-y += libxl_colo_qdisk.o 25OBJS-y += libxl_colo_proxy.o 26OBJS-y += libxl_colo_nic.o 27else 28OBJS-y += libxl_no_colo.o 29endif 30 31ACPI_PATH = $(XEN_ROOT)/tools/libacpi 32DSDT_FILES-$(CONFIG_X86) = dsdt_pvh.c 33ACPI_OBJS = $(patsubst %.c,%.o,$(DSDT_FILES-y)) build.o static_tables.o 34ACPI_PIC_OBJS = $(patsubst %.o,%.opic,$(ACPI_OBJS)) 35 36vpath build.c $(ACPI_PATH)/ 37vpath static_tables.c $(ACPI_PATH)/ 38 39OBJS-$(CONFIG_X86) += $(ACPI_OBJS) 40 41CFLAGS += -Wno-format-zero-length -Wmissing-declarations -Wformat-nonliteral 42 43CFLAGS-$(CONFIG_X86) += -DCONFIG_PCI_SUPP_LEGACY_IRQ 44 45OBJS-$(CONFIG_X86) += libxl_cpuid.o 46OBJS-$(CONFIG_X86) += libxl_x86.o 47OBJS-$(CONFIG_X86) += libxl_psr.o 48OBJS-$(CONFIG_X86) += libxl_x86_acpi.o 49OBJS-$(CONFIG_ARM) += libxl_nocpuid.o 50OBJS-$(CONFIG_ARM) += libxl_arm.o 51OBJS-$(CONFIG_ARM) += libxl_libfdt_compat.o 52ifeq ($(CONFIG_ARM_64),y) 53DSDT_FILES-y = dsdt_anycpu_arm.c 54OBJS-y += libxl_arm_acpi.o 55OBJS-y += $(DSDT_FILES-y:.c=.o) 56else 57OBJS-$(CONFIG_ARM) += libxl_arm_no_acpi.o 58endif 59 60OBJS-OS-$(CONFIG_NetBSD) = libxl_netbsd.o 61OBJS-OS-$(CONFIG_Linux) = libxl_linux.o libxl_setresuid.o 62OBJS-OS-$(CONFIG_FreeBSD) = libxl_freebsd.o libxl_setresuid.o 63ifeq ($(OBJS-OS-y),) 64$(error Your Operating System is not supported by libxenlight, \ 65please check libxl_linux.c and libxl_netbsd.c to see how to get it ported) 66endif 67OBJS-y += $(OBJS-OS-y) 68 69OBJS-y += libxl.o 70OBJS-y += libxl_create.o 71OBJS-y += libxl_dm.o 72OBJS-y += libxl_pci.o 73OBJS-y += libxl_dom.o 74OBJS-y += libxl_exec.o 75OBJS-y += libxl_xshelp.o 76OBJS-y += libxl_device.o 77OBJS-y += libxl_internal.o 78OBJS-y += libxl_utils.o 79OBJS-y += libxl_uuid.o 80OBJS-y += libxl_json.o 81OBJS-y += libxl_aoutils.o 82OBJS-y += libxl_numa.o 83OBJS-y += libxl_vnuma.o 84OBJS-y += libxl_stream_read.o 85OBJS-y += libxl_stream_write.o 86OBJS-y += libxl_save_callout.o 87OBJS-y += _libxl_save_msgs_callout.o 88OBJS-y += libxl_qmp.o 89OBJS-y += libxl_event.o 90OBJS-y += libxl_fork.o 91OBJS-y += libxl_dom_suspend.o 92OBJS-y += libxl_dom_save.o 93OBJS-y += libxl_usb.o 94OBJS-y += libxl_vtpm.o 95OBJS-y += libxl_nic.o 96OBJS-y += libxl_disk.o 97OBJS-y += libxl_console.o 98OBJS-y += libxl_cpupool.o 99OBJS-y += libxl_mem.o 100OBJS-y += libxl_sched.o 101OBJS-y += libxl_tmem.o 102OBJS-y += libxl_9pfs.o 103OBJS-y += libxl_domain.o 104OBJS-y += libxl_vdispl.o 105OBJS-y += libxl_pvcalls.o 106OBJS-y += libxl_vsnd.o 107OBJS-y += libxl_vkb.o 108OBJS-y += libxl_virtio.o 109OBJS-y += libxl_genid.o 110OBJS-y += _libxl_types.o 111OBJS-y += libxl_flask.o 112OBJS-y += _libxl_types_internal.o 113 114# Device tree overlay is enabled only for ARM architecture. 115OBJS-$(CONFIG_ARM) += libxl_dt_overlay.o 116 117ifeq ($(CONFIG_LIBNL),y) 118CFLAGS_LIBXL += $(LIBNL3_CFLAGS) 119endif 120CFLAGS_LIBXL += -Wshadow 121ifeq ($(debug),y) 122CFLAGS_LIBXL += -DCONFIG_DEBUG 123endif 124 125CFLAGS += $(PTHREAD_CFLAGS) 126LDFLAGS += $(PTHREAD_LDFLAGS) 127 128LIBXL_TESTS += timedereg 129LIBXL_TESTS_PROGS = $(LIBXL_TESTS) fdderegrace 130LIBXL_TESTS_INSIDE = $(LIBXL_TESTS) fdevent 131 132# Each entry FOO in LIBXL_TESTS has two main .c files: 133# libxl_test_FOO.c "inside libxl" code to support the test case 134# test_FOO.c "outside libxl" code to exercise the test case 135# Conventionally there will also be: 136# libxl_test_FOO.h interface between the "inside" and "outside" parts 137# The "inside libxl" file is compiled exactly like a piece of libxl, and the 138# "outside libxl" file is compiled exactly like a piece of application 139# code. They must share information via explicit libxl entrypoints. 140# Unlike proper parts of libxl, it is permissible for libxl_test_FOO.c 141# to use private global variables for its state. Note that all the 142# "inside" parts are compiled into a single test library, so their 143# symbol names must be unique. 144# 145# To run these tests, either use LD_PRELOAD to get libxenlight_test.so 146# loaded, or rename it to libxenlight.so so it is the target of the 147# appropriate symlinks. 148 149LIBXL_TEST_OBJS += $(foreach t, $(LIBXL_TESTS_INSIDE),libxl_test_$t.opic) 150TEST_PROG_OBJS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t.o) test_common.o 151TEST_PROGS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t) 152 153CLIENTS = testidl libxl-save-helper 154 155SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o 156 157LIBHEADER := libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_types_json.h libxl_utils.h libxl_uuid.h 158 159NO_HEADERS_CHK := y 160 161include $(XEN_ROOT)/tools/libs/libs.mk 162 163LDLIBS-y += $(UTIL_LIBS) 164LDLIBS-$(CONFIG_LIBNL) += $(LIBNL3_LIBS) 165LDLIBS-$(CONFIG_Linux) += -luuid 166LDLIBS-$(CONFIG_Linux) += -lrt 167LDLIBS-$(CONFIG_ARM) += -lfdt 168LDLIBS-y += $(PTHREAD_LIBS) 169LDLIBS-y += -lyajl 170LDLIBS += $(LDLIBS-y) 171 172$(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS): CFLAGS += $(CFLAGS_LIBXL) -include $(XEN_ROOT)/tools/config.h 173$(ACPI_OBJS) $(ACPI_PIC_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\" 174$(TEST_PROG_OBJS) _libxl.api-for-check: CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxentoolcore) 175libxl_x86_acpi.o libxl_x86_acpi.opic: CFLAGS += -iquote $(ACPI_PATH) 176$(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenguest) 177 178testidl.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight) 179testidl.c: libxl_types.idl gentest.py 180 $(PYTHON) gentest.py $< $@.new 181 mv -f $@.new $@ 182 183all: $(CLIENTS) $(TEST_PROGS) 184 185$(OBJS-y) $(PIC_OBJS) $(SAVE_HELPER_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS): libxl.api-ok 186 187$(DSDT_FILES-y): acpi 188 189# Depend on the source files generated by the "acpi" target even though 190# "build.o" don't needs them. It does need the generated headers. 191build.o build.opic: $(DSDT_FILES-y) 192 193libxl.api-ok: check-libxl-api-rules _libxl.api-for-check 194 $(PERL) $^ 195 touch $@ 196 197_libxl.api-for-check: $(XEN_INCLUDE)/libxl.h 198 $(CC) $(CPPFLAGS) $(CFLAGS) -c -E $< $(APPEND_CFLAGS) \ 199 -DLIBXL_EXTERNAL_CALLERS_ONLY=LIBXL_EXTERNAL_CALLERS_ONLY \ 200 >$@.new 201 mv -f $@.new $@ 202 203_libxl_save_msgs_helper.c _libxl_save_msgs_callout.c \ 204_libxl_save_msgs_helper.h _libxl_save_msgs_callout.h: \ 205 libxl_save_msgs_gen.pl 206 $(PERL) -w $< $@ >$@.new 207 $(call move-if-changed,$@.new,$@) 208 209# 210# headers dependencies on generated headers 211# 212$(XEN_INCLUDE)/libxl.h: $(XEN_INCLUDE)/_libxl_types.h 213$(XEN_INCLUDE)/libxl_json.h: $(XEN_INCLUDE)/_libxl_types_json.h 214libxl_internal.h: $(XEN_INCLUDE)/libxl.h $(XEN_INCLUDE)/libxl_json.h 215libxl_internal.h: _libxl_types_internal.h _libxl_types_private.h _libxl_types_internal_private.h 216libxl_internal.h: _libxl_save_msgs_callout.h 217 218# 219# objects dependencies on headers that depends on generated headers 220# 221$(TEST_PROG_OBJS): $(XEN_INCLUDE)/libxl.h 222$(OBJS-y) $(PIC_OBJS) $(LIBXL_TEST_OBJS): libxl_internal.h 223$(SAVE_HELPER_OBJS): $(XEN_INCLUDE)/libxl.h _libxl_save_msgs_helper.h 224testidl.o: $(XEN_INCLUDE)/libxl.h 225 226# This exploits the 'multi-target pattern rule' trick. 227# gentypes.py should be executed only once to make all the targets. 228_libxl_type%.h _libxl_type%_json.h _libxl_type%_private.h _libxl_type%.c: libxl_type%.idl gentypes.py idl.py 229 $(PYTHON) gentypes.py libxl_type$(*F).idl __libxl_type$(*F).h __libxl_type$(*F)_private.h \ 230 __libxl_type$(*F)_json.h __libxl_type$(*F).c 231 $(call move-if-changed,__libxl_type$(*F).h,_libxl_type$(*F).h) 232 $(call move-if-changed,__libxl_type$(*F)_private.h,_libxl_type$(*F)_private.h) 233 $(call move-if-changed,__libxl_type$(*F)_json.h,_libxl_type$(*F)_json.h) 234 $(call move-if-changed,__libxl_type$(*F).c,_libxl_type$(*F).c) 235 236.PRECIOUS: _libxl_type%.h _libxl_type%.c 237 238$(XEN_INCLUDE)/_libxl_%.h: _libxl_%.h 239 cp -f $< $@ 240 241.PHONY: acpi 242acpi: 243 $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES-y)" 244 245libxenlight_test.so: $(PIC_OBJS) $(LIBXL_TEST_OBJS) 246 $(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS) $(APPEND_LDFLAGS) 247 248test_%: test_%.o test_common.o libxenlight_test.so 249 $(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS) 250 251libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so 252 $(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS) 253 254testidl: testidl.o libxenlight.so 255 $(CC) $(LDFLAGS) -o $@ testidl.o $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS) 256 257install:: $(LIBHEADERS) libxl-save-helper 258 $(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN) 259 $(INSTALL_PROG) libxl-save-helper $(DESTDIR)$(LIBEXEC_BIN) 260 261uninstall:: 262 rm -f $(DESTDIR)$(LIBEXEC_BIN)/libxl-save-helper 263 264clean:: 265 $(RM) _*.h *.o $(CLIENTS) 266 $(RM) _*.c *.pyc _*.api-for-check 267 $(RM) testidl.c.new testidl.c *.api-ok 268 $(RM) $(TEST_PROGS) libxenlight_test.so libxl_test_*.opic 269 $(RM) -r __pycache__ 270 $(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean 271