# vim: filetype=automake

VBOX_DRIVER_SOURCES = \
	vbox/vbox_glue.c \
	vbox/vbox_glue.h \
	vbox/vbox_driver.c \
	vbox/vbox_driver.h \
	vbox/vbox_snapshot_conf.c \
	vbox/vbox_snapshot_conf.h \
	vbox/vbox_V5_0.c \
	vbox/vbox_CAPI_v5_0.h \
	vbox/vbox_V5_1.c \
	vbox/vbox_CAPI_v5_1.h \
	vbox/vbox_V5_2.c \
	vbox/vbox_CAPI_v5_2.h \
	vbox/vbox_common.c \
	vbox/vbox_common.h \
	vbox/vbox_uniformed_api.h \
	vbox/vbox_get_driver.h \
	vbox/vbox_network.c \
	vbox/vbox_storage.c \
	$(NULL)

VBOX_DRIVER_EXTRA_DIST = \
	vbox/vbox_tmpl.c \
	vbox/README \
	vbox/vbox_MSCOMGlue.c \
	vbox/vbox_MSCOMGlue.h \
	vbox/vbox_XPCOMCGlue.c \
	vbox/vbox_XPCOMCGlue.h \
	$(NULL)

DRIVER_SOURCE_FILES += \
	$(VBOX_DRIVER_SOURCES) \
	vbox/vbox_tmpl.c \
	$(NULL)

EXTRA_DIST += \
	$(VBOX_DRIVER_SOURCES) \
	$(VBOX_DRIVER_EXTRA_DIST) \
	$(NULL)

if WITH_VBOX
noinst_LTLIBRARIES += libvirt_driver_vbox_impl.la
libvirt_driver_vbox_la_SOURCES =
libvirt_driver_vbox_la_LIBADD = \
	libvirt_driver_vbox_impl.la \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
mod_LTLIBRARIES += libvirt_driver_vbox.la
libvirt_driver_vbox_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)

libvirt_driver_vbox_impl_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	-DVBOX_DRIVER \
	$(NULL)
libvirt_driver_vbox_impl_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_vbox_impl_la_LIBADD = \
	$(DLOPEN_LIBS) \
	$(WIN32_EXTRA_LIBS) \
	$(LIBXML_LIBS) \
	$(NULL)
libvirt_driver_vbox_impl_la_SOURCES = $(VBOX_DRIVER_SOURCES)

sbin_PROGRAMS += virtvboxd

nodist_conf_DATA += vbox/virtvboxd.conf
augeas_DATA += vbox/virtvboxd.aug
augeastest_DATA += vbox/test_virtvboxd.aug
CLEANFILES += vbox/virtvboxd.aug

virtvboxd_SOURCES = $(REMOTE_DAEMON_SOURCES)
virtvboxd_CFLAGS = \
       $(REMOTE_DAEMON_CFLAGS) \
       -DDAEMON_NAME="\"virtvboxd\"" \
       -DMODULE_NAME="\"vbox\"" \
       $(NULL)
virtvboxd_LDFLAGS = $(REMOTE_DAEMON_LD_FLAGS)
virtvboxd_LDADD = $(REMOTE_DAEMON_LD_ADD)

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

VIRTVBOXD_UNIT_VARS = \
	$(VIRTD_UNIT_VARS) \
	-e 's|[@]name[@]|Libvirt vbox|g' \
	-e 's|[@]service[@]|virtvboxd|g' \
	-e 's|[@]sockprefix[@]|virtvboxd|g' \
	$(NULL)

virtvboxd.service: vbox/virtvboxd.service.in $(top_builddir)/config.status
	$(AM_V_GEN)$(SED) $(VIRTVBOXD_UNIT_VARS) $< > $@-t && mv $@-t $@

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

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

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

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

endif WITH_VBOX
