576df0
diff --git a/Makefile.in b/Makefile.in
576df0
index ea8366e..06b8c5a 100644
576df0
--- a/Makefile.in
576df0
+++ b/Makefile.in
576df0
@@ -4,7 +4,7 @@ CLEAN_SUBDIRS = test
576df0
 
576df0
 PROGRAM_NAME         = $(progname)
576df0
 PROGRAM_SOURCES      = modules.c
576df0
-PROGRAM_LDADD        = buildmark.o $(HTTPD_LDFLAGS) $(PROGRAM_DEPENDENCIES) $(PCRE_LIBS) $(EXTRA_LIBS) $(AP_LIBS) $(LIBS)
576df0
+PROGRAM_LDADD        = buildmark.o $(HTTPD_LDFLAGS) $(PROGRAM_DEPENDENCIES) $(HTTPD_LIBS) $(EXTRA_LIBS) $(AP_LIBS) $(LIBS)
576df0
 PROGRAM_PRELINK      = $(COMPILE) -c $(top_srcdir)/server/buildmark.c
576df0
 PROGRAM_DEPENDENCIES = \
576df0
   server/libmain.la \
576df0
diff --git a/acinclude.m4 b/acinclude.m4
576df0
index ce1d637..0ad0c13 100644
576df0
--- a/acinclude.m4
576df0
+++ b/acinclude.m4
576df0
@@ -606,6 +606,30 @@ AC_DEFUN([APACHE_CHECK_OPENSSL],[
576df0
   fi
576df0
 ])
576df0
 
576df0
+AC_DEFUN(APACHE_CHECK_SYSTEMD, [                                                                        
576df0
+dnl Check for systemd support for listen.c's socket activation.
576df0
+case $host in
576df0
+*-linux-*)
576df0
+   if test -n "$PKGCONFIG" && $PKGCONFIG --exists libsystemd; then
576df0
+      SYSTEMD_LIBS=`$PKGCONFIG --libs libsystemd`
576df0
+   elif test -n "$PKGCONFIG" && $PKGCONFIG --exists libsystemd-daemon; then
576df0
+      SYSTEMD_LIBS=`$PKGCONFIG --libs libsystemd-daemon`
576df0
+   else
576df0
+      AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon")
576df0
+   fi
576df0
+   if test -n "$SYSTEMD_LIBS"; then
576df0
+      AC_CHECK_HEADERS(systemd/sd-daemon.h)
576df0
+      if test "${ac_cv_header_systemd_sd_daemon_h}" = "no" || test -z "${SYSTEMD_LIBS}"; then
576df0
+        AC_MSG_WARN([Your system does not support systemd.])
576df0
+      else
576df0
+        APR_ADDTO(HTTPD_LIBS, [$SYSTEMD_LIBS])
576df0
+        AC_DEFINE(HAVE_SYSTEMD, 1, [Define if systemd is supported])
576df0
+      fi
576df0
+   fi
576df0
+   ;;
576df0
+esac
576df0
+])
576df0
+
576df0
 dnl
576df0
 dnl APACHE_EXPORT_ARGUMENTS
576df0
 dnl Export (via APACHE_SUBST) the various path-related variables that
576df0
diff --git a/configure.in b/configure.in
576df0
index 82bfeef..eedba50 100644
576df0
--- a/configure.in
576df0
+++ b/configure.in
576df0
@@ -234,6 +234,7 @@ if test "$PCRE_CONFIG" != "false"; then
576df0
   AC_MSG_NOTICE([Using external PCRE library from $PCRE_CONFIG])
576df0
   APR_ADDTO(PCRE_INCLUDES, [`$PCRE_CONFIG --cflags`])
576df0
   APR_ADDTO(PCRE_LIBS, [`$PCRE_CONFIG --libs`])
576df0
+  APR_ADDTO(HTTPD_LIBS, [\$(PCRE_LIBS)])
576df0
 else
576df0
   AC_MSG_ERROR([pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/])
576df0
 fi
576df0
@@ -504,6 +505,8 @@ if test "$ac_cv_struct_tm_gmtoff" = "yes"; then
576df0
     AC_DEFINE(HAVE_GMTOFF, 1, [Define if struct tm has a tm_gmtoff field])
576df0
 fi
576df0
 
576df0
+APACHE_CHECK_SYSTEMD
576df0
+
576df0
 dnl ## Set up any appropriate OS-specific environment variables for apachectl
576df0
 
576df0
 case $host in
576df0
@@ -677,6 +680,7 @@ APACHE_SUBST(OS_DIR)
576df0
 APACHE_SUBST(BUILTIN_LIBS)
576df0
 APACHE_SUBST(SHLIBPATH_VAR)
576df0
 APACHE_SUBST(OS_SPECIFIC_VARS)
576df0
+APACHE_SUBST(HTTPD_LIBS)
576df0
 
576df0
 PRE_SHARED_CMDS='echo ""'
576df0
 POST_SHARED_CMDS='echo ""'