patch 9.1.1561: configure: wayland test can be improved

Commit: 
https://github.com/vim/vim/commit/138381bde006e035fb42b52e714b4c6b3760a406
Author: Christoffer Aasted <chr.aas...@gmail.com>
Date:   Thu Jul 17 21:11:06 2025 +0200

    patch 9.1.1561: configure: wayland test can be improved
    
    Problem:  configure: wayland test can be improved
    Solution: Define $WAYLAND_CFLAGS, simplify the wayland tests
              (Christoffer Aasted).
    
    closes: #17772
    
    Signed-off-by: Christoffer Aasted <chr.aas...@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/Makefile b/src/Makefile
index 0cf9f8836..175f659d6 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3646,19 +3646,19 @@ objects/window.o: window.c
        $(CCC) -o $@ window.c
 
 objects/wayland.o: wayland.c
-       $(CCC) -o $@ wayland.c
+       $(CCC) $(WAYLAND_CFLAGS) -o $@ wayland.c
 
 objects/wlr-data-control-unstable-v1.o: 
auto/wayland/wlr-data-control-unstable-v1.c
-       $(CCC) -o $@ auto/wayland/wlr-data-control-unstable-v1.c
+       $(CCC) $(WAYLAND_CFLAGS) -o $@ 
auto/wayland/wlr-data-control-unstable-v1.c
 
 objects/ext-data-control-v1.o: auto/wayland/ext-data-control-v1.c
-       $(CCC) -o $@ auto/wayland/ext-data-control-v1.c
+       $(CCC) $(WAYLAND_CFLAGS) -o $@ auto/wayland/ext-data-control-v1.c
 
 objects/xdg-shell.o: auto/wayland/xdg-shell.c
-       $(CCC) -o $@ auto/wayland/xdg-shell.c
+       $(CCC) $(WAYLAND_CFLAGS) -o $@ auto/wayland/xdg-shell.c
 
 objects/primary-selection-unstable-v1.o: 
auto/wayland/primary-selection-unstable-v1.c
-       $(CCC) -o $@ auto/wayland/primary-selection-unstable-v1.c
+       $(CCC) $(WAYLAND_CFLAGS) -o $@ 
auto/wayland/primary-selection-unstable-v1.c
 
 objects/netbeans.o: netbeans.c
        $(CCC) -o $@ netbeans.c
diff --git a/src/auto/configure b/src/auto/configure
index a4123a3fd..d01f38c71 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -678,6 +678,7 @@ xmkmfpath
 WAYLAND_OBJ
 WAYLAND_SRC
 WAYLAND_LIBS
+WAYLAND_CFLAGS
 TERM_TEST
 TERM_OBJ
 TERM_SRC
@@ -9213,120 +9214,49 @@ printf %s "checking --with-wayland argument... " >&6; }
 # Check whether --with-wayland was given.
 if test ${with_wayland+y}
 then :
