Add MCTP service file

Previous service file for this repo are contained
in the corresponding meta layer.
Now move it into the repository that owns them.

Signed-off-by: Xiaochao Ma <maxiaochao@inspur.com>
Change-Id: I15d85815483da19b08869225eb50866b49fe5575
diff --git a/Makefile.am b/Makefile.am
index 3994ff0..c93d452 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,6 +15,11 @@
 include_HEADERS += libmctp-astlpc.h
 endif
 
+if HAVE_SYSTEMD
+systemdsystemunit_DATA = \
+	mctp-demux.service
+endif
+
 bin_PROGRAMS = utils/mctp-demux-daemon
 utils_mctp_demux_daemon_LDADD = libmctp.la
 
diff --git a/configure.ac b/configure.ac
index 77212cf..3a2343b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,25 @@
 # pkg-config
 PKG_PROG_PKG_CONFIG
 PKG_INSTALLDIR
+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"])
 
 # Set defaults for standard library compiles. We may want to
 # AC_ARG_WITH these in the future.
diff --git a/mctp-demux.service b/mctp-demux.service
new file mode 100644
index 0000000..c04a46d
--- /dev/null
+++ b/mctp-demux.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=MCTP demultiplexer daemon
+
+[Service]
+Restart=always
+EnvironmentFile=-/etc/default/mctp
+ExecStart=/usr/bin/mctp-demux-daemon $DEMUX_BINDING_OPTS
+SyslogIdentifier=mctp-demux
+
+[Install]
+WantedBy=multi-user.target