From 5485794187848d6da049c54ca7cf551bfeafd9e8 Mon Sep 17 00:00:00 2001
From: Umut Tezduyar <umut@tezduyar.com>
Date: Sat, 1 Jun 2013 23:07:34 +0200
Subject: [PATCH] build-sys: option to disable tmpfiles

---
 Makefile.am                                        | 54 +++++++++++++++-------
 configure.ac                                       | 11 ++++-
 units/.gitignore                                   |  1 +
 ...ervice.in => systemd-update-utmp.service.m4.in} |  5 +-
 4 files changed, 53 insertions(+), 18 deletions(-)
 rename units/{systemd-update-utmp.service.in => systemd-update-utmp.service.m4.in} (85%)

diff --git a/Makefile.am b/Makefile.am
index e63563f..ac75112 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -280,9 +280,13 @@ rootbin_PROGRAMS = \
 	systemd-notify \
 	systemd-ask-password \
 	systemd-tty-ask-password-agent \
-	systemd-tmpfiles \
 	systemd-machine-id-setup
 
+if ENABLE_TMPFILES
+rootbin_PROGRAMS += \
+	systemd-tmpfiles
+endif
+
 bin_PROGRAMS = \
 	systemd-cgls \
 	systemd-cgtop \
@@ -336,18 +340,20 @@ dist_bashcompletion_DATA = \
 	shell-completion/bash/systemd-analyze \
 	shell-completion/bash/udevadm
 
+if ENABLE_TMPFILES
 dist_tmpfiles_DATA = \
 	tmpfiles.d/systemd.conf \
 	tmpfiles.d/tmp.conf \
 	tmpfiles.d/x11.conf
 
-dist_sysctl_DATA = \
-	sysctl.d/50-default.conf
-
 if HAVE_SYSV_COMPAT
 dist_tmpfiles_DATA += \
 	tmpfiles.d/legacy.conf
 endif
+endif
+
+dist_sysctl_DATA = \
+	sysctl.d/50-default.conf
 
 dist_systemunit_DATA = \
 	units/graphical.target \
@@ -400,7 +406,6 @@ dist_systemunit_DATA = \
 	units/sound.target \
 	units/bluetooth.target \
 	units/smartcard.target \
-	units/systemd-tmpfiles-clean.timer \
 	units/quotaon.service \
 	units/systemd-ask-password-wall.path \
 	units/systemd-ask-password-console.path \
@@ -419,9 +424,6 @@ nodist_systemunit_DATA = \
 	units/systemd-remount-fs.service \
 	units/systemd-update-utmp.service \
 	units/systemd-update-utmp-runlevel.service \
-	units/systemd-tmpfiles-setup-dev.service \
-	units/systemd-tmpfiles-setup.service \
-	units/systemd-tmpfiles-clean.service \
 	units/systemd-ask-password-wall.service \
 	units/systemd-ask-password-console.service \
 	units/systemd-sysctl.service \
@@ -463,11 +465,8 @@ EXTRA_DIST += \
 	units/systemd-initctl.service.in \
 	units/systemd-shutdownd.service.in \
 	units/systemd-remount-fs.service.in \
-	units/systemd-update-utmp.service.in \
+	units/systemd-update-utmp.service.m4.in \
 	units/systemd-update-utmp-runlevel.service.in \
-	units/systemd-tmpfiles-setup-dev.service.in \
-	units/systemd-tmpfiles-setup.service.in \
-	units/systemd-tmpfiles-clean.service.in \
 	units/systemd-ask-password-wall.service.in \
 	units/systemd-ask-password-console.service.in \
 	units/systemd-sysctl.service.in \
@@ -500,6 +499,19 @@ CLEANFILES += \
 	units/console-getty.service.m4 \
 	units/rescue.service.m4
 
+if ENABLE_TMPFILES
+dist_systemunit_DATA += \
+	units/systemd-tmpfiles-clean.timer
+nodist_systemunit_DATA += \
+	units/systemd-tmpfiles-setup-dev.service \
+	units/systemd-tmpfiles-setup.service \
+	units/systemd-tmpfiles-clean.service
+EXTRA_DIST += \
+	units/systemd-tmpfiles-setup-dev.service.in \
+	units/systemd-tmpfiles-setup.service.in \
+	units/systemd-tmpfiles-clean.service.in
+endif
+
 if HAVE_SYSV_COMPAT
 nodist_systemunit_DATA += \
 	units/rc-local.service \
@@ -1437,6 +1449,7 @@ EXTRA_DIST += \
 	units/systemd-modules-load.service.in
 
 # ------------------------------------------------------------------------------
+if ENABLE_TMPFILES
 systemd_tmpfiles_SOURCES = \
 	src/tmpfiles/tmpfiles.c
 
@@ -1444,6 +1457,7 @@ systemd_tmpfiles_LDADD = \
 	libsystemd-label.la \
 	libsystemd-shared.la \
 	libsystemd-capability.la
+endif
 
 # ------------------------------------------------------------------------------
 systemd_machine_id_setup_SOURCES = \
