diff --git a/Makefile.am b/Makefile.am index 8a8a8fcd..288f86ed 100644 --- a/Makefile.am +++ b/Makefile.am @@ -29,6 +29,9 @@ ACLOCAL_AMFLAGS = -I m4 +AM_DISTCHECK_CONFIGURE_FLAGS = \ + --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) + SUBDIRS = \ include \ script diff --git a/configure.ac b/configure.ac index e9517115..b19992cf 100644 --- a/configure.ac +++ b/configure.ac @@ -45,6 +45,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror dist-bzip2 subdir-objects]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_MACRO_DIR([m4]) +PKG_PROG_PKG_CONFIG PKG_INSTALLDIR() #------------------------------------------------------------------------------ @@ -1078,6 +1079,35 @@ else AC_MSG_RESULT([no]) fi +#------------------------------------------------------------------------------ +# systemd service support +#------------------------------------------------------------------------------ + +AC_ARG_WITH([systemdsystemunitdir], + AS_HELP_STRING([--with-systemdsystemunitdir=DIR], + [Directory for systemd service files]), + , + [with_systemdsystemunitdir=auto] +) + +case "${with_systemdsystemunitdir}" in + yes) + with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) + if test "x$with_systemdsystemunitdir" = "x"; then + AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package]) + fi + ;; + no) + with_systemdsystemunitdir= + ;; + auto) + with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) + ;; +esac + +AM_CONDITIONAL(HAVE_SYSTEMD, test "x$with_systemdsystemunitdir" != "x") +AC_SUBST(systemdsystemunitdir,[$with_systemdsystemunitdir]) + #------------------------------------------------------------------------------ AC_CONFIG_FILES([ diff --git a/script/Makefile.am b/script/Makefile.am index 419a024f..b3483f15 100644 --- a/script/Makefile.am +++ b/script/Makefile.am @@ -35,9 +35,6 @@ SUBDIRS = init.d sysconfig sbin_SCRIPTS = ethercatctl -systemddir = $(libdir)/systemd/system -systemd_DATA = ethercat.service - dist_sysconf_DATA = ethercat.conf EXTRA_DIST = \ @@ -49,4 +46,8 @@ BUILT_SOURCES = \ ethercatctl \ ethercat.service +if HAVE_SYSTEMD +systemdsystemunit_DATA = ethercat.service +endif + #------------------------------------------------------------------------------