# vim: filetype=automake

QEMU_DRIVER_SOURCES = \
	qemu/qemu_agent.c \
	qemu/qemu_agent.h \
	qemu/qemu_alias.c \
	qemu/qemu_alias.h \
	qemu/qemu_block.c \
	qemu/qemu_block.h \
	qemu/qemu_blockjob.c \
	qemu/qemu_blockjob.h \
	qemu/qemu_capabilities.c \
	qemu/qemu_capabilities.h \
	qemu/qemu_command.c \
	qemu/qemu_command.h \
	qemu/qemu_dbus.c \
	qemu/qemu_dbus.h \
	qemu/qemu_domain.c \
	qemu/qemu_domain.h \
	qemu/qemu_domain_address.c \
	qemu/qemu_domain_address.h \
	qemu/qemu_cgroup.c \
	qemu/qemu_cgroup.h \
	qemu/qemu_extdevice.c \
	qemu/qemu_extdevice.h \
	qemu/qemu_firmware.c \
	qemu/qemu_firmware.h \
	qemu/qemu_hostdev.c \
	qemu/qemu_hostdev.h \
	qemu/qemu_hotplug.c \
	qemu/qemu_hotplug.h \
	qemu/qemu_hotplugpriv.h \
	qemu/qemu_conf.c \
	qemu/qemu_conf.h \
	qemu/qemu_interop_config.c \
	qemu/qemu_interop_config.h \
	qemu/qemu_process.c \
	qemu/qemu_process.h \
	qemu/qemu_processpriv.h \
	qemu/qemu_migration.c \
	qemu/qemu_migration.h \
	qemu/qemu_migration_cookie.c \
	qemu/qemu_migration_cookie.h \
	qemu/qemu_migration_params.c \
	qemu/qemu_migration_params.h \
	qemu/qemu_migration_paramspriv.h \
	qemu/qemu_monitor.c \
	qemu/qemu_monitor.h \
	qemu/qemu_monitor_priv.h \
	qemu/qemu_monitor_text.c \
	qemu/qemu_monitor_text.h \
	qemu/qemu_monitor_json.c \
	qemu/qemu_monitor_json.h \
	qemu/qemu_driver.c \
	qemu/qemu_driver.h \
	qemu/qemu_interface.c \
	qemu/qemu_interface.h \
	qemu/qemu_capspriv.h \
	qemu/qemu_security.c \
	qemu/qemu_security.h \
	qemu/qemu_qapi.c \
	qemu/qemu_qapi.h \
	qemu/qemu_slirp.c \
	qemu/qemu_slirp.h \
	qemu/qemu_tpm.c \
	qemu/qemu_tpm.h \
	qemu/qemu_vhost_user.c \
	qemu/qemu_vhost_user.h \
	qemu/qemu_vhost_user_gpu.c \
	qemu/qemu_vhost_user_gpu.h \
	qemu/qemu_checkpoint.c \
	qemu/qemu_checkpoint.h \
	$(NULL)


DRIVER_SOURCE_FILES += $(QEMU_DRIVER_SOURCES)
STATEFUL_DRIVER_SOURCE_FILES += $(QEMU_DRIVER_SOURCES)
EXTRA_DIST += $(QEMU_DRIVER_SOURCES)

if WITH_QEMU
noinst_LTLIBRARIES += libvirt_driver_qemu_impl.la
libvirt_driver_qemu_la_SOURCES =
libvirt_driver_qemu_la_LIBADD = \
	libvirt_driver_qemu_impl.la \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
mod_LTLIBRARIES += libvirt_driver_qemu.la
libvirt_driver_qemu_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)

libvirt_driver_qemu_impl_la_CFLAGS = \
	$(GNUTLS_CFLAGS) \
	$(LIBNL_CFLAGS) \
	$(SELINUX_CFLAGS) \
	$(XDR_CFLAGS) \
	-I$(srcdir)/access \
	-I$(srcdir)/conf \
	-I$(srcdir)/secret \
	$(AM_CFLAGS) \
	$(NULL)
libvirt_driver_qemu_impl_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_qemu_impl_la_LIBADD = \
	$(CAPNG_LIBS) \
	$(GNUTLS_LIBS) \
	$(LIBNL_LIBS) \
	$(SELINUX_LIBS) \
	$(LIBXML_LIBS) \
	$(NULL)
libvirt_driver_qemu_impl_la_SOURCES = $(QEMU_DRIVER_SOURCES)

if WITH_DTRACE_PROBES
libvirt_driver_qemu_la_LIBADD += libvirt_qemu_probes.lo
nodist_libvirt_driver_qemu_la_SOURCES = libvirt_qemu_probes.h
BUILT_SOURCES += libvirt_qemu_probes.h

tapset_DATA += libvirt_qemu_probes.stp

CLEANFILES += \
	libvirt_qemu_probes.h \
	libvirt_qemu_probes.o \
	libvirt_qemu_probes.lo \
	libvirt_qemu_probes.stp \
	$(NULL)

