commit 8607f749d8f6bc88a2454bb18cb4fc8d2504e3d4
Author: Yaroslav Shmelev <yars068@yandex.ru>
Date:   Tue Jan 12 14:36:50 2016 +0300

    Possibility to not install systemd files on non-systemd machine
    
    On non-systemd driven distributions, this allow to not install systemd
    related stuff.
    For more details, see https://bugzilla.gnome.org/show_bug.cgi?id=760293

diff --git a/configure.ac b/configure.ac
index bb358c6..c1fd28c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -260,6 +260,26 @@ fi
 
 AM_CONDITIONAL(USE_UDISKS2, [test "$msg_udisks2" = "yes"])
 
+dnl ************************************
+dnl *** Check for systemd user units ***
+dnl ************************************
+
+sustemd_user_dir=${prefix}/lib/systemd/user
+AC_ARG_WITH([systemd-userunitdir],
+        [AS_HELP_STRING([--with-systemd-userunitdir=PATH],
+            [enable or disable systemd user units support, defaults to no])], 
+        [systemd_user_units=$withval],
+        [msg_systemd_user_units=no])
+
+if test "x$systemd_user_units" != "xno"; then
+    PKG_CHECK_MODULES([SYSTEMD], [systemd >= 219],
+        [])
+fi
+
+msg_systemd_userunits=${systemd_user_units}
+
+AM_CONDITIONAL([HAVE_SYSTEMD_USER_UNITS_DIR], [test "x$systemd_user_units" != "xno"])
+
 dnl **********************************
 dnl *** Check for libsystemd-login ***
 dnl **********************************
@@ -944,6 +964,7 @@ echo "
 	Build GDU volume monitor:     $msg_gdu
 	Build udisks2 volume monitor: $msg_udisks2
 	Build GOA volume monitor:     $msg_goa
+        Use systemd user units:       $msg_systemd_userunits
         Use libsystemd-login:         $msg_libsystemd_login
         Use GCR:                      $msg_gcr
 	GNOME Keyring support:        $msg_keyring
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 79113c7..31a31df 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -39,9 +39,11 @@ servicedir = $(DBUS_SERVICE_DIR)
 service_in_files = org.gtk.vfs.Daemon.service.in
 service_DATA = org.gtk.vfs.Daemon.service
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-daemon.service.in
 systemd_user_DATA = gvfs-daemon.service
+endif
 
 %.mount: %.mount.in ../config.log
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
@@ -120,7 +122,7 @@ libexec_PROGRAMS += gvfsd-archive
 endif
 
 mount_in_files += afc.mount.in
-if USE_AFC
+/if USE_AFC
 mount_DATA += afc.mount
 libexec_PROGRAMS += gvfsd-afc
 endif
diff --git a/metadata/Makefile.am b/metadata/Makefile.am
index e15e40e..ca6105c 100644
--- a/metadata/Makefile.am
+++ b/metadata/Makefile.am
@@ -72,16 +72,23 @@ servicedir = $(DBUS_SERVICE_DIR)
 service_in_files = org.gtk.vfs.Metadata.service.in
 service_DATA = org.gtk.vfs.Metadata.service
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-metadata.service.in
 systemd_user_DATA = gvfs-metadata.service
+endif
 
 EXTRA_DIST =				\
 	$(service_in_files)		\
-	$(systemd_user_in_files)	\
 	dbus-interface.xml		\
 	$(NULL)
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
+EXTRA_DIST += \
+	$(systemd_user_in_files)	\
+        $(NULL)
+endif
+
 CLEANFILES =				\
 	$(dbus_built_sources)		\
 	$(service_DATA)			\
diff --git a/monitor/afc/Makefile.am b/monitor/afc/Makefile.am
index bde7a90..0de8315 100644
--- a/monitor/afc/Makefile.am
+++ b/monitor/afc/Makefile.am
@@ -35,15 +35,19 @@ servicedir = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.AfcVolumeMonitor.service.in
 service_DATA = $(service_in_files:.service.in=.service)
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-afc-volume-monitor.service.in
 systemd_user_DATA = $(systemd_user_in_files:.service.in=.service)