-  withval=$with_wayland;
-fi
-
-
-test -z "$with_wayland" && with_wayland=yes
-if test "$with_wayland" = yes; then
-  { printf "%s
" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-printf "%s
" "yes" >&6; }
-  { printf "%s
" "$as_me:${as_lineno-$LINENO}: checking if Wayland client header files can be 
found" >&5
-printf %s "checking if Wayland client header files can be found... " >&6; }
-  cppflags_save=$CPPFLAGS
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <wayland-client.h>
-int
-main (void)
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"
-then :
-  { printf "%s
" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-printf "%s
" "yes" >&6; }
+  withval=$with_wayland; with_wayland=$withval
 else case e in #(
-  e) { printf "%s
" "$as_me:${as_lineno-$LINENO}: result: no" >&5
-printf "%s
" "no" >&6; }; no_wl=yes ;;
+  e) with_wayland=yes ;;
 esac
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
-  CPPFLAGS=$cppflags_save
 
-  if test "$no_wl" = yes; then
-    with_wayland=no
-  else
-    { printf "%s
" "$as_me:${as_lineno-$LINENO}: checking for wl_display_connect in 
-lwayland-client" >&5
-printf %s "checking for wl_display_connect in -lwayland-client... " >&6; }
-if test ${ac_cv_lib_wayland_client_wl_display_connect+y}
-then :
-  printf %s "(cached) " >&6
-else case e in #(
-  e) ac_check_lib_save_LIBS=$LIBS
-LIBS="-lwayland-client  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+{ printf "%s
" "$as_me:${as_lineno-$LINENO}: result: $with_wayland" >&5
+printf "%s
" "$with_wayland" >&6; }
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.
-   The 'extern "C"' is for builds by C++ compilers;
-   although this is not generally supported in C code supporting it here
-   has little cost and some practical benefit (sr 110532).  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char wl_display_connect (void);
-int
-main (void)
-{
-return wl_display_connect ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ac_cv_lib_wayland_client_wl_display_connect=yes
-else case e in #(
-  e) ac_cv_lib_wayland_client_wl_display_connect=no ;;
-esac
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS ;;
-esac
-fi
-{ printf "%s
" "$as_me:${as_lineno-$LINENO}: result: 
$ac_cv_lib_wayland_client_wl_display_connect" >&5
-printf "%s
" "$ac_cv_lib_wayland_client_wl_display_connect" >&6; }
-if test "x$ac_cv_lib_wayland_client_wl_display_connect" = xyes
-then :
-  no_wl=no
-fi
-
-
-    if test "$no_wl" = no; then
-      printf "%s
" "#define HAVE_WAYLAND 1" >>confdefs.h
+if test "$with_wayland" = yes; then
+cflags_save=$CFLAGS
+  { printf "%s
" "$as_me:${as_lineno-$LINENO}: checking for wayland" >&5
+printf %s "checking for wayland... " >&6; }
+  if "$PKG_CONFIG" --exists 'wayland-client'; then
+    { printf "%s
" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s
" "yes" >&6; }
+    printf "%s
" "#define HAVE_WAYLAND 1" >>confdefs.h
 
-      WAYLAND_LIBS="-lwayland-client";
+    WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client`
+    CFLAGS="$CFLAGS $WAYLAND_CFLAGS"
+    WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client`
+    WAYLAND_SRC=" \
+      auto/wayland/wlr-data-control-unstable-v1.c \
+      auto/wayland/ext-data-control-v1.c \
+      auto/wayland/xdg-shell.c \
+      auto/wayland/primary-selection-unstable-v1.c \
+      wayland.c"
+    WAYLAND_OBJ=" \
+      objects/wlr-data-control-unstable-v1.o \
+      objects/ext-data-control-v1.o \
+      objects/xdg-shell.o \
+      objects/primary-selection-unstable-v1.o \
+      objects/wayland.o"
 
-      WAYLAND_SRC=" \
-             auto/wayland/wlr-data-control-unstable-v1.c \
-             auto/wayland/ext-data-control-v1.c \
-             auto/wayland/xdg-shell.c \
-             auto/wayland/primary-selection-unstable-v1.c \
-             wayland.c"
 
-      WAYLAND_OBJ=" \
-             objects/wlr-data-control-unstable-v1.o \
-             objects/ext-data-control-v1.o \
-             objects/xdg-shell.o \
-             objects/primary-selection-unstable-v1.o \
-             objects/wayland.o"
 
 
-    else
-      with_wayland=no
-    fi
-  fi
-else
-  { printf "%s
" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+  else
+    { printf "%s
" "$as_me:${as_lineno-$LINENO}: result: no" >&5
 printf "%s
" "no" >&6; }
+    with_wayland=no
+  fi
+CFLAGS=$cflags_save
 fi
 
 test -z "$with_x" && with_x=yes
diff --git a/src/config.mk.in b/src/config.mk.in
index f893e8f0b..78b207ef7 100644
--- a/src/config.mk.in
+++ b/src/config.mk.in
@@ -40,6 +40,7 @@ X_LIBS                = @X_LIB@
 WAYLAND_LIBS    = @WAYLAND_LIBS@
 WAYLAND_SRC    = @WAYLAND_SRC@
 WAYLAND_OBJ    = @WAYLAND_OBJ@
+WAYLAND_CFLAGS    = @WAYLAND_CFLAGS@
 
 XDIFF_OBJS_USED        = @XDIFF_OBJS_USED@
 
diff --git a/src/configure.ac b/src/configure.ac
index 9db7d37bd..fc9590f75 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -2406,49 +2406,41 @@ CPPFLAGS=$cppflags_save
 
 AC_MSG_CHECKING(--with-wayland argument)
 AC_ARG_WITH(wayland,
-       [  --with-wayland         Include support for the Wayland protocol.])
+       [  --with-wayland         Include support for the Wayland protocol.],
+       [with_wayland=$withval],
+       [with_wayland=yes])
+AC_MSG_RESULT([$with_wayland])
 
-test -z "$with_wayland" && with_wayland=yes
 if test "$with_wayland" = yes; then
-  AC_MSG_RESULT(yes)
-  AC_MSG_CHECKING(if Wayland client header files can be found)
-  cppflags_save=$CPPFLAGS
-  CPPFLAGS="$CPPFLAGS $X_CFLAGS"
-  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <wayland-client.h>], )],
-       AC_MSG_RESULT(yes),
-       AC_MSG_RESULT(no); no_wl=yes)
-  CPPFLAGS=$cppflags_save
-
-  if test "$no_wl" = yes; then
-    with_wayland=no
+cflags_save=$CFLAGS
+  AC_MSG_CHECKING(for wayland)
+  if "$PKG_CONFIG" --exists 'wayland-client'; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(HAVE_WAYLAND)
+    WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client`
+    CFLAGS="$CFLAGS $WAYLAND_CFLAGS"
+    WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client`
+    WAYLAND_SRC=" \
+      auto/wayland/wlr-data-control-unstable-v1.c \
+      auto/wayland/ext-data-control-v1.c \
+      auto/wayland/xdg-shell.c \
+      auto/wayland/primary-selection-unstable-v1.c \
+      wayland.c"
+    WAYLAND_OBJ=" \
+      objects/wlr-data-control-unstable-v1.o \
+      objects/ext-data-control-v1.o \
+      objects/xdg-shell.o \
+      objects/primary-selection-unstable-v1.o \
+      objects/wayland.o"
+    AC_SUBST(WAYLAND_CFLAGS)
+    AC_SUBST(WAYLAND_LIBS)
+    AC_SUBST(WAYLAND_SRC)
+    AC_SUBST(WAYLAND_OBJ)
   else
