# vim: filetype=automake

# These files are not related to driver APIs. Simply generic
# helper APIs for various purposes
UTIL_SOURCES = \
	util/glibcompat.c \
	util/glibcompat.h \
	util/viralloc.c \
	util/viralloc.h \
	util/virarch.c \
	util/virarch.h \
	util/virarptable.c \
	util/virarptable.h \
	util/viratomic.c \
	util/viratomic.h \
	util/viraudit.c \
	util/viraudit.h \
	util/virauth.c \
	util/virauth.h \
	util/virauthconfig.c \
	util/virauthconfig.h \
	util/virbitmap.c \
	util/virbitmap.h \
	util/virbuffer.c \
	util/virbuffer.h \
	util/virperf.c \
	util/virperf.h \
	util/vircgroup.c \
	util/vircgroup.h util/vircgrouppriv.h \
	util/vircgroupbackend.c \
	util/vircgroupbackend.h \
	util/vircgroupv1.c \
	util/vircgroupv1.h \
	util/vircgroupv2.c \
	util/vircgroupv2.h \
	util/virclosecallbacks.c \
	util/virclosecallbacks.h \
	util/vircommand.c \
	util/vircommand.h \
	util/vircommandpriv.h \
	util/virconf.c \
	util/virconf.h \
	util/vircrypto.c \
	util/vircrypto.h \
	util/virdbus.c \
	util/virdbus.h \
	util/virdbuspriv.h \
	util/virdevmapper.c \
	util/virdevmapper.h \
	util/virdnsmasq.c \
	util/virdnsmasq.h \
	util/virebtables.c \
	util/virebtables.h \
	util/virendian.h \
	util/virenum.h \
	util/virenum.c \
	util/virerror.c \
	util/virerror.h \
	util/virerrorpriv.h \
	util/virevent.c \
	util/virevent.h \
	util/vireventpoll.c \
	util/vireventpoll.h \
	util/virfcp.c \
	util/virfcp.h \
	util/virfdstream.c \
	util/virfdstream.h \
	util/virfile.c \
	util/virfile.h \
	util/virfirewall.c \
	util/virfirewall.h \
	util/virfirewallpriv.h \
	util/virfirewalld.c \
	util/virfirewalld.h \
	util/virfirewalldpriv.h \
	util/virfirmware.c \
	util/virfirmware.h \
	util/virgettext.c \
	util/virgettext.h \
	util/virgic.c \
	util/virgic.h \
	util/virhash.c \
	util/virhash.h \
	util/virhashcode.c \
	util/virhashcode.h \
	util/virhook.c \
	util/virhook.h \
	util/virhostcpu.c \
	util/virhostcpu.h \
	util/virhostcpupriv.h \
	util/virhostdev.c \
	util/virhostdev.h \
	util/virhostmem.c \
	util/virhostmem.h \
	util/virhostuptime.c \
	util/virhostuptime.h \
	util/viridentity.c \
	util/viridentity.h \
	util/virinitctl.c \
	util/virinitctl.h \
	util/viriptables.c \
	util/viriptables.h \
	util/viriscsi.c \
	util/viriscsi.h \
	util/virjson.c \
	util/virjson.h \
	util/virkeycode.c \
	util/virkeycode.h \
	util/virkeyfile.c \
	util/virkeyfile.h \
	util/virlease.c \
	util/virlease.h \
	util/virlockspace.c \
	util/virlockspace.h \
	util/virlog.c \
	util/virlog.h \
	util/virmacaddr.c \
	util/virmacaddr.h \
	util/virmacmap.c \
	util/virmacmap.h \
	util/virmodule.c \
	util/virmodule.h \
	util/virnetdev.c \
	util/virnetdev.h \
	util/virnetdevbandwidth.c \
	util/virnetdevbandwidth.h \
	util/virnetdevbridge.c \
	util/virnetdevbridge.h \
	util/virnetdevip.c \
	util/virnetdevip.h \
	util/virnetdevmacvlan.c \
	util/virnetdevmacvlan.h \
	util/virnetdevmidonet.c \
	util/virnetdevmidonet.h \
	util/virnetdevopenvswitch.c \
	util/virnetdevopenvswitch.h \
	util/virnetdevtap.c \
	util/virnetdevtap.h \
	util/virnetdevveth.c \
	util/virnetdevveth.h \
	util/virnetdevvlan.c \
	util/virnetdevvlan.h \
	util/virnetdevvportprofile.c \
	util/virnetdevvportprofile.h \
	util/virnetlink.c \
	util/virnetlink.h \
	util/virnodesuspend.c \
	util/virnodesuspend.h \
	util/virkmod.c \
	util/virkmod.h \
	util/virnuma.c \
	util/virnuma.h \
	util/virobject.c \
	util/virobject.h \
	util/virpci.c \
	util/virpci.h \
	util/virpidfile.c \
	util/virpidfile.h \
	util/virpolkit.c \
	util/virpolkit.h \
	util/virportallocator.c \
	util/virportallocator.h \
	util/virprobe.h \
	util/virprocess.c \
	util/virprocess.h \
	util/virqemu.c \
	util/virqemu.h \
	util/virrandom.c \
	util/virrandom.h \
	util/virresctrl.c \
	util/virresctrl.h \
	util/virresctrlpriv.h \
	util/virrotatingfile.c \
	util/virrotatingfile.h \
	util/virscsi.c \
	util/virscsi.h \
	util/virscsihost.c \
	util/virscsihost.h \
	util/virscsivhost.c \
	util/virscsivhost.h \
	util/virseclabel.c \
	util/virseclabel.h \
	util/virsecret.c \
	util/virsecret.h \
	util/virsocketaddr.c \
	util/virsocketaddr.h \
	util/virstorageencryption.c \
	util/virstorageencryption.h \
	util/virstoragefile.c \
	util/virstoragefile.h \
	util/virstoragefilebackend.c \
	util/virstoragefilebackend.h \
	util/virstring.c \
	util/virstring.h \
	util/virsysinfo.c \
	util/virsysinfo.h \
	util/virsysinfopriv.h \
	util/virsystemd.c \
	util/virsystemd.h \
	util/virsystemdpriv.h \
	util/virthread.c \
	util/virthread.h \
	util/virthreadjob.c \
	util/virthreadjob.h \
	util/virthreadpool.c \
	util/virthreadpool.h \
	util/virtime.c \
	util/virtime.h \
	util/virtpm.c \
	util/virtpm.h \
	util/virtypedparam-public.c \
	util/virtypedparam.c \
	util/virtypedparam.h \
	util/virusb.c \
	util/virusb.h \
	util/viruri.c \
	util/viruri.h \
	util/virutil.c \
	util/virutil.h \
	util/viruuid.c \
	util/viruuid.h \
	util/virvhba.c \
	util/virvhba.h \
	util/virvsock.c \
	util/virvsock.h \
	util/virxdrdefs.h \
	util/virxml.c \
	util/virxml.h \
	util/virmdev.c \
	util/virmdev.h \
	util/virfilecache.c \
	util/virfilecache.h \
	$(NULL)


