# vim: filetype=automake

STORAGE_DRIVER_BACKEND_SOURCES = \
	storage/storage_backend.h \
	storage/storage_backend.c \
	$(NULL)

STORAGE_DRIVER_SOURCES = \
	storage/storage_driver.h \
	storage/storage_driver.c \
	$(STORAGE_DRIVER_BACKEND_SOURCES) \
	storage/storage_util.h \
	storage/storage_util.c \
	$(NULL)

STORAGE_DRIVER_FS_SOURCES = \
	storage/storage_backend_fs.h \
	storage/storage_backend_fs.c \
	$(NULL)

STORAGE_FILE_FS_SOURCES = \
	storage/storage_file_fs.h \
	storage/storage_file_fs.c \
	$(NULL)

STORAGE_DRIVER_LVM_SOURCES = \
	storage/storage_backend_logical.h \
	storage/storage_backend_logical.c \
	$(NULL)

STORAGE_DRIVER_ISCSI_SOURCES = \
	storage/storage_backend_iscsi.h \
	storage/storage_backend_iscsi.c \
	$(NULL)

STORAGE_DRIVER_ISCSI_DIRECT_SOURCES = \
	storage/storage_backend_iscsi_direct.h \
	storage/storage_backend_iscsi_direct.c \
	$(NULL)

STORAGE_DRIVER_SCSI_SOURCES = \
	storage/storage_backend_scsi.h \
	storage/storage_backend_scsi.c \
	$(NULL)

STORAGE_DRIVER_MPATH_SOURCES = \
	storage/storage_backend_mpath.h \
	storage/storage_backend_mpath.c \
	$(NULL)

STORAGE_DRIVER_DISK_SOURCES = \
	storage/storage_backend_disk.h \
	storage/storage_backend_disk.c \
	$(NULL)

STORAGE_DRIVER_RBD_SOURCES = \
	storage/storage_backend_rbd.h \
	storage/storage_backend_rbd.c \
	$(NULL)

STORAGE_DRIVER_SHEEPDOG_SOURCES = \
	storage/storage_backend_sheepdog.h \
	storage/storage_backend_sheepdog.c \
	storage/storage_backend_sheepdog_priv.h \
	$(NULL)

STORAGE_DRIVER_GLUSTER_SOURCES = \
	storage/storage_backend_gluster.h \
	storage/storage_backend_gluster.c \
	$(NULL)

STORAGE_FILE_GLUSTER_SOURCES = \
	storage/storage_file_gluster.h \
	storage/storage_file_gluster.c \
	$(NULL)

STORAGE_DRIVER_ZFS_SOURCES = \
	storage/storage_backend_zfs.h \
	storage/storage_backend_zfs.c \
	$(NULL)

STORAGE_DRIVER_VSTORAGE_SOURCES = \
	storage/storage_backend_vstorage.h \
	storage/storage_backend_vstorage.c \
	$(NULL)

STORAGE_HELPER_DISK_SOURCES = \
	storage/parthelper.c \
	$(NULL)

DRIVER_SOURCE_FILES += $(STORAGE_DRIVER_SOURCES)
STATEFUL_DRIVER_SOURCE_FILES += $(STORAGE_DRIVER_SOURCES)
EXTRA_DIST += \
	$(STORAGE_DRIVER_SOURCES) \
	$(STORAGE_DRIVER_FS_SOURCES) \
	$(STORAGE_FILE_FS_SOURCES) \
	$(STORAGE_DRIVER_LVM_SOURCES) \
	$(STORAGE_DRIVER_ISCSI_SOURCES) \
	$(STORAGE_DRIVER_ISCSI_DIRECT_SOURCES) \
	$(STORAGE_DRIVER_SCSI_SOURCES) \
	$(STORAGE_DRIVER_MPATH_SOURCES) \
	$(STORAGE_DRIVER_DISK_SOURCES) \
	$(STORAGE_DRIVER_RBD_SOURCES) \
	$(STORAGE_DRIVER_SHEEPDOG_SOURCES) \
	$(STORAGE_DRIVER_GLUSTER_SOURCES) \
	$(STORAGE_FILE_GLUSTER_SOURCES) \
	$(STORAGE_DRIVER_ZFS_SOURCES) \
	$(STORAGE_DRIVER_VSTORAGE_SOURCES) \
	$(STORAGE_HELPER_DISK_SOURCES) \
	$(NULL)

storagebackenddir = $(libdir)/libvirt/storage-backend
storagebackend_LTLIBRARIES =

storagefiledir = $(libdir)/libvirt/storage-file
storagefile_LTLIBRARIES =

# Needed to keep automake quiet about conditionals
libvirt_driver_storage_impl_la_SOURCES =
libvirt_driver_storage_impl_la_CFLAGS = \
	-I$(srcdir)/access \
	-I$(srcdir)/conf \
	-I$(srcdir)/secret \
	$(AM_CFLAGS) \
	$(NULL)
