From dfc46ddcdf777f371c8b298684d055ef39d92330 Mon Sep 17 00:00:00 2001 From: Kara <33235324+kro-cat@users.noreply.github.com> Date: Fri, 7 Jun 2024 10:58:48 -0500 Subject: [PATCH] fsm_init: fix implicit function declaration _IceTransNoListen A declaration is required for `_IceTransNoListen` to link against libICE. `_IceTransNoListen` is declared in X11/Xtrans/Xtrans.h (`xtrans-dev`) only when configured for libICE by defining the following symbols: `ICE_t` `TRANS_SERVER`. (see [libICE configure.ac](https://gitlab.freedesktop.org/xorg/lib/libice/-/blob/master/configure.ac)) Add a check in configure.ac to determine if the build system has X11/Xtrans/Xtrans.h, and define `ICE_t` and `TRANS_SERVER` if it does. Add a preprocessor step in lib/fsm.c to switch between using Xtrans.h or an extern declaration for the `_IceTransNoListen` symbol depending on whether or not the build system has Xtrans.h. Fixes #1031 Signed-off-by: Kara <33235324+kro-cat@users.noreply.github.com> --- configure.ac | 6 +++++- libs/fsm.c | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a57b52482..857ae4329 100644 --- a/configure.ac +++ b/configure.ac @@ -379,7 +379,11 @@ if test ! x"$with_sm" = xno; then [$X_LIBS $X_PRE_LIBS -lX11 $X_EXTRA_LIBS]) ac_LIBS="$LIBS" LIBS="$LIBS -lICE" - AC_CHECK_FUNCS([_IceTransNoListen]) + AC_CHECK_FUNCS([_IceTransNoListen], + [AC_CHECK_HEADERS([X11/Xtrans/Xtrans.h], + [AC_DEFINE(ICE_t, 1, [Xtrans transport type]) + dnl AC_DEFINE(TRANS_CLIENT, 1, [Xtrans transport client code]) + AC_DEFINE(TRANS_SERVER, 1, [Xtrans transport server code])])]) LIBS="$ac_LIBS" fi dnl AC_SUBST(sm_LIBS) diff --git a/libs/fsm.c b/libs/fsm.c index 36e665b0a..dba5f0b2c 100644 --- a/libs/fsm.c +++ b/libs/fsm.c @@ -33,6 +33,11 @@ #include #include #include +#if defined(HAVE_X11_XTRANS_XTRANS_H) && defined(HAVE__ICETRANSNOLISTEN) +#include +#elif defined(HAVE__ICETRANSNOLISTEN) +extern void _IceTransNoListen(char *protocol); +#endif #include "fvwmlib.h" #include "System.h"