[PATCH] Support installing systemd unit file.

Michał Górny mgorny at gentoo.org
Wed Aug 31 07:52:10 PDT 2011


Signed-off-by: Michał Górny <mgorny at gentoo.org>
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=38339
---
 .gitignore     |    1 +
 Makefile.am    |   13 ++++++++++++-
 configure.ac   |   21 +++++++++++++++++++++
 xdm.service.in |    9 +++++++++
 4 files changed, 43 insertions(+), 1 deletions(-)
 create mode 100644 xdm.service.in

diff --git a/.gitignore b/.gitignore
index fbf6b92..ff39688 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,7 @@ stamp-h?
 symlink-tree
 texinfo.tex
 ylwrap
+xdm.service
 
 #	Do not edit the following section
 # 	Edit Compile Debug Document Distribute
diff --git a/Makefile.am b/Makefile.am
index 0bd7ca9..e5f9f5c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,9 @@ SUBDIRS = app-defaults chooser config greeter include man xdm xdmshell
 ACLOCAL_AMFLAGS = -I m4
 
 # This ensures distcheck is performed in a location where user has write access
-DISTCHECK_CONFIGURE_FLAGS = --with-appdefaultdir=\$${datadir}/X11/app-defaults
+DISTCHECK_CONFIGURE_FLAGS = \
+	--with-appdefaultdir=\$${datadir}/X11/app-defaults \
+	--with-systemdsystemunitdir=\$${libdir}/systemd/system
 
 if LINT
 ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
@@ -38,6 +40,15 @@ lint:
 	(cd chooser && $(MAKE) $(AM_MAKEFLAGS) lint)
 endif LINT
 
+if HAVE_SYSTEMD
+systemdsystemunit_DATA = xdm.service
+
+xdm.service: xdm.service.in
+	$(AM_V_GEN)$(SED) -e 's|BINDIR|$(bindir)|g' < $< > $@
+endif HAVE_SYSTEMD
+CLEANFILES = xdm.service
+EXTRA_DIST = xdm.service.in
+
 MAINTAINERCLEANFILES = ChangeLog INSTALL
 
 .PHONY: ChangeLog INSTALL
diff --git a/configure.ac b/configure.ac
index 0c79999..2485288 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,27 @@ if test "x$USE_SELINUX" != "xno" ; then
     )
 fi
 
+# Check whether to install systemd unit files, as suggested in daemon(7).
+AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
+	[Directory for systemd service files (default from the System and Service Manager)]),,
+	[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"])
+
 # FIXME: Find better test for which OS'es use su -m  - for now, just try to
 # mirror the Imakefile setting of:
 # if  defined(OpenBSDArchitecture) || defined(NetBSDArchitecture) || defined(FreeBSDArchitecture) || defined(DarwinArchitecture)
diff --git a/xdm.service.in b/xdm.service.in
new file mode 100644
index 0000000..d15e072
--- /dev/null
+++ b/xdm.service.in
@@ -0,0 +1,9 @@
+[Unit]
+Description=X-Window Display Manager
+After=systemd-user-sessions.service
+
+[Service]
+ExecStart=BINDIR/xdm -nodaemon
+
+[Install]
+Alias=graphical.target.wants/xdm.service
-- 
1.7.6.1



More information about the xorg-devel mailing list