From d886c4cada68ed5bfdca72de846182be63f2619e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= <arsen@aarsen.me>
Date: Mon, 19 Dec 2022 11:30:58 +0100
Subject: [PATCH] configure.in: Allow disabling Wayland support

---
This patch is not forwarded upstream since, AFAIK, the autoconf+bakefile build
system is currently in the process of being replaced.

This patch enables us to explicitly disable GDK wayland platform detection via
an enable flag.  It doesn't implement failed detection logic since that
shouldn't happen in the scenario Portage is in.  This patch also runs includes
patches for the configure script itself, because the configuration was
generated by a seemingly patched Autoconf 2.69.

 configure    | 53 +++++++++++++++++++++++++++++++++++++++++++---------
 configure.in | 37 ++++++++++++++++++++----------------
 2 files changed, 65 insertions(+), 25 deletions(-)

diff --git a/configure b/configure
index 54eb7a7..b6d5e52 100755
--- a/configure
+++ b/configure
@@ -1218,6 +1218,7 @@ enable_textfile
 enable_timer
 enable_variant
 enable_zipstream
+enable_wayland
 enable_url
 enable_protocol
 enable_protocol_http
@@ -2190,6 +2191,7 @@ Optional Features:
   --enable-timer          use wxTimer class
   --enable-variant        use wxVariant class
   --enable-zipstream      use wxZip streams
+  --enable-wayland        allow using Wayland EGL backend
   --enable-url            use wxURL class
   --enable-protocol       use wxProtocol class
   --enable-protocol-http  HTTP support in wxProtocol
@@ -8228,6 +8230,35 @@ fi
           eval "$wx_cv_use_zipstream"
 
 
+          enablestring=
+          defaultval=$wxUSE_ALL_FEATURES
+          if test -z "$defaultval"; then
+              if test x"$enablestring" = xdisable; then
+                  defaultval=yes
+              else
+                  defaultval=no
+              fi
+          fi
+
+          # Check whether --enable-wayland was given.
+if test "${enable_wayland+set}" = set; then :
+  enableval=$enable_wayland;
+                          if test "$enableval" = yes; then
+                            wx_cv_use_wayland='wxUSE_WAYLAND=yes'
+                          else
+                            wx_cv_use_wayland='wxUSE_WAYLAND=no'
+                          fi
+
+else
+
+                          wx_cv_use_wayland='wxUSE_WAYLAND=${'DEFAULT_wxUSE_WAYLAND":-$defaultval}"
+
+fi
+
+
+          eval "$wx_cv_use_wayland"
+
+
 
           enablestring=
           defaultval=$wxUSE_ALL_FEATURES
@@ -29335,26 +29366,27 @@ done
         TOOLKIT=GTK
         GUIDIST=GTK_DIST
 
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GDK Wayland backend" >&5
+	if test x"$wxUSE_WAYLAND" = xyes; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GDK Wayland backend" >&5
 $as_echo_n "checking for GDK Wayland backend... " >&6; }
 if ${wx_cv_gdk_wayland+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
-            save_CFLAGS=$CFLAGS
-            CFLAGS="$CFLAGS $TOOLKIT_INCLUDE"
-            cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+		    save_CFLAGS=$CFLAGS
+		    CFLAGS="$CFLAGS $TOOLKIT_INCLUDE"
+		    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-                            #include <gdk/gdk.h>
+				    #include <gdk/gdk.h>
 
 int
 main ()
 {
 
-                            #ifndef GDK_WINDOWING_WAYLAND
-                            Not GDK Windowing Wayland
-                            #endif
+				    #ifndef GDK_WINDOWING_WAYLAND
+				    Not GDK Windowing Wayland
+				    #endif
 
   ;
   return 0;
@@ -29367,11 +29399,14 @@ else
 
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-            CFLAGS=$save_CFLAGS
+		    CFLAGS=$save_CFLAGS
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $wx_cv_gdk_wayland" >&5
 $as_echo "$wx_cv_gdk_wayland" >&6; }
+	else
+		wx_cv_gdk_wayland=no
+	fi
 
                 if test "$wxUSE_GPE" = "yes"; then
             { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gpewidget library" >&5
diff --git a/configure.in b/configure.in
index c76c528..430cdff 100644
--- a/configure.in
+++ b/configure.in
@@ -779,6 +779,7 @@ WX_ARG_FEATURE(textfile,      [  --enable-textfile       use wxTextFile class],
 WX_ARG_FEATURE(timer,         [  --enable-timer          use wxTimer class], wxUSE_TIMER)
 WX_ARG_FEATURE(variant,       [  --enable-variant        use wxVariant class], wxUSE_VARIANT)
 WX_ARG_FEATURE(zipstream,     [  --enable-zipstream      use wxZip streams], wxUSE_ZIPSTREAM)
+WX_ARG_FEATURE(wayland,       [  --enable-wayland        allow using Wayland EGL backend], wxUSE_WAYLAND)
 
 dnl URL-related classes
 WX_ARG_FEATURE(url,           [  --enable-url            use wxURL class], wxUSE_URL)
@@ -3292,22 +3293,26 @@ libraries returned by 'pkg-config gtk+-2.0 --libs' or 'gtk-config
         TOOLKIT=GTK
         GUIDIST=GTK_DIST
 
-        AC_CACHE_CHECK([for GDK Wayland backend], wx_cv_gdk_wayland, [
-            save_CFLAGS=$CFLAGS
-            CFLAGS="$CFLAGS $TOOLKIT_INCLUDE"
-            AC_TRY_COMPILE([
-                            #include <gdk/gdk.h>
-                           ],
-                           [
-                            #ifndef GDK_WINDOWING_WAYLAND
-                            Not GDK Windowing Wayland
-                            #endif
-                           ],
-                           wx_cv_gdk_wayland=yes,
-                           wx_cv_gdk_wayland=no
-                           )
-            CFLAGS=$save_CFLAGS
-        ])
+	if test x"$wxUSE_WAYLAND" = xyes; then
+		AC_CACHE_CHECK([for GDK Wayland backend], wx_cv_gdk_wayland, [
+		    save_CFLAGS=$CFLAGS
+		    CFLAGS="$CFLAGS $TOOLKIT_INCLUDE"
+		    AC_TRY_COMPILE([
+				    #include <gdk/gdk.h>
+				   ],
+				   [
+				    #ifndef GDK_WINDOWING_WAYLAND
+				    Not GDK Windowing Wayland
+				    #endif
+				   ],
+				   wx_cv_gdk_wayland=yes,
+				   wx_cv_gdk_wayland=no
+				   )
+		    CFLAGS=$save_CFLAGS
+		])
+	else
+		wx_cv_gdk_wayland=no
+	fi
 
         dnl test for external libxpm if we're configured to use it
         if test "$wxUSE_GPE" = "yes"; then
-- 
2.39.0

