From 4dfe31fd72ad96fcb3154f20020e2cc4ec36ba95 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 15 Aug 2013 11:08:39 +0200 Subject: [PATCH] systemd: install service file using `systemdsystemunit_DATA` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When there is an autoconf variable `somethingdir`, we can use `something_DATA` in automake to install things to this directory. This is more convenient than using local targets We still have to protect the use of those variables with conditional macros since they can be empty or set to no. There is also a drawback about distcheck trying to set prefix and not expecting things to be installed outside of prefix. Do the same thing for OS X launchd daemon configuration file. --- Makefile.am | 6 ++++++ configure.ac | 11 +++++++++-- debian/rules | 2 +- m4/args.m4 | 1 + osx/Makefile.am | 14 +++----------- src/daemon/Makefile.am | 8 +++----- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Makefile.am b/Makefile.am index 273a4dc5..07390fd8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,3 +31,9 @@ dist-hook: echo $(VERSION) > $(distdir)/.dist-version MOSTLYCLEANFILES = $(DX_CLEANFILES) + +# systemd and launchd files are not installed in the prefix, don't +# request them for distcheck +DISTCHECK_CONFIGURE_FLAGS = \ + --with-systemdsystemunitdir=no \ + --with-launchddaemonsdir=no diff --git a/configure.ac b/configure.ac index 504b3569..470f42c3 100644 --- a/configure.ac +++ b/configure.ac @@ -179,11 +179,18 @@ if test x"$with_json" = x"yes"; then fi # OS X launchd support -lldp_ARG_WITH([launchd-daemons-path], [Directory for launchd configuration file (OSX)], [/Library/LaunchDaemons]) +lldp_ARG_WITH([launchddaemonsdir], [Directory for launchd configuration file (OSX)], + [/Library/LaunchDaemons]) +AC_SUBST([launchddaemonsdir], [$with_launchddaemonsdir]) +AM_CONDITIONAL(HAVE_LAUNCHDDAEMONSDIR, + [test -n "$with_launchddaemonsdir" -a "x$with_launchddaemonsdir" != xno ]) # Systemd lldp_ARG_WITH([systemdsystemunitdir], [Directory for systemd service files], - [$($PKG_CONFIG --variable=systemdsystemunitdir systemd || echo no)]) + [$($PKG_CONFIG --variable=systemdsystemunitdir systemd)]) +AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) +AM_CONDITIONAL(HAVE_SYSTEMDSYSTEMUNITDIR, + [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) # Privsep settings lldp_ARG_WITH([privsep-user], [Which user to use for privilege separation], [_lldpd]) diff --git a/debian/rules b/debian/rules index 941649e3..96e804ed 100755 --- a/debian/rules +++ b/debian/rules @@ -4,4 +4,4 @@ include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/rules/autoreconf.mk include /usr/share/cdbs/1/class/autotools.mk -DEB_CONFIGURE_EXTRA_FLAGS = --with-snmp --with-xml +DEB_CONFIGURE_EXTRA_FLAGS = --with-snmp --with-xml --with-systemdsystemunitdir=/lib/systemd/system diff --git a/m4/args.m4 b/m4/args.m4 index cc6263bd..47d05ada 100644 --- a/m4/args.m4 +++ b/m4/args.m4 @@ -12,6 +12,7 @@ AC_DEFUN([lldp_ARG_WITH],[ AC_SUBST(AS_TR_CPP([$1]), [$withval])],[ AC_DEFINE_UNQUOTED(AS_TR_CPP([$1]), ["$3"], [$2]) AC_SUBST(AS_TR_CPP([$1]), [$3]) + eval with_[]m4_translit([$1], [-+.], [___]))="$3" ])]) dnl lldp_ARG_ENABLE(name, help1, default) diff --git a/osx/Makefile.am b/osx/Makefile.am index 7f34c2af..5e2b8fe7 100644 --- a/osx/Makefile.am +++ b/osx/Makefile.am @@ -57,17 +57,9 @@ $(ARCHS:%=stamp-%): stamp-%: im.bernat.lldpd.plist touch $@ # Install launchd plist -install-data-local: - [ x"@LAUNCHD_DAEMONS_PATH@" = x"no" ] || install -m 0755 -d $(DESTDIR)@LAUNCHD_DAEMONS_PATH@ - [ x"@LAUNCHD_DAEMONS_PATH@" = x"no" ] || install -m 0644 im.bernat.lldpd.plist $(DESTDIR)@LAUNCHD_DAEMONS_PATH@ -uninstall-local: - [ x"@LAUNCHD_DAEMONS_PATH@" = x"no" ] || rm -f $(DESTDIR)@LAUNCHD_DAEMONS_PATH@/im.bernat.lldpd.plist -clean-local: - rm -rf $(ARCHS) - rm -rf $(PKG_DIR) - rm -f stamp-* - rm -rf pkg.1 - rm -f ../$(PKG_NAME) +if HAVE_LAUNCHDDAEMONSDIR +launchddaemons_DATA = im.bernat.lldpd.plist +endif .PHONY: pkg requirements diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index 54dda7b1..dbf38068 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -101,8 +101,6 @@ $(top_builddir)/libevent/libevent.la: $(top_srcdir)/libevent/*.c $(top_srcdir)/l endif ## systemd service file -install-data-local: - [ x"@SYSTEMDSYSTEMUNITDIR@" = x"no" ] || install -m 0755 -d $(DESTDIR)@SYSTEMDSYSTEMUNITDIR@ - [ x"@SYSTEMDSYSTEMUNITDIR@" = x"no" ] || install -m 0644 -d lldpd.service $(DESTDIR)@SYSTEMDSYSTEMUNITDIR@ -uninstall-local: - [ x"@LAUNCHD_DAEMONS_PATH@" = x"no" ] || rm -f $(DESTDIR)@SYSTEMDSYSTEMUNITDIR@/lldpd.service +if HAVE_SYSTEMDSYSTEMUNITDIR +systemdsystemunit_DATA = lldpd.service +endif -- 2.39.5