aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-09-10 13:28:25 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-09-10 16:09:54 +0200
commit516697e29a090c0137c49c66731b5d93125e8f7e (patch)
tree5b764bb49994e45fa05cc4139a5aa9116318f0c7
parent3e9c071aa66d2a7f7465c4cac229f205d2dbecdd (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--contrib/systemd/osmo-pcu.service (renamed from contrib/osmo-pcu.service)0
-rw-r--r--debian/osmo-pcu.install1
l---------debian/osmo-pcu.service1
-rwxr-xr-xdebian/rules3
8 files changed, 32 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 7a4e6c0..240e4ee 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 7288c24..90394e1 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 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..f565234
--- /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
index 6329d31..6329d31 100644
--- a/contrib/osmo-pcu.service
+++ b/contrib/systemd/osmo-pcu.service
diff --git a/debian/osmo-pcu.install b/debian/osmo-pcu.install
index 80316ee..1b82e96 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 f077431..0000000
--- 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 cffb6ca..712dd75 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