From 516697e29a090c0137c49c66731b5d93125e8f7e Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 10 Sep 2018 13:28:25 +0200 Subject: [PATCH] Install systemd services with autotools Change-Id: Ie4c7e81495181059d1dff1c194d52d11fb72ed03 --- Makefile.am | 5 ++++- configure.ac | 18 ++++++++++++++++++ contrib/Makefile.am | 1 + contrib/systemd/Makefile.am | 5 +++++ contrib/{ => systemd}/osmo-pcu.service | 0 debian/osmo-pcu.install | 1 + debian/osmo-pcu.service | 1 - debian/rules | 3 +++ 8 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 contrib/Makefile.am create mode 100644 contrib/systemd/Makefile.am rename contrib/{ => systemd}/osmo-pcu.service (100%) delete mode 120000 debian/osmo-pcu.service diff --git a/Makefile.am b/Makefile.am index 7a4e6c0b..240e4ee2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,11 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 -SUBDIRS = include src examples tests +SUBDIRS = include src examples tests contrib EXTRA_DIST = osmoappdesc.py README.md +DISTCHECK_CONFIGURE_FLAGS = \ + --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) + @RELMAKE@ pkgconfigdir = $(libdir)/pkgconfig diff --git a/configure.ac b/configure.ac index 7288c24e..90394e12 100644 --- a/configure.ac +++ b/configure.ac @@ -157,6 +157,22 @@ AM_CONDITIONAL(ENABLE_VTY_TESTS, test "x$enable_vty_tests" = "xyes") STD_DEFINES_AND_INCLUDES="-Wall" AC_SUBST(STD_DEFINES_AND_INCLUDES) +# https://www.freedesktop.org/software/systemd/man/daemon.html +AC_ARG_WITH([systemdsystemunitdir], + [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],, + [with_systemdsystemunitdir=auto]) +AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [ + def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) + + AS_IF([test "x$def_systemdsystemunitdir" = "x"], + [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], + [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) + with_systemdsystemunitdir=no], + [with_systemdsystemunitdir="$def_systemdsystemunitdir"])]) +AS_IF([test "x$with_systemdsystemunitdir" != "xno"], + [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]) +AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) + AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"]) AC_MSG_RESULT([CFLAGS="$CFLAGS"]) AC_MSG_RESULT([CXXFLAGS="$CXXFLAGS"]) @@ -168,4 +184,6 @@ AC_OUTPUT( src/Makefile examples/Makefile tests/Makefile + contrib/Makefile + contrib/systemd/Makefile Makefile) diff --git a/contrib/Makefile.am b/contrib/Makefile.am new file mode 100644 index 00000000..3439c97b --- /dev/null +++ b/contrib/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = systemd diff --git a/contrib/systemd/Makefile.am b/contrib/systemd/Makefile.am new file mode 100644 index 00000000..f565234f --- /dev/null +++ b/contrib/systemd/Makefile.am @@ -0,0 +1,5 @@ +if HAVE_SYSTEMD +EXTRA_DIST = osmo-pcu.service +systemdsystemunit_DATA = \ + osmo-pcu.service +endif diff --git a/contrib/osmo-pcu.service b/contrib/systemd/osmo-pcu.service similarity index 100% rename from contrib/osmo-pcu.service rename to contrib/systemd/osmo-pcu.service diff --git a/debian/osmo-pcu.install b/debian/osmo-pcu.install index 80316ee0..1b82e961 100644 --- a/debian/osmo-pcu.install +++ b/debian/osmo-pcu.install @@ -1,4 +1,5 @@ etc/osmocom/osmo-pcu.cfg +lib/systemd/system/osmo-pcu.service usr/bin/osmo-pcu usr/include/osmocom/pcu/pcuif_proto.h usr/lib/*/pkgconfig/osmo-pcu.pc diff --git a/debian/osmo-pcu.service b/debian/osmo-pcu.service deleted file mode 120000 index f0774312..00000000 --- a/debian/osmo-pcu.service +++ /dev/null @@ -1 +0,0 @@ -../contrib/osmo-pcu.service \ No newline at end of file diff --git a/debian/rules b/debian/rules index cffb6ca0..712dd756 100755 --- a/debian/rules +++ b/debian/rules @@ -22,3 +22,6 @@ override_dh_clean: # Print test results in case of a failure override_dh_auto_test: dh_auto_test || (find . -name testsuite.log -exec cat {} \; ; false) + +override_dh_auto_configure: + dh_auto_configure -- --with-systemdsystemunitdir=/lib/systemd/system