aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-09-10 12:09:47 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2018-09-10 16:10:03 +0200
commita68b6828c818935ce9806960b7eefeafa21dac93 (patch)
treedbf8810112180d9a4f5c8b2ad5238044c25d2a62
parentb69c902fe027709e83e76607799a0dc724c0dee5 (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-hnbgw.install1
l---------debian/osmo-hnbgw.service1
-rwxr-xr-xdebian/rules3
7 files changed, 32 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index 67445ee..2e59306 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,12 +1,15 @@
AUTOMAKE_OPTIONS = foreign dist-bzip2
-SUBDIRS = src include doc
+SUBDIRS = src include doc contrib
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libosmo-ranap.pc
EXTRA_DIST = asn1 .version README.md
+DISTCHECK_CONFIGURE_FLAGS = \
+ --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
+
@RELMAKE@
BUILT_SOURCES = $(top_srcdir)/.version
diff --git a/configure.ac b/configure.ac
index bb99dfb..559db39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,6 +79,22 @@ fi
CFLAGS="$CFLAGS -Wall"
CPPFLAGS="$CPPFLAGS -Wall"
+# 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([CFLAGS="$CFLAGS"])
AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
@@ -98,4 +114,6 @@ AC_OUTPUT(
include/osmocom/iuh/Makefile
doc/Makefile
doc/examples/Makefile
+ contrib/Makefile
+ contrib/systemd/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..507be2d
--- /dev/null
+++ b/contrib/systemd/Makefile.am
@@ -0,0 +1,5 @@
+if HAVE_SYSTEMD
+EXTRA_DIST = osmo-hnbgw.service
+systemdsystemunit_DATA = \
+ osmo-hnbgw.service
+endif
diff --git a/debian/osmo-hnbgw.install b/debian/osmo-hnbgw.install
index e230915..bb70ad5 100644
--- a/debian/osmo-hnbgw.install
+++ b/debian/osmo-hnbgw.install
@@ -1,2 +1,3 @@
+lib/systemd/system/osmo-hnbgw.service
usr/bin/osmo-hnbgw
usr/share/doc/osmo-iuh/examples/osmo-hnbgw.cfg
diff --git a/debian/osmo-hnbgw.service b/debian/osmo-hnbgw.service
deleted file mode 120000
index e69ea55..0000000
--- a/debian/osmo-hnbgw.service
+++ /dev/null
@@ -1 +0,0 @@
-../contrib/systemd/osmo-hnbgw.service \ No newline at end of file
diff --git a/debian/rules b/debian/rules
index 9ebfdd0..6f20b3e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -16,3 +16,6 @@ override_dh_strip:
# 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