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

    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
    
    Possibility to not install systemd related stuff when it not needed.
    That allows you to change the target location for systemd user units.
    For details, see https://bugzilla.gnome.org/show_bug.cgi?id=760293

diff --git a/configure.ac b/configure.ac
index bb358c6..fd18d6b 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-systemduserunitdir=PATH],
+            [specify the location or disable systemd user units support])],
+        [systemd_user_units=$withval],
+        [msg_systemd_user_units=yes])
+
+if test "x$systemd_user_units" != "xno"; then
+    PKG_CHECK_MODULES([SYSTEMD], [systemd >= 206],
+        AC_SUBST(systemd_user_units_dir, [$systemd_user_dir]))
+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..5a79c35 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
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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)|" $< > $@
@@ -141,21 +143,30 @@ noinst_DATA = $(mount_DATA:.mount=.localmount)
 
 EXTRA_DIST = 				\
 	$(service_in_files)		\
-	$(systemd_user_in_files)	\
 	$(mount_in_files)		\
 	$(gvfs_gschemas_dist)		\
 	$(gvfs_gschemas_convert_dist)	\
 	$(gsettings_ENUM_FILES)		\
 	$(NULL)
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
+EXTRA_DIST += \
+	$(systemd_user_in_files) \
+        $(NULL)
+endif
+
 DISTCLEANFILES = $(mount_DATA) $(noinst_DATA)
 
 CLEANFILES =					\
 	$(gsettings__enum_file)			\
 	$(service_DATA)				\
-	$(systemd_user_DATA)			\
 	*.gschema.valid
 
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
+	$(systemd_user_DATA)
+endif
+
 noinst_PROGRAMS =				\
 	gvfsd-test			\
 	$(NULL)
diff --git a/metadata/Makefile.am b/metadata/Makefile.am
index e15e40e..95877e1 100644
--- a/metadata/Makefile.am
+++ b/metadata/Makefile.am
@@ -72,18 +72,30 @@ servicedir = $(DBUS_SERVICE_DIR)
 service_in_files = org.gtk.vfs.Metadata.service.in
 service_DATA = org.gtk.vfs.Metadata.service
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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)			\
+        $(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
 	$(systemd_user_DATA)		\
 	$(NULL)
+endif
diff --git a/monitor/afc/Makefile.am b/monitor/afc/Makefile.am
index bde7a90..9c765d1 100644
--- a/monitor/afc/Makefile.am
+++ b/monitor/afc/Makefile.am
@@ -35,26 +35,40 @@ servicedir = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.AfcVolumeMonitor.service.in
 service_DATA = $(service_in_files:.service.in=.service)
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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 = \
 	*~ \
 	*.loT \
 	$(BUILT_SOURCES) \
 	$(service_DATA) \
+        $(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
 	$(systemd_user_DATA) \
 	$(NULL)
+endif
 
 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..bf29090 100644
--- a/monitor/gdu/Makefile.am
+++ b/monitor/gdu/Makefile.am
@@ -43,26 +43,40 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.GduVolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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 = \
 	*~ \
 	*.loT \
 	$(BUILT_SOURCES) \
 	$(service_DATA) \
+        $(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
 	$(systemd_user_DATA) \
 	$(NULL)
+endif
 
 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..5a2b550 100644
--- a/monitor/goa/Makefile.am
+++ b/monitor/goa/Makefile.am
@@ -35,26 +35,40 @@ servicedir = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.GoaVolumeMonitor.service.in
 service_DATA = $(service_in_files:.service.in=.service)
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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_UNITS_DIR
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
 	$(AM_V_GEN) $(SED) -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+endif
 
 CLEANFILES = \
 	*~ \
 	*.loT \
 	$(BUILT_SOURCES) \
 	$(service_DATA) \
+        $(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
 	$(systemd_user_DATA) \
 	$(NULL)
+endif
 
 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/gphoto2/Makefile.am b/monitor/gphoto2/Makefile.am
index 723fbbc..73582b2 100644
--- a/monitor/gphoto2/Makefile.am
+++ b/monitor/gphoto2/Makefile.am
@@ -77,27 +77,41 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.GPhoto2VolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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 = \
 	*~ \
 	*.loT \
 	$(BUILT_SOURCES) \
 	$(service_DATA) \
+        $(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
 	$(systemd_user_DATA) \
 	$(NULL)
+endif
 
 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/hal/Makefile.am b/monitor/hal/Makefile.am
index 888268f..e5147e7 100644
--- a/monitor/hal/Makefile.am
+++ b/monitor/hal/Makefile.am
@@ -56,27 +56,41 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.HalVolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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 = \
 	*~ \
 	*.loT \
 	$(BUILT_SOURCES) \
 	$(service_DATA) \
+        $(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
 	$(systemd_user_DATA) \
 	$(NULL)
+endif
 
 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..ec05ce9 100644
--- a/monitor/mtp/Makefile.am
+++ b/monitor/mtp/Makefile.am
@@ -40,26 +40,40 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.MTPVolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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 = \
 	*~ \
 	*.loT \
 	$(BUILT_SOURCES) \
 	$(service_DATA) \
+        $(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
 	$(systemd_user_DATA) \
 	$(NULL)
+endif
 
 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/udisks2/Makefile.am b/monitor/udisks2/Makefile.am
index 5c0a801..d427c9d 100644
--- a/monitor/udisks2/Makefile.am
+++ b/monitor/udisks2/Makefile.am
@@ -48,27 +48,40 @@ servicedir       = $(datadir)/dbus-1/services
 service_in_files = org.gtk.vfs.UDisks2VolumeMonitor.service.in
 service_DATA     = $(service_in_files:.service.in=.service)
 
-systemd_userdir = ${prefix}/lib/systemd/user
+if HAVE_SYSTEMD_USER_UNITS_DIR
+systemd_userdir = @systemd_user_units_dir@
 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 = \
 	*~ \
 	*.loT \
 	$(BUILT_SOURCES) \
 	$(service_DATA) \
+        $(NULL)
+
+if HAVE_SYSTEMD_USER_UNITS_DIR
+CLEANFILES += \
 	$(systemd_user_DATA) \
 	$(NULL)
 
 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
