summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-09-10 13:54:05 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-09-10 16:09:56 +0200
commitb47fc45642382399814d5f3b460a6a1f887173b3 (patch)
treee19b9c20dfb80227b852f8eee85e115b214eb830
parent3233e0d9df8c61b789ed8980c0d16b541b2204a5 (diff)
Install systemd services with autotools
-rw-r--r--Makefile.am5
-rw-r--r--configure.ac18
-rw-r--r--contrib/Makefile.am1
-rw-r--r--contrib/systemd/Makefile.am5
-rw-r--r--debian/osmo-sip-connector.install1
l---------debian/osmo-sip-connector.service1
-rwxr-xr-xdebian/rules3
7 files changed, 32 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 5a2c4a9..7c1e00c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,10 +1,13 @@
AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6
-SUBDIRS = src tests
+SUBDIRS = src tests contrib
BUILT_SOURCES = $(top_srcdir)/.version
EXTRA_DIST = git-version-gen osmoappdesc.py .version
+DISTCHECK_CONFIGURE_FLAGS = \
+ --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
+
@RELMAKE@
$(top_srcdir)/.version:
diff --git a/configure.ac b/configure.ac
index 916cfc3..1514faa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,22 @@ AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
AC_MSG_RESULT([$enable_ext_tests])
AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
+# 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"])
@@ -73,4 +89,6 @@ AC_MSG_RESULT([LDFLAGS="$LDFLAGS"])
AC_OUTPUT(
src/Makefile
tests/Makefile
+ contrib/Makefile
+ contrib/systemd/Makefile
Makefile)
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
new file mode 100644
index 0000000..3439c97
--- /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 0000000..213cc7a
--- /dev/null
+++ b/contrib/systemd/Makefile.am
@@ -0,0 +1,5 @@
+if HAVE_SYSTEMD
+EXTRA_DIST = osmo-sip-connector.service
+systemdsystemunit_DATA = \
+ osmo-sip-connector.service
+endif
diff --git a/debian/osmo-sip-connector.install b/debian/osmo-sip-connector.install
index a16b95f..b776fda 100644
--- a/debian/osmo-sip-connector.install
+++ b/debian/osmo-sip-connector.install
@@ -1 +1,2 @@
+lib/systemd/system/osmo-sip-connector.service
usr/bin/osmo-sip-connector
diff --git a/debian/osmo-sip-connector.service b/debian/osmo-sip-connector.service
deleted file mode 120000
index c0ae1e1..0000000
--- a/debian/osmo-sip-connector.service
+++ /dev/null
@@ -1 +0,0 @@
-../contrib/systemd/osmo-sip-connector.service \ No newline at end of file
diff --git a/debian/rules b/debian/rules
index 5e9e20f..e4e7ca9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -13,3 +13,6 @@ export DEB_BUILD_HARDENING=1
override_dh_strip:
dh_strip --dbg-package=osmo-sip-connector-dbg
+
+override_dh_auto_configure:
+ dh_auto_configure -- --with-systemdsystemunitdir=/lib/systemd/system