libvirt_driver_storage_impl_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_storage_impl_la_LIBADD = $(SECDRIVER_LIBS) $(LIBXML_LIBS)
if WITH_BLKID
libvirt_driver_storage_impl_la_CFLAGS += $(BLKID_CFLAGS)
libvirt_driver_storage_impl_la_LIBADD += $(BLKID_LIBS)
endif WITH_BLKID

if WITH_STORAGE
noinst_LTLIBRARIES += libvirt_driver_storage_impl.la
libvirt_driver_storage_la_SOURCES =
libvirt_driver_storage_la_LIBADD = \
	libvirt_driver_storage_impl.la \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
mod_LTLIBRARIES += libvirt_driver_storage.la
libvirt_driver_storage_la_LDFLAGS = $(AM_LDFLAGS_MOD_NOUNDEF)
libvirt_driver_storage_impl_la_SOURCES += $(STORAGE_DRIVER_SOURCES)

sbin_PROGRAMS += virtstoraged

nodist_conf_DATA += storage/virtstoraged.conf
augeas_DATA += storage/virtstoraged.aug
augeastest_DATA += storage/test_virtstoraged.aug
CLEANFILES += storage/virtstoraged.aug

virtstoraged_SOURCES = $(REMOTE_DAEMON_SOURCES)
virtstoraged_CFLAGS = \
       $(REMOTE_DAEMON_CFLAGS) \
       -DDAEMON_NAME="\"virtstoraged\"" \
       -DMODULE_NAME="\"storage\"" \
       $(NULL)
virtstoraged_LDFLAGS = $(REMOTE_DAEMON_LD_FLAGS)
virtstoraged_LDADD = $(REMOTE_DAEMON_LD_ADD)

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

VIRTSTORAGED_UNIT_VARS = \
	$(VIRTD_UNIT_VARS) \
	-e 's|[@]name[@]|Libvirt storage|g' \
	-e 's|[@]service[@]|virtstoraged|g' \
	-e 's|[@]sockprefix[@]|virtstoraged|g' \
	$(NULL)

virtstoraged.service: storage/virtstoraged.service.in \
		$(top_builddir)/config.status
	$(AM_V_GEN)$(SED) $(VIRTSTORAGED_UNIT_VARS) $< > $@-t && mv $@-t $@

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

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

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

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


libvirt_storage_backend_fs_la_SOURCES = $(STORAGE_DRIVER_FS_SOURCES)
libvirt_storage_backend_fs_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_fs.la
libvirt_storage_backend_fs_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_fs_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)

libvirt_storage_file_fs_la_SOURCES = $(STORAGE_FILE_FS_SOURCES)
libvirt_storage_file_fs_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)

storagefile_LTLIBRARIES += libvirt_storage_file_fs.la
libvirt_storage_file_fs_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_file_fs_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
endif WITH_STORAGE

if WITH_STORAGE_LVM
libvirt_storage_backend_logical_la_SOURCES = $(STORAGE_DRIVER_LVM_SOURCES)
libvirt_storage_backend_logical_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_logical.la
libvirt_storage_backend_logical_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_logical_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
endif WITH_STORAGE_LVM

if WITH_STORAGE_ISCSI
libvirt_storage_backend_iscsi_la_SOURCES = $(STORAGE_DRIVER_ISCSI_SOURCES)
libvirt_storage_backend_iscsi_la_CFLAGS = \
	-I$(srcdir)/conf \
	-I$(srcdir)/secret \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_iscsi.la
libvirt_storage_backend_iscsi_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_iscsi_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
endif WITH_STORAGE_ISCSI

if WITH_STORAGE_ISCSI_DIRECT
libvirt_storage_backend_iscsi_direct_la_SOURCES = \
	$(STORAGE_DRIVER_ISCSI_DIRECT_SOURCES)
libvirt_storage_backend_iscsi_direct_la_CFLAGS = \
	-I$(srcdir)/conf \
	-I$(srcdir)/secret \
	$(LIBISCSI_CFLAGS) \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_iscsi-direct.la
libvirt_storage_backend_iscsi_direct_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_iscsi_direct_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(LIBISCSI_LIBS) \
	$(NULL)
endif WITH_STORAGE_ISCSI_DIRECT

if WITH_STORAGE_SCSI
libvirt_storage_backend_scsi_la_SOURCES = $(STORAGE_DRIVER_SCSI_SOURCES)
libvirt_storage_backend_scsi_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_scsi.la
libvirt_storage_backend_scsi_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_scsi_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
endif WITH_STORAGE_SCSI

if WITH_STORAGE_MPATH
libvirt_storage_backend_mpath_la_SOURCES = $(STORAGE_DRIVER_MPATH_SOURCES)
libvirt_storage_backend_mpath_la_LIBADD = \
	libvirt.la \
	$(DEVMAPPER_LIBS) \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