+endif
 
 $(service_DATA): $(service_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
 
 CLEANFILES = \
 	*~ \
@@ -55,6 +59,11 @@ CLEANFILES = \
 
 EXTRA_DIST = \
 	$(service_in_files) \
-	$(systemd_user_in_files) \
 	$(remote_volume_monitors_DATA) \
 	$(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+EXTRA_DIST += \
+	$(systemd_user_in_files) \
+        $(NULL)
+endif
diff --git a/monitor/gdu/Makefile.am b/monitor/gdu/Makefile.am
index 0c5c4e8..c361f39 100644
--- a/monitor/gdu/Makefile.am
+++ b/monitor/gdu/Makefile.am
@@ -43,15 +43,19 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.GduVolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-gdu-volume-monitor.service.in
 systemd_user_DATA = $(systemd_user_in_files:.service.in=.service)
+endif
 
 $(service_DATA): $(service_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
 
 CLEANFILES = \
 	*~ \
@@ -63,6 +67,11 @@ CLEANFILES = \
 
 EXTRA_DIST = \
 	$(service_in_files) \
-	$(systemd_user_in_files) \
 	$(remote_volume_monitors_DATA) \
 	$(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+EXTRA_DIST += \
+	$(systemd_user_in_files) \
+        $(NULL)
+endif
diff --git a/monitor/goa/Makefile.am b/monitor/goa/Makefile.am
index c1c45d9..4421dec 100644
--- a/monitor/goa/Makefile.am
+++ b/monitor/goa/Makefile.am
@@ -35,15 +35,19 @@ servicedir = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.GoaVolumeMonitor.service.in
 service_DATA = $(service_in_files:.service.in=.service)
 
+if HAVE_SYSTEMD_USER_UNIT_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-goa-volume-monitor.service.in
 systemd_user_DATA = $(systemd_user_in_files:.service.in=.service)
+endif
 
 $(service_DATA): $(service_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
 
+if HAVE_SYSTEMD_USER_UNIT_DIR
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
 
 CLEANFILES = \
 	*~ \
@@ -55,6 +59,11 @@ CLEANFILES = \
 
 EXTRA_DIST = \
 	$(service_in_files) \
-	$(systemd_user_in_files) \
 	$(remote_volume_monitors_DATA) \
 	$(NULL)
+
+if HAVE_SYSTEMD_USER_UNIT_DIR
+EXTRA_DIST += \
+	$(systemd_user_in_files) \
+        $(NULL)
+endif
diff --git a/monitor/gphoto2/Makefile.am b/monitor/gphoto2/Makefile.am
index 723fbbc..055db95 100644
--- a/monitor/gphoto2/Makefile.am
+++ b/monitor/gphoto2/Makefile.am
@@ -77,15 +77,19 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.GPhoto2VolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-gphoto2-volume-monitor.service.in
 systemd_user_DATA = $(systemd_user_in_files:.service.in=.service)
+endif
 
 $(service_DATA): $(service_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
 
 CLEANFILES = \
 	*~ \
@@ -101,3 +105,8 @@ EXTRA_DIST = \
 	$(systemd_user_in_files) \
 	$(remote_volume_monitors_DATA) \
 	$(NULL)
+if HAVE_SYSTEMD_USER_UNITS_DIR
+EXTRA_DIST += \
+	$(systemd_user_in_files) \
+        $(NULL)
+endif
diff --git a/monitor/hal/Makefile.am b/monitor/hal/Makefile.am
index 888268f..ef5c7ec 100644
--- a/monitor/hal/Makefile.am
+++ b/monitor/hal/Makefile.am
@@ -56,15 +56,19 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.HalVolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-hal-volume-monitor.service.in
 systemd_user_DATA = $(systemd_user_in_files:.service.in=.service)
+endif
 
 $(service_DATA): $(service_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
 
 CLEANFILES = \
 	*~ \
@@ -77,6 +81,11 @@ CLEANFILES = \
 EXTRA_DIST = \
 	hal-marshal.list \
 	$(service_in_files) \
-	$(systemd_user_in_files) \
 	$(remote_volume_monitors_DATA) \
 	$(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+EXTRA_DIST += \
+	$(systemd_user_in_files) \
+        $(NULL)
+endif
diff --git a/monitor/mtp/Makefile.am b/monitor/mtp/Makefile.am
index 98e64b3..35f927d 100644
--- a/monitor/mtp/Makefile.am
+++ b/monitor/mtp/Makefile.am
@@ -40,15 +40,19 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.MTPVolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-mtp-volume-monitor.service.in
 systemd_user_DATA = $(systemd_user_in_files:.service.in=.service)
+endif
 
 $(service_DATA): $(service_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
 
 CLEANFILES = \
 	*~ \
@@ -60,6 +64,11 @@ CLEANFILES = \
 
 EXTRA_DIST = \
 	$(service_in_files) \
-	$(systemd_user_in_files) \
 	$(remote_volume_monitors_DATA) \
 	$(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
+	$(systemd_user_in_files) \
+        $(NULL)
+endif
diff --git a/monitor/udisks2/Makefile.am b/monitor/udisks2/Makefile.am
index 5c0a801..6aa02b2 100644
--- a/monitor/udisks2/Makefile.am
+++ b/monitor/udisks2/Makefile.am
@@ -48,15 +48,18 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.UDisks2VolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
 systemd_userdir = ${prefix}/lib/systemd/user
 systemd_user_in_files = gvfs-udisks2-volume-monitor.service.in
 systemd_user_DATA = $(systemd_user_in_files:.service.in=.service)
+endif
 
 $(service_DATA): $(service_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
-
+if HAVE_SYSTEMD_USER_UNITS_DIR
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
 
 CLEANFILES = \
 	*~ \
@@ -69,6 +72,10 @@ CLEANFILES = \
 EXTRA_DIST = \
 	what-is-shown.txt \
 	$(service_in_files) \
-	$(systemd_user_in_files) \
 	$(remote_volume_monitors_DATA) \
 	$(NULL)
+if HAVE_SYSTEMD_USER_UNITS_DIR
+EXTRA_DIST += \
+	$(systemd_user_in_files) \
+        $(NULL)
+endif