endif WITH_DTRACE_PROBES

sbin_PROGRAMS += virtqemud

nodist_conf_DATA += qemu/virtqemud.conf
augeas_DATA += qemu/virtqemud.aug
augeastest_DATA += qemu/test_virtqemud.aug
CLEANFILES += qemu/virtqemud.aug

virtqemud_SOURCES = $(REMOTE_DAEMON_SOURCES)
virtqemud_CFLAGS = \
       $(REMOTE_DAEMON_CFLAGS) \
       -DDAEMON_NAME="\"virtqemud\"" \
       -DMODULE_NAME="\"qemu\"" \
       $(NULL)
virtqemud_LDFLAGS = $(REMOTE_DAEMON_LD_FLAGS)
virtqemud_LDADD = $(REMOTE_DAEMON_LD_ADD)

SYSTEMD_UNIT_FILES += \
	virtqemud.service \
	virtqemud.socket \
	virtqemud-ro.socket \
	virtqemud-admin.socket \
	$(NULL)
SYSTEMD_UNIT_FILES_IN += \
	qemu/virtqemud.service.in \
	$(NULL)

VIRTQEMUD_UNIT_VARS = \
	$(VIRTD_UNIT_VARS) \
	-e 's|[@]name[@]|Libvirt qemu|g' \
	-e 's|[@]service[@]|virtqemud|g' \
	-e 's|[@]sockprefix[@]|virtqemud|g' \
	$(NULL)

virtqemud.service: qemu/virtqemud.service.in $(top_builddir)/config.status
	$(AM_V_GEN)$(SED) $(VIRTQEMUD_UNIT_VARS) $< > $@-t && mv $@-t $@

virtqemu%.socket: remote/libvirt%.socket.in $(top_builddir)/config.status
	$(AM_V_GEN)$(SED) $(VIRTQEMUD_UNIT_VARS) $< > $@-t && mv $@-t $@

qemu/virtqemud.conf: remote/libvirtd.conf.in
	$(AM_V_GEN)$(SED) \
		-e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
		-e 's/[@]DAEMON_NAME[@]/virtqemud/' \
		$< > $@

qemu/virtqemud.aug: remote/libvirtd.aug.in
	$(AM_V_GEN)$(SED) \
		-e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
		-e 's/[@]DAEMON_NAME[@]/virtqemud/' \
		-e 's/[@]DAEMON_NAME_UC[@]/Virtqemud/' \
		$< > $@

qemu/test_virtqemud.aug: remote/test_libvirtd.aug.in \
		qemu/virtqemud.conf $(AUG_GENTEST_SCRIPT)
	$(AM_V_GEN)$(AUG_GENTEST) qemu/virtqemud.conf \
		$(srcdir)/remote/test_libvirtd.aug.in | \
		$(SED) \
		-e '/[@]CUT_ENABLE_IP[@]/,/[@]END[@]/d' \
		-e 's/[@]DAEMON_NAME[@]/virtqemud/' \
		-e 's/[@]DAEMON_NAME_UC[@]/Virtqemud/' \
		> $@ || rm -f $@

conf_DATA += qemu/qemu.conf

augeas_DATA += qemu/libvirtd_qemu.aug
augeastest_DATA += qemu/test_libvirtd_qemu.aug

qemu/test_libvirtd_qemu.aug: qemu/test_libvirtd_qemu.aug.in \
		$(srcdir)/qemu/qemu.conf $(AUG_GENTEST_SCRIPT)
	$(AM_V_GEN)$(AUG_GENTEST) $(srcdir)/qemu/qemu.conf $< > $@

INSTALL_DATA_DIRS += qemu

install-data-qemu:
	$(MKDIR_P) -m 0751 "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu"
	$(MKDIR_P) "$(DESTDIR)$(runstatedir)/libvirt/qemu"
	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/libvirt/qemu"
	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/libvirt/qemu"
	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/swtpm"
	$(MKDIR_P) "$(DESTDIR)$(runstatedir)/libvirt/qemu/swtpm"
	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/log/swtpm/libvirt/qemu"

uninstall-data-qemu:
	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/qemu" ||:
	rmdir "$(DESTDIR)$(runstatedir)/libvirt/qemu" ||:
	rmdir "$(DESTDIR)$(localstatedir)/cache/libvirt/qemu" ||:
	rmdir "$(DESTDIR)$(localstatedir)/log/libvirt/qemu" ||:
	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/swtpm"
	rmdir "$(DESTDIR)$(runstatedir)/libvirt/qemu/swtpm" ||:
	rmdir "$(DESTDIR)$(localstatedir)/log/swtpm/libvirt/qemu" ||:

endif WITH_QEMU

.PHONY: \
	install-data-qemu \
	uninstall-data-qemu \
	$(NULL)

EXTRA_DIST += \
	qemu/qemu.conf \
	qemu/libvirtd_qemu.aug \
	qemu/test_libvirtd_qemu.aug.in \
	qemu/THREADS.txt \
	libvirt_qemu_probes.d \
	$(NULL)