@@ -4115,12 +4129,16 @@ SYSINIT_TARGET_WANTS += \
 	sys-kernel-config.mount \
 	sys-kernel-debug.mount \
 	sys-fs-fuse-connections.mount \
-	systemd-tmpfiles-setup-dev.service \
-	systemd-tmpfiles-setup.service \
 	systemd-sysctl.service \
 	systemd-ask-password-console.path
+
+if ENABLE_TMPFILES
+SYSINIT_TARGET_WANTS += \
+	systemd-tmpfiles-setup-dev.service \
+	systemd-tmpfiles-setup.service
 TIMERS_TARGET_WANTS += \
 	systemd-tmpfiles-clean.timer
+endif
 
 if HAVE_SYSV_COMPAT
 SYSTEM_UNIT_ALIASES += \
@@ -4164,8 +4182,6 @@ INSTALL_DIRS += \
 endif
 
 INSTALL_DIRS += \
-	$(tmpfilesdir) \
-	$(sysconfdir)/tmpfiles.d \
 	$(prefix)/lib/modules-load.d \
 	$(sysconfdir)/modules-load.d \
 	$(prefix)/lib/sysctl.d \
@@ -4185,6 +4201,12 @@ INSTALL_DIRS += \
 	$(dbussessionservicedir) \
 	$(sysconfdir)/xdg/systemd
 
+if ENABLE_TMPFILES
+INSTALL_DIRS += \
+	$(tmpfilesdir) \
+	$(sysconfdir)/tmpfiles.d
+endif
+
 install-exec-hook: $(INSTALL_EXEC_HOOKS)
 
 uninstall-hook: $(UNINSTALL_DATA_HOOKS) $(UNINSTALL_EXEC_HOOKS)
diff --git a/configure.ac b/configure.ac
index c24b4a8..68457c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -617,6 +617,15 @@ fi
 AM_CONDITIONAL(ENABLE_QUOTACHECK, [test "$have_quotacheck" = "yes"])
 
 # ------------------------------------------------------------------------------
+have_tmpfiles=no
+AC_ARG_ENABLE(tmpfiles, AS_HELP_STRING([--disable-tmpfiles], [disable tmpfiles support]))
+if test "x$enable_tmpfiles" != "xno"; then
+        M4_DEFINES="$M4_DEFINES -DHAVE_TMPFILES"
+        have_tmpfiles=yes
+fi
+AM_CONDITIONAL(ENABLE_TMPFILES, [test "$have_tmpfiles" = "yes"])
+
+# ------------------------------------------------------------------------------
 have_randomseed=no
 AC_ARG_ENABLE(randomseed, AS_HELP_STRING([--disable-randomseed], [disable randomseed tools]))
 if test "x$enable_randomseed" != "xno"; then
@@ -810,7 +819,6 @@ AM_CONDITIONAL(ENABLE_MANPAGES, [test "x$have_manpages" = "xyes"])
 # Location of the init scripts as mandated by LSB
 SYSTEM_SYSVINIT_PATH=/etc/init.d
 SYSTEM_SYSVRCND_PATH=/etc/rc.d
-M4_DEFINES=
 
 AC_ARG_WITH([sysvinit-path],
         [AS_HELP_STRING([--with-sysvinit-path=PATH],
@@ -954,6 +962,7 @@ AC_MSG_RESULT([
         readahead:               ${have_readahead}
         bootchart:               ${have_bootchart}
         quotacheck:              ${have_quotacheck}
+        tmpfiles:                ${have_tmpfiles}
         randomseed:              ${have_randomseed}
         logind:                  ${have_logind}
         hostnamed:               ${have_hostnamed}
diff --git a/units/.gitignore b/units/.gitignore
index 878cf2c..20c3b2b 100644
--- a/units/.gitignore
+++ b/units/.gitignore
@@ -45,6 +45,7 @@
 /systemd-initctl.service
 /getty@.service
 /systemd-update-utmp.service
+/systemd-update-utmp.service.m4
 /systemd-update-utmp-runlevel.service
 /systemd-binfmt.service
 /emergency.service
diff --git a/units/systemd-update-utmp.service.in b/units/systemd-update-utmp.service.m4.in
similarity index 85%
rename from units/systemd-update-utmp.service.in
rename to units/systemd-update-utmp.service.m4.in
index e7c20a5..a755437 100644
--- a/units/systemd-update-utmp.service.in
+++ b/units/systemd-update-utmp.service.m4.in
@@ -11,7 +11,10 @@ Documentation=man:systemd-update-utmp.service(8) man:utmp(5)
 DefaultDependencies=no
 RequiresMountsFor=/var/log/wtmp
 Conflicts=shutdown.target
-After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-remount-fs.service systemd-tmpfiles-setup.service auditd.service
+After=systemd-readahead-collect.service systemd-readahead-replay.service systemd-remount-fs.service auditd.service
+m4_ifdef(`HAVE_TMPFILES',
+After=systemd-tmpfiles-setup.service
+)m4_dnl
 Before=sysinit.target shutdown.target
 
 [Service]
-- 
1.8.2.3

