From 6c616fd2d09040928159693cf1c6065f90f075ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Mon, 30 Sep 2024 20:38:32 -0400
Subject: [PATCH] Add a "Build Options" menu item.

Useful to check if SyncTERM was built with or without specific
features.
---
 src/syncterm/CHANGES    |   1 +
 src/syncterm/Manual.txt |   3 +
 src/syncterm/bbslist.c  | 120 ++++++++++++++++++++++++++++++++++++++++
 src/xpdev/Common.gmake  |   1 +
 src/xpdev/GNUmakefile   |   1 -
 src/xpdev/xpbeep.c      |  20 ++++---
 6 files changed, 136 insertions(+), 10 deletions(-)

diff --git a/src/syncterm/CHANGES b/src/syncterm/CHANGES
index 4e017afc85..12df5e5149 100644
--- a/src/syncterm/CHANGES
+++ b/src/syncterm/CHANGES
@@ -7,6 +7,7 @@ Fix some use-after-free bugs in RIP
 Fix reversed mouse wheel in GDI mode
 Have the X11 IC focus follow window focus
 Fix WM_SETCURSOR handling to allow crabbing resize points in GDI
+Added "Build Options" menu item
 
 Version 1.2rc1
 --------------
diff --git a/src/syncterm/Manual.txt b/src/syncterm/Manual.txt
index ba0778a2fa..277d223f22 100644
--- a/src/syncterm/Manual.txt
+++ b/src/syncterm/Manual.txt
@@ -703,6 +703,9 @@ File Locations::
 Shows the paths to the various files and directories
 that SyncTERM will access.
 
+Build Options::
+Shows which optional components SyncTERM was built to support.
+
 
 ==== Current Screen Mode
 
diff --git a/src/syncterm/bbslist.c b/src/syncterm/bbslist.c
index c0abc58744..d32579c779 100644
--- a/src/syncterm/bbslist.c
+++ b/src/syncterm/bbslist.c
@@ -23,6 +23,20 @@
 #include "vidmodes.h"
 #include "window.h"
 
+#if defined(__unix__) && defined(SOUNDCARD_H_IN) && (SOUNDCARD_H_IN > 0) && !defined(_WIN32)
+	#if SOUNDCARD_H_IN==1
+		#include <sys/soundcard.h>
+	#elif SOUNDCARD_H_IN==2
+		#include <soundcard.h>
+	#elif SOUNDCARD_H_IN==3
+		#include <linux/soundcard.h>
+	#else
+		#ifndef USE_ALSA_SOUND
+			#warning Cannot find soundcard.h
+		#endif
+	#endif
+#endif
+
 #ifdef _MSC_VER
 #pragma warning(disable : 4244 4267 4018)
 #endif
@@ -2618,6 +2632,7 @@ show_bbslist(char *current, int connected)
 		"Font Management",
 		"Program Settings",
 		"File Locations",
+		"Build Options",
 		NULL
 	};
 	char                 *connected_settings_menu[] = {
@@ -2625,6 +2640,7 @@ show_bbslist(char *current, int connected)
 		"Font Management",
 		"Program Settings",
 		"File Locations",
+		"Build Options",
 		NULL
 	};
 	int                   at_settings = 0;
@@ -3164,6 +3180,8 @@ show_bbslist(char *current, int connected)
 				    "        Modify hardware and screen/video settings\n\n"
 				    "~ File Locations ~\n"
 				    "        Display location for config and directory files\n\n"
+				    "~ Build Options ~\n"
+				    "        Display compile options selected at build time\n\n"
 				    "~ " ALT_KEY_NAMEP "-B ~\n"
 				    "        View scrollback of last session\n";
 				if (oldopt != -2)
@@ -3353,6 +3371,108 @@ show_bbslist(char *current, int connected)
 						    NULL,
 						    NULL);
 						break;