EXTRA_DIST += \
	$(srcdir)/keycodemapdb/data/keymaps.csv \
	$(srcdir)/keycodemapdb/tools/keymap-gen \
	$(NULL)


KEYCODES = linux osx atset1 atset2 atset3 xtkbd usb win32 qnum
KEYNAMES = linux osx win32

KEYTABLES = \
	$(KEYCODES:%=util/virkeycodetable_%.h) \
	$(KEYNAMES:%=util/virkeynametable_%.h) \
	$(NULL)

KEYPODS = $(KEYCODES:%=util/virkeycode-%.pod) \
	  $(KEYNAMES:%=util/virkeyname-%.pod)
KEYMANS = $(KEYPODS:%.pod=%.7)

man7_MANS += $(KEYMANS)

UTIL_SOURCES += $(KEYTABLES)
BUILT_SOURCES += $(KEYTABLES)
MAINTAINERCLEANFILES += $(KEYTABLES)
CLEANFILES += $(KEYMANS) $(KEYPODS)

UTIL_IO_HELPER_SOURCES = util/iohelper.c

noinst_LTLIBRARIES += libvirt_util.la
libvirt_la_LIBADD = $(libvirt_la_BUILT_LIBADD)
libvirt_la_BUILT_LIBADD += libvirt_util.la
libvirt_util_la_SOURCES = \
	$(UTIL_SOURCES) \
	$(NULL)
