SDL-1.2: SDL_fbvideo.c: check sys/io.h before enabling VGA16_FBCON_SUPPORT

From b124d3bc6942fbb1215181424cac89ec49e0a7c6 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Mon, 15 Feb 2021 03:55:28 +0300
Subject: [PATCH] SDL_fbvideo.c: check sys/io.h before enabling
 VGA16_FBCON_SUPPORT

---
 configure                     | 12 ++++++++++++
 configure.ac                  |  1 +
 include/SDL_config.h.in       |  1 +
 src/video/fbcon/SDL_fbvideo.c |  2 +-
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index d1375786..37e78375 100755
--- a/configure
+++ b/configure
@@ -19635,6 +19635,18 @@ $as_echo "$have_cocoa" >&6; }
 
 CheckFBCON()
 {
+    for ac_header in sys/io.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/io.h" "ac_cv_header_sys_io_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_io_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_IO_H 1
+_ACEOF
+
+fi
+
+done
+
     # Check whether --enable-video-fbcon was given.
 if test "${enable_video_fbcon+set}" = set; then :
   enableval=$enable_video_fbcon;
diff --git a/configure.ac b/configure.ac
index 07b547af..b02cd851 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1350,6 +1350,7 @@ AS_HELP_STRING([--enable-video-cocoa], [use Cocoa/Quartz video driver [[default=
 dnl Find the framebuffer console includes
 CheckFBCON()
 {
+    AC_CHECK_HEADERS(sys/io.h)
     AC_ARG_ENABLE(video-fbcon,
 AS_HELP_STRING([--enable-video-fbcon], [use framebuffer console video driver [[default=yes]]]),
                   , enable_video_fbcon=yes)
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 60640583..c0161dd7 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -76,6 +76,7 @@
 #undef HAVE_ICONV_H
 #undef HAVE_SIGNAL_H
 #undef HAVE_ALTIVEC_H
+#undef HAVE_SYS_IO_H
 
 /* C library functions */
 #undef HAVE_MALLOC
diff --git a/src/video/fbcon/SDL_fbvideo.c b/src/video/fbcon/SDL_fbvideo.c
index 7206a4bb..ba9eb254 100644
--- a/src/video/fbcon/SDL_fbvideo.c
+++ b/src/video/fbcon/SDL_fbvideo.c
@@ -50,7 +50,7 @@
 
 /*#define FBCON_DEBUG*/
 
-#if defined(__i386__) && defined(FB_TYPE_VGA_PLANES)
+#if defined(__i386__) && defined(HAVE_SYS_IO_H) && defined(FB_TYPE_VGA_PLANES)
 #define VGA16_FBCON_SUPPORT
 #include <sys/io.h>		/* For ioperm() */
 #ifndef FB_AUX_VGA_PLANES_VGA4