AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}

AM_CPPFLAGS = $(DEPS_CFLAGS)

DISTCLEANFILES  =   src/mc-hid-server-glue.hpp \
                    script/init.d/mediacore-hid

SUPPORT_SRC = 	src/log/log.hpp \
                src/log/log.cpp \
                src/thread/thread.hpp \
                src/thread/thread.cpp \
                src/buttontimer/buttontimer.hpp \
                src/buttontimer/buttontimer.cpp \
                src/gpio/gpio.hpp \
                src/gpio/gpio.cpp \
                src/gpio/dma.hpp \
                src/gpio/dma.cpp \
                src/gpio/mailbox.h \
                src/gpio/mailbox.c

sbin_PROGRAMS   = mediacore-hid-server

EXTRA_DIST =    cfg/dbus/nl.miqra.MediaCore.Hid.conf \
                cfg/init.d/mediacore-hid.in \
                cfg/rsyslog/syslog.MediaCore.Hid.conf \
                src/mc-hid-introspect.xml 

init_d_dirdir = $(sysconfdir)/init.d
init_d_dir_SCRIPTS = cfg/init.d/mediacore-hid

dbus_confdir = $(sysconfdir)/dbus-1/system.d
dbus_conf_DATA = cfg/dbus/nl.miqra.MediaCore.Hid.conf

rsyslog_confdir = $(sysconfdir)/rsyslog.d
rsyslog_conf_DATA = cfg/rsyslog/syslog.MediaCore.Hid.conf

src/mc-hid-server-glue.hpp: src/mc-hid-introspect.xml
	dbusxx-xml2cpp $^ --adaptor=$@

BUILT_SOURCES = src/mc-hid-server-glue.hpp 

mediacore_hid_server_CPPFLAGS = -std=c++17 -I/usr/include/dbus-c++-1/ -I/opt/vc/include/
mediacore_hid_server_SOURCES =  src/mc-hid-server.cpp \
                                src/mc-hid-server.hpp \
                                src/mc-hid-server-glue.hpp \
                                src/exception/baseexceptions.hpp \
                                src/exception/baseexceptions.cpp \
                                $(SUPPORT_SRC)
                       
mediacore_hid_server_LDADD   =  $(DEPS_LIBS) -L/opt/vc/lib -lpthread -lrt -lgpiodcxx -lbcm_host 
                    

cfg/init.d/mediacore-hid: cfg/init.d/mediacore-hid.in
	cat $^ > $@
	sed -i "s#@BIN_DIR@#$(bindir)#" $@
	sed -i "s#@ETC_DIR@#$(sysconfdir)#" $@
	sed -i "s#@SBIN_DIR@#$(sbindir)#" $@

version.py: version.py.in 
	cat $^ > $@
	sed -i "s#@V_PACKAGE@#$(PACKAGE)#" $@
	sed -i "s#@V_VERSION\@#$(VERSION)#" $@