libvirt_util_la_CFLAGS = \
	$(CAPNG_CFLAGS) \
	$(YAJL_CFLAGS) \
	$(LIBNL_CFLAGS) \
	$(AM_CFLAGS) \
	$(AUDIT_CFLAGS) \
	$(DEVMAPPER_CFLAGS) \
	$(DBUS_CFLAGS) \
	$(LDEXP_LIBM) \
	$(NUMACTL_CFLAGS) \
	$(GNUTLS_CFLAGS) \
	$(ACL_CFLAGS) \
	$(NULL)
libvirt_util_la_LIBADD = \
	-lm \
	$(CAPNG_LIBS) \
	$(YAJL_LIBS) \
	$(LIBNL_LIBS) \
	$(THREAD_LIBS) \
	$(AUDIT_LIBS) \
	$(DEVMAPPER_LIBS) \
	$(LIB_CLOCK_GETTIME) \
	$(DBUS_LIBS) \
	$(WIN32_EXTRA_LIBS) \
	$(LIBXML_LIBS) \
	$(SECDRIVER_LIBS) \
	$(NUMACTL_LIBS) \
	$(ACL_LIBS) \
	$(GNUTLS_LIBS) \
	$(NULL)


util/virkeycodetable_%.h: $(srcdir)/keycodemapdb/data/keymaps.csv \
			$(srcdir)/keycodemapdb/tools/keymap-gen Makefile.am
	$(AM_V_GEN)export NAME=`echo $@ | sed -e 's,util/virkeycodetable_,,' \
					      -e 's,\.h,,'` && \
		$(MKDIR_P) util/ && \
		$(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
			--lang stdc --varname virKeyCodeTable_$$NAME code-table \
			$(srcdir)/keycodemapdb/data/keymaps.csv $$NAME > $@-tmp && \
		mv $@-tmp $@ || rm -f $@-tmp

util/virkeynametable_%.h: $(srcdir)/keycodemapdb/data/keymaps.csv \
			$(srcdir)/keycodemapdb/tools/keymap-gen Makefile.am
	$(AM_V_GEN)export NAME=`echo $@ | sed -e 's,util/virkeynametable_,,' \
					      -e 's,\.h,,'` && \
		$(MKDIR_P) util/ && \
		$(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
			--lang stdc --varname virKeyNameTable_$$NAME name-table \
			$(srcdir)/keycodemapdb/data/keymaps.csv $$NAME > $@-tmp && \
		mv $@-tmp $@ || rm -f $@-tmp

util/virkeycode-%.pod: $(srcdir)/keycodemapdb/data/keymaps.csv \
			$(srcdir)/keycodemapdb/tools/keymap-gen Makefile.am
	$(AM_V_GEN)export NAME=`echo $@ | sed -e 's,util/virkeycode-,,' \
					      -e 's,\.pod,,'` && \
		$(MKDIR_P) util/ && \
		$(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
		--lang pod \
		--varname "virkeycode-$$NAME - Key code values for $$NAME" \
		code-docs \
		$(srcdir)/keycodemapdb/data/keymaps.csv $$NAME > \
			$@-tmp && mv $@-tmp $@ || rm $@-tmp

util/virkeyname-%.pod: $(srcdir)/keycodemapdb/data/keymaps.csv \
			$(srcdir)/keycodemapdb/tools/keymap-gen Makefile.am
	$(AM_V_GEN)export NAME=`echo $@ | sed -e 's,util/virkeyname-,,' \
					      -e 's,\.pod,,'` && \
		$(MKDIR_P) util/ && \
		$(RUNUTF8) $(PYTHON) $(srcdir)/keycodemapdb/tools/keymap-gen \
		--lang pod \
		--varname "virkeyname-$$NAME - Key name values for $$NAME" \
		name-docs \
		$(srcdir)/keycodemapdb/data/keymaps.csv $$NAME > \
			$@-tmp && mv $@-tmp $@ || rm $@-tmp

util/virkey%.7: util/virkey%.pod
	$(AM_V_GEN)$(POD2MAN) --section=7 $< $@-t1 && \
	if grep 'POD ERROR' $@-t1; then rm $@-t1; exit 1; fi && \
	sed \
		-e 's|SYSCONFDIR|\@sysconfdir\@|g' \
		-e 's|LOCALSTATEDIR|\@localstatedir\@|g' \
		< $@-t1 > $@-t2 && \
	rm -f $@-t1 && \
	mv $@-t2 $@
