[PATCHv3] build: Fix systemd-daemon compile/linker flags

Peter Hutterer peter.hutterer at who-t.net
Sun Nov 22 15:37:39 PST 2015


On Thu, Nov 19, 2015 at 04:04:30PM +0200, Jussi Kukkonen wrote:
> * Dont add systemd to REQUIRED_LIBS (this lead to build failure when
>   libsystemd is available but libsystemd-daemon is not)
> * Only use systemd compile and linker flags where needed (libxtrans)
> * Try libsystemd (>= 210) first so it's used instead of the
>   libsystemd-daemon wrapper that might also exist
> 
> Signed-off-by: Jussi Kukkonen <jussi.kukkonen at intel.com>
> ---
> 
> Let's try once more. Tried to address Peters comments by limiting
> systemd flag use to libos.la. Also fixed the issue Emil pointed out
> by checking only for libsystemd versions that actually provide the
> required api.
> 
> Note that the actual systemd-daemon api use is not in xserver, but
> in the xtrans "library" (at least that's the only one I could find).

unfortunately, this one doesn't work when dtrace is enabled (it works fine
otherwise). libos.la is the only one where appending a library isn't easy
because we convert libos.la to a dtrace object os.O and link that in - and
that makes us lose the dependency. So maybe it's better to go down the
original path with the REQUIRED_LIBS after all, anything else is going to be
messier than a local hack. How about something like this:

diff --git a/configure.ac b/configure.ac
index 14a5bb8..ecb4263 100644
--- a/configure.ac
+++ b/configure.ac
@@ -836,21 +836,21 @@ AC_ARG_WITH([systemd-daemon],
 	AS_HELP_STRING([--with-systemd-daemon],
 		[support systemd socket activation (default: auto)]),
 	[WITH_SYSTEMD_DAEMON=$withval], [WITH_SYSTEMD_DAEMON=auto])
-PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
-                  [HAVE_SYSTEMD_DAEMON=yes],
-                  [PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd],
-                                     [HAVE_SYSTEMD_DAEMON=yes], [HAVE_SYSTEMD_DAEMON=no])])
+PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd >= 210],
+                  [HAVE_SYSTEMD_DAEMON="libsystemd"],
+                  [PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
+                                     [HAVE_SYSTEMD_DAEMON="libsystemd-daemon"], [HAVE_SYSTEMD_DAEMON=no])])
 if test "x$WITH_SYSTEMD_DAEMON" = xauto; then
 	WITH_SYSTEMD_DAEMON="$HAVE_SYSTEMD_DAEMON"
 fi
-if test "x$WITH_SYSTEMD_DAEMON" = xyes; then
+if test "x$WITH_SYSTEMD_DAEMON" != xno; then
 	if test "x$HAVE_SYSTEMD_DAEMON" = xno; then
 		AC_MSG_ERROR([systemd support requested but no library has been found])
 	fi
 	AC_DEFINE(HAVE_SYSTEMD_DAEMON, 1, [Define to 1 if libsystemd-daemon is available])
-	REQUIRED_LIBS="$REQUIRED_LIBS libsystemd-daemon"
+	REQUIRED_LIBS="$REQUIRED_LIBS $HAVE_SYSTEMD_DAEMON"
 fi
-AM_CONDITIONAL([HAVE_SYSTEMD_DAEMON], [test "x$HAVE_SYSTEMD_DAEMON" = "xyes"])
+AM_CONDITIONAL([HAVE_SYSTEMD_DAEMON], [test "x$HAVE_SYSTEMD_DAEMON" != "xno"])
 
 if test "x$CONFIG_UDEV" = xyes && test "x$CONFIG_HAL" = xyes; then
 	AC_MSG_ERROR([Hotplugging through both libudev and hal not allowed])

best to rename it to "SYSTEMD_PKG" or so instead of HAVE_SYSTEMD_DAEMON, a
bit more testing and it should be fine?

Cheers,
   Peter

>  configure.ac   | 5 ++---
>  os/Makefile.am | 4 ++--
>  2 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 14a5bb8..997b5e5 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -836,9 +836,9 @@ AC_ARG_WITH([systemd-daemon],
>  	AS_HELP_STRING([--with-systemd-daemon],
>  		[support systemd socket activation (default: auto)]),
>  	[WITH_SYSTEMD_DAEMON=$withval], [WITH_SYSTEMD_DAEMON=auto])
> -PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
> +PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd >= 210],
>                    [HAVE_SYSTEMD_DAEMON=yes],
> -                  [PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd],
> +                  [PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon],
>                                       [HAVE_SYSTEMD_DAEMON=yes], [HAVE_SYSTEMD_DAEMON=no])])
>  if test "x$WITH_SYSTEMD_DAEMON" = xauto; then
>  	WITH_SYSTEMD_DAEMON="$HAVE_SYSTEMD_DAEMON"
> @@ -848,7 +848,6 @@ if test "x$WITH_SYSTEMD_DAEMON" = xyes; then
>  		AC_MSG_ERROR([systemd support requested but no library has been found])
>  	fi
>  	AC_DEFINE(HAVE_SYSTEMD_DAEMON, 1, [Define to 1 if libsystemd-daemon is available])
> -	REQUIRED_LIBS="$REQUIRED_LIBS libsystemd-daemon"
>  fi
>  AM_CONDITIONAL([HAVE_SYSTEMD_DAEMON], [test "x$HAVE_SYSTEMD_DAEMON" = "xyes"])
>  
> diff --git a/os/Makefile.am b/os/Makefile.am
> index a1bbb4d..c1e2cb5 100644
> --- a/os/Makefile.am
> +++ b/os/Makefile.am
> @@ -1,6 +1,6 @@
>  noinst_LTLIBRARIES = libos.la
>  
> -AM_CFLAGS = $(DIX_CFLAGS) $(SHA1_CFLAGS)
> +AM_CFLAGS = $(DIX_CFLAGS) $(SHA1_CFLAGS) $(SYSTEMD_DAEMON_CFLAGS)
>  
>  SECURERPC_SRCS = rpcauth.c
>  XDMCP_SRCS = xdmcp.c
> @@ -25,7 +25,7 @@ libos_la_SOURCES = 	\
>  	xstrans.c	\
>  	xprintf.c	\
>  	$(XORG_SRCS)
> -libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS) $(LTLIBOBJS)
> +libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS) $(SYSTEMD_DAEMON_LIBS) $(LTLIBOBJS)
>  
>  if SECURE_RPC
>  libos_la_SOURCES += $(SECURERPC_SRCS)
> -- 
> 2.6.2


More information about the xorg-devel mailing list