+					case 5: // Build Options
+						asprintf(&p,
+						    "`SyncTERM Build Options`\n\n"
+						    "%s Cryptlib (ie: SSH and TLS)\n"
+						    "%s Operation Overkill ][ Terminal\n\n"
+						    "Video\n"
+						    "    %s SDL\n"
+						    "    %s X11 Support\n"
+						    "        %s Xinerama\n"
+						    "        %s XRandR\n"
+						    "        %s XRender\n"
+						    "    %s GDI\n\n"
+						    "Audio\n"
+						    "    %s OSS\n"
+						    "    %s SDL\n"
+						    "    %s ALSA\n"
+						    "    %s PortAudio\n"
+						    "    %s PulseAudio\n"
+						    "    %s PC Speaker\n",
+#ifdef WITHOUT_CRYPTLIB
+						    "[ ]",
+#else
+						    "[`\xFB`]",
+#endif
+#ifdef WITHOUT_OOII
+						    "[ ]",
+#else
+						    "[`\xFB`]",
+#endif
+#ifdef WITH_SDL
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#ifdef NO_X
+						    "[ ]",
+#else
+						    "[`\xFB`]",
+#endif
+#ifdef WITH_XINERAMA
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#ifdef WITH_XRANDR
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#ifdef WITH_XRENDER
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#ifdef WITH_GDI
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#if (defined SOUNDCARD_H_IN) && (SOUNDCARD_H_IN > 0) && (defined AFMT_U8)
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#ifdef WITH_SDL_AUDIO
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#ifdef USE_ALSA_SOUND
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#ifdef WITH_PORTAUDIO
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#ifdef WITH_PULSEAUDIO
+						    "[`\xFB`]",
+#else
+						    "[ ]",
+#endif
+#if (defined(__FreeBSD__) && defined(HAS_MACHINE_SPEAKER_H)) || ((defined(__OpenBSD__) || defined(__NetBSD__)) && defined(HAS_MACHINE_SPKR_H))
+						    "[`\xFB`]"
+#elif !defined(__GNU__) && !defined(__QNX__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__HAIKU__) && !defined(__EMSCRIPTEN__)
+						    "[`\xFB`]"
+#else
+						    "[ ]"
+#endif
+						);
+						uifc.showbuf(WIN_MID | WIN_SAV | WIN_HLP,
+						    0,
+						    0,
+						    60,
+						    21,
+						    "Build Options",
+						    p,
+						    NULL,
+						    NULL);
+						break;
 				}
 			}
 		}
diff --git a/src/xpdev/Common.gmake b/src/xpdev/Common.gmake
index b5ad528806..e929101f7b 100644
--- a/src/xpdev/Common.gmake
+++ b/src/xpdev/Common.gmake
@@ -57,6 +57,7 @@ ifndef win
   XPDEV-MT_CFLAGS	+=	-DHAS_MACHINE_SPKR_H
   XPDEV_CFLAGS		+=	-DHAS_MACHINE_SPKR_H
  endif
+ XPDEV-MT_CFLAGS	+=	-DSOUNDCARD_H_IN=$(shell if [ -f /usr/include/sys/soundcard.h ] ; then echo 1 ; elif [ -f /usr/include/soundcard.h ] ; then echo 2 ; elif [ -f /usr/include/linux/soundcard.h ] ; then echo 3 ; else echo 0 ; fi) -I. $(XPDEV_CFLAGS)
 endif
 
 # FreeBSD, OpenBSD, NetBSD, Linux, SunOS, and Darwin all have random()/srandom()
diff --git a/src/xpdev/GNUmakefile b/src/xpdev/GNUmakefile
index 6ee81e9508..ae38daff5e 100644
--- a/src/xpdev/GNUmakefile
+++ b/src/xpdev/GNUmakefile
@@ -15,7 +15,6 @@ ifndef NO_PULSEAUDIO
  endif
 endif
 
-CFLAGS	+=	-DSOUNDCARD_H_IN=$(shell if [ -f /usr/include/sys/soundcard.h ] ; then echo 1 ; elif [ -f /usr/include/soundcard.h ] ; then echo 2 ; elif [ -f /usr/include/linux/soundcard.h ] ; then echo 3 ; else echo 0 ; fi) -I. $(XPDEV_CFLAGS)
 ifndef WITHOUT_ALSA_SOUND
 	ifeq ($(shell if [ -f /usr/include/alsa/asoundlib.h ] ; then echo YES ; fi),YES)
 		CFLAGS	+=	-DUSE_ALSA_SOUND
diff --git a/src/xpdev/xpbeep.c b/src/xpdev/xpbeep.c
index 4e4cfd4207..c3f434f9d7 100644
--- a/src/xpdev/xpbeep.c
+++ b/src/xpdev/xpbeep.c
@@ -15,15 +15,17 @@
 	#include <fcntl.h>
 	#include <sys/ioctl.h>
 	#ifndef __EMSCRIPTEN__
-		#if SOUNDCARD_H_IN==1
-			#include <sys/soundcard.h>
-		#elif SOUNDCARD_H_IN==2
-			#include <soundcard.h>
-		#elif SOUNDCARD_H_IN==3
-			#include <linux/soundcard.h>
-		#else
-			#ifndef USE_ALSA_SOUND
-				#warning Cannot find soundcard.h
+		#ifdef SOUNDCARD_H_IN
+			#if SOUNDCARD_H_IN==1
+				#include <sys/soundcard.h>
+			#elif SOUNDCARD_H_IN==2
+				#include <soundcard.h>
+			#elif SOUNDCARD_H_IN==3
+				#include <linux/soundcard.h>
+			#else
+				#ifndef USE_ALSA_SOUND
+					#warning Cannot find soundcard.h
+				#endif
 			#endif
 		#endif
 		#ifdef USE_ALSA_SOUND
-- 
GitLab