]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Makefile.am: Fix systemd detection mess in automake
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 26 Apr 2021 05:39:50 +0000 (08:39 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 26 Apr 2021 11:22:19 +0000 (14:22 +0300)
Makefile.am
configure.ac
m4/want_systemd.m4 [new file with mode: 0644]

index 34f58c79a87c624113e6d979d64a2301aabd1d27..dee457c152e474f7c34244139ad8c324c7b164eb 100644 (file)
@@ -59,7 +59,6 @@ dovecot-config: dovecot-config.in Makefile
        -e "s|^\(dovecot_statedir\)=|\1=$(statedir)|" \
        ) > dovecot-config
 
-if HAVE_LIBSYSTEMD
 %.service: %.service.in
        $(AM_V_GEN)sed -e 's,@sbindir\@,$(sbindir),g' \
        -e 's,@bindir\@,$(bindir),g' \
@@ -67,6 +66,7 @@ if HAVE_LIBSYSTEMD
        -e 's,@systemdservicetype\@,$(systemdservicetype),g' \
        $< > $@
 
+if WANT_SYSTEMD
 systemdsystemunit_DATA = \
         dovecot.socket \
         dovecot.service
@@ -92,7 +92,7 @@ install-exec-hook:
 uninstall-hook:
        rm $(DESTDIR)$(pkglibdir)/dovecot-config
 
-if HAVE_LIBSYSTEMD
+if WANT_SYSTEMD
 CLEANFILES = dovecot.service
 endif
 
index 19242beb602fee303d55fdf7d9c59064d3801f24..75ab282a84b1180ad86ac8c3322465af007e41f1 100644 (file)
@@ -241,26 +241,11 @@ AC_SUBST(statedir)
 
 AC_ARG_WITH([systemd],
    AS_HELP_STRING([--with-systemd], [Build with systemd support (default=auto)]),
-   want_systemd="$withval"
+   want_systemd="$withval",
+   want_systemd="auto"
 )
 
-systemdservicetype='simple'
-
-AS_IF([test "$want_systemd" != "no"], [
-  PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [
-    AC_DEFINE([HAVE_LIBSYSTEMD],[1], [Define to 1 if you have libsystemd])
-    systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
-    systemdservicetype='notify'
-  ], [AS_IF([test "$want_systemd" = "yes"], [
-       AC_MSG_ERROR([libsystemd not found])
-     ],
-     [want_systemd="no"])
-  ])
-])
-
-AC_SUBST(systemdsystemunitdir)
-AC_SUBST(systemdservicetype)
-AM_CONDITIONAL(HAVE_LIBSYSTEMD, [test "$want_systemd" != "no"])
+DOVECOT_WANT_SYSTEMD
 
 dovecot_moduledir="$libdir/dovecot"
 DC_DOVECOT_MODULEDIR
@@ -968,6 +953,13 @@ if test "$not_userdb" != ""; then
   echo "                 :$not_userdb"
 fi
 echo "CFLAGS ......... : $CFLAGS"
+
+if test "$systemdsystemunitdir" != ""; then
+  echo "SYSTEMD ........ : $systemdservicetype - $systemdsystemunitdir/dovecot.service";
+else
+  echo "SYSTEMD ........ : $systemdservicetype - (no unit file)"
+fi
+
 echo "SQL drivers .... :$sql_drivers"
 if test "$not_sql_drivers" != ""; then
   echo "                 :$not_sql_drivers"
diff --git a/m4/want_systemd.m4 b/m4/want_systemd.m4
new file mode 100644 (file)
index 0000000..fbccbc2
--- /dev/null
@@ -0,0 +1,36 @@
+dnl Checks for libsystemd existence and where
+dnl to put systemd unit files. You can have
+dnl systemd units without libsystemd.
+
+AC_DEFUN([DOVECOT_WANT_SYSTEMD], [
+  systemdservicetype='simple'
+  have_libsystemd=no
+
+  AS_IF([test "$want_systemd" != "no"], [
+    dnl Check for actual systemd integration
+    PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [
+      AC_DEFINE([HAVE_LIBSYSTEMD],[1], [Define to 1 if you have libsystemd])
+      systemdservicetype='notify'
+      have_libsystemd=yes
+    ], AS_IF([test "$want_systemd" = "yes"], [
+         AC_MSG_WARN([libsystemd not found - full integration disabled])
+       ])
+    )
+    dnl Check for unit file installation
+    AC_MSG_CHECKING([for systemd unit directory])
+    AS_IF([test "$systemdsystemunitdir" = ""], [
+       PKG_CHECK_VAR([systemdsystemunitdir], [systemd], [systemdsystemunitdir])
+    ])
+    AC_MSG_RESULT([$systemdsystemunitdir])
+    AS_IF([test "$systemdsystemunitdir" = ""], [
+      AS_IF([test "$want_systemd" = "yes"], [
+        AC_MSG_ERROR([Cannot determine where to put systemd files - Provide systemdsystemunitdir manually])
+      ])
+      dnl Cannot enable even unit file installation.
+      want_systemd=no
+    ])
+  ])
+  AC_SUBST(systemdsystemunitdir)
+  AC_SUBST(systemdservicetype)
+  AM_CONDITIONAL(WANT_SYSTEMD, [test "$want_systemd" != "no"])
+])