libvirt_storage_backend_mpath_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(DEVMAPPER_CFLAGS) \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_mpath.la
libvirt_storage_backend_mpath_la_LDFLAGS = $(AM_LDFLAGS_MOD)
endif WITH_STORAGE_MPATH

if WITH_STORAGE_DISK
libvirt_storage_backend_disk_la_SOURCES = $(STORAGE_DRIVER_DISK_SOURCES)
libvirt_storage_backend_disk_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_disk.la
libvirt_storage_backend_disk_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_disk_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
endif WITH_STORAGE_DISK

if WITH_STORAGE_RBD
libvirt_storage_backend_rbd_la_SOURCES = $(STORAGE_DRIVER_RBD_SOURCES)
libvirt_storage_backend_rbd_la_LIBADD = \
	libvirt.la \
	$(LIBRBD_LIBS) \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
libvirt_storage_backend_rbd_la_CFLAGS = \
	-I$(srcdir)/conf \
	-I$(srcdir)/secret \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_rbd.la
libvirt_storage_backend_rbd_la_LDFLAGS = $(AM_LDFLAGS_MOD)
endif WITH_STORAGE_RBD

if WITH_STORAGE_SHEEPDOG
libvirt_storage_backend_sheepdog_la_SOURCES = \
	$(STORAGE_DRIVER_SHEEPDOG_SOURCES)
libvirt_storage_backend_sheepdog_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)

libvirt_storage_backend_sheepdog_priv_la_SOURCES = \
	$(STORAGE_DRIVER_SHEEPDOG_SOURCES)
libvirt_storage_backend_sheepdog_priv_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)
noinst_LTLIBRARIES += libvirt_storage_backend_sheepdog_priv.la

storagebackend_LTLIBRARIES += libvirt_storage_backend_sheepdog.la
libvirt_storage_backend_sheepdog_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_sheepdog_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
endif WITH_STORAGE_SHEEPDOG

if WITH_STORAGE_GLUSTER
libvirt_storage_backend_gluster_la_SOURCES = \
	$(STORAGE_DRIVER_GLUSTER_SOURCES)
libvirt_storage_backend_gluster_la_LIBADD = \
	libvirt.la \
	$(GLUSTERFS_LIBS) \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
libvirt_storage_backend_gluster_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(GLUSTERFS_CFLAGS) \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_gluster.la
libvirt_storage_backend_gluster_la_LDFLAGS = $(AM_LDFLAGS_MOD)


libvirt_storage_file_gluster_la_SOURCES = \
	$(STORAGE_FILE_GLUSTER_SOURCES)
libvirt_storage_file_gluster_la_LIBADD = \
	libvirt.la \
	$(GLUSTERFS_LIBS) \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
libvirt_storage_file_gluster_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(GLUSTERFS_CFLAGS) \
	$(AM_CFLAGS) \
	$(NULL)

storagefile_LTLIBRARIES += libvirt_storage_file_gluster.la
libvirt_storage_file_gluster_la_LDFLAGS = $(AM_LDFLAGS_MOD)
endif WITH_STORAGE_GLUSTER

if WITH_STORAGE_ZFS
libvirt_storage_backend_zfs_la_SOURCES = \
	$(STORAGE_DRIVER_ZFS_SOURCES)
libvirt_storage_backend_zfs_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_zfs.la
libvirt_storage_backend_zfs_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_zfs_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
endif WITH_STORAGE_ZFS

if WITH_STORAGE_VSTORAGE
libvirt_storage_backend_vstorage_la_SOURCES = \
	$(STORAGE_DRIVER_VSTORAGE_SOURCES)
libvirt_storage_backend_vstorage_la_CFLAGS = \
	-I$(srcdir)/conf \
	$(AM_CFLAGS) \
	$(NULL)

storagebackend_LTLIBRARIES += libvirt_storage_backend_vstorage.la
libvirt_storage_backend_vstorage_la_LDFLAGS = $(AM_LDFLAGS_MOD)
libvirt_storage_backend_vstorage_la_LIBADD = \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
endif WITH_STORAGE_VSTORAGE

if WITH_STORAGE_DISK
libexec_PROGRAMS += libvirt_parthelper

libvirt_parthelper_SOURCES = $(STORAGE_HELPER_DISK_SOURCES)
libvirt_parthelper_LDFLAGS = \
	$(AM_LDFLAGS) \
	$(PIE_LDFLAGS) \
	$(NULL)
libvirt_parthelper_LDADD = \
	$(LIBPARTED_LIBS) \
	libvirt.la \
	$(GLIB_LIBS) \
	../gnulib/lib/libgnu.la \
	$(NULL)
if WITH_DTRACE_PROBES
libvirt_parthelper_LDADD += libvirt_probes.lo
endif WITH_DTRACE_PROBES

libvirt_parthelper_CFLAGS = \
	$(LIBPARTED_CFLAGS) \
	$(AM_CFLAGS) \
	$(PIE_CFLAGS) \
	$(NULL)
endif WITH_STORAGE_DISK
