# vim: filetype=automake

BHYVE_DRIVER_SOURCES = \
	bhyve/bhyve_capabilities.c \
	bhyve/bhyve_capabilities.h \
	bhyve/bhyve_command.c \
	bhyve/bhyve_command.h \
	bhyve/bhyve_conf.c \
	bhyve/bhyve_conf.h \
	bhyve/bhyve_parse_command.c \
	bhyve/bhyve_parse_command.h \
	bhyve/bhyve_device.c \
	bhyve/bhyve_device.h \
	bhyve/bhyve_domain.c \
	bhyve/bhyve_domain.h \
	bhyve/bhyve_driver.h \
	bhyve/bhyve_driver.c \
	bhyve/bhyve_monitor.c \
	bhyve/bhyve_monitor.h \
	bhyve/bhyve_process.c \
	bhyve/bhyve_process.h \
	bhyve/bhyve_utils.h \
	$(NULL)

DRIVER_SOURCE_FILES += $(BHYVE_DRIVER_SOURCES)
STATEFUL_DRIVER_SOURCE_FILES += $(BHYVE_DRIVER_SOURCES)

EXTRA_DIST += $(BHYVE_DRIVER_SOURCES)


if WITH_BHYVE
noinst_LTLIBRARIES += libvirt_driver_bhyve_impl.la
libvirt_driver_bhyve_la_SOURCES =
libvirt_driver_bhyve_la_LIBADD = \
	libvirt_driver_bhyve_impl.la \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
mod_LTLIBRARIES += libvirt_driver_bhyve.la
libvirt_driver_bhyve_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)

libvirt_driver_bhyve_impl_la_CFLAGS = \
	-I$(srcdir)/access \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)
libvirt_driver_bhyve_impl_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_bhyve_impl_la_SOURCES = $(BHYVE_DRIVER_SOURCES)

sbin_PROGRAMS += virtbhyved

nodist_conf_DATA += bhyve/virtbhyved.conf
augeas_DATA += bhyve/virtbhyved.aug
augeastest_DATA += bhyve/test_virtbhyved.aug
CLEANFILES += bhyve/virtbhyved.aug

virtbhyved_SOURCES = $(REMOTE_DAEMON_SOURCES)
virtbhyved_CFLAGS = \
       $(REMOTE_DAEMON_CFLAGS) \
       -DDAEMON_NAME="\"virtbhyved\"" \
       -DMODULE_NAME="\"bhyve\"" \
       $(NULL)
virtbhyved_LDFLAGS = $(REMOTE_DAEMON_LD_FLAGS)
virtbhyved_LDADD = $(REMOTE_DAEMON_LD_ADD)

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

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

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

conf_DATA += bhyve/bhyve.conf
augeas_DATA += bhyve/libvirtd_bhyve.aug
augeastest_DATA += bhyve/test_libvirtd_bhyve.aug

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

endif WITH_BHYVE

EXTRA_DIST += \
	bhyve/bhyve.conf \
	bhyve/libvirtd_bhyve.aug \
	bhyve/test_libvirtd_bhyve.aug.in \
	$(NULL)
