<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.32.2">
</HEAD>
<BODY>
On Wed, 2011-08-31 at 18:02 +0200, Micha&#322; G&#243;rny wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Fixes: <A HREF="https://bugs.freedesktop.org/show_bug.cgi?id=38339">https://bugs.freedesktop.org/show_bug.cgi?id=38339</A>
Signed-off-by: Micha&#322; G&#243;rny &lt;<A HREF="mailto:mgorny@gentoo.org">mgorny@gentoo.org</A>&gt;
Reviewed-by: Gaetan Nadon &lt;<A HREF="mailto:memsize@videotron.ca">memsize@videotron.ca</A>&gt;
Tested-by: Gaetan Nadon &lt;<A HREF="mailto:memsize@videotron.ca">memsize@videotron.ca</A>&gt;
---
 .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..c51052d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -76,3 +76,4 @@ core
 #                Edit the following section as needed
 # For example, !report.pc overrides *.pc. See 'man gitignore'
 #
+xdm.service
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 &amp;&amp; $(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' &lt; $&lt; &gt; $@
+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 &quot;x$USE_SELINUX&quot; != &quot;xno&quot; ; 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 &quot;x$with_systemdsystemunitdir&quot; = &quot;xyes&quot; -o &quot;x$with_systemdsystemunitdir&quot; = &quot;xauto&quot;], [
+    def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
+
+    AS_IF([test &quot;x$def_systemdsystemunitdir&quot; = &quot;x&quot;], [
+        AS_IF([test &quot;x$with_systemdsystemunitdir&quot; = &quot;xyes&quot;], [
+            AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])
+        ])
+        with_systemdsystemunitdir=no
+    ], [
+        with_systemdsystemunitdir=$def_systemdsystemunitdir
+    ])
+])
+AS_IF([test &quot;x$with_systemdsystemunitdir&quot; != &quot;xno&quot;], [
+        AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
+])
+AM_CONDITIONAL(HAVE_SYSTEMD, [test &quot;x$with_systemdsystemunitdir&quot; != &quot;xno&quot;])
+
 # 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
</PRE>
</BLOCKQUOTE>
<BR>
Reviewed-by: Gaetan Nadon &lt;<A HREF="mailto:memsize@videotron.ca">memsize@videotron.ca</A>&gt;<BR>
Tested-by: Gaetan Nadon &lt;memsize@videotron.ca&gt;<BR>
<BR>
<BR>
</BODY>
</HTML>