-    AC_CHECK_LIB(wayland-client, wl_display_connect,[no_wl=no])
-
-    if test "$no_wl" = no; then
-      AC_DEFINE(HAVE_WAYLAND)
-      WAYLAND_LIBS="-lwayland-client";
-      AC_SUBST(WAYLAND_LIBS)
-      WAYLAND_SRC=" \
-             auto/wayland/wlr-data-control-unstable-v1.c \
-             auto/wayland/ext-data-control-v1.c \
-             auto/wayland/xdg-shell.c \
-             auto/wayland/primary-selection-unstable-v1.c \
-             wayland.c"
-      AC_SUBST(WAYLAND_SRC)
-      WAYLAND_OBJ=" \
-             objects/wlr-data-control-unstable-v1.o \
-             objects/ext-data-control-v1.o \
-             objects/xdg-shell.o \
-             objects/primary-selection-unstable-v1.o \
-             objects/wayland.o"
-      AC_SUBST(WAYLAND_OBJ)
-
-    else
-      with_wayland=no
-    fi
+    AC_MSG_RESULT(no)
+    with_wayland=no
   fi
-else
-  AC_MSG_RESULT(no)
+CFLAGS=$cflags_save
 fi
 
 test -z "$with_x" && with_x=yes
diff --git a/src/version.c b/src/version.c
index 31443f916..d7c183f07 100644
--- a/src/version.c
+++ b/src/version.c
@@ -719,6 +719,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1561,
 /**/
     1560,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1ucUIt-00Bif5-L4%40256bit.org.

Raspunde prin e-mail lui