ref: d6124484d7ff1c13189315603892cc6f8c0299d1
parent: 3c78b254a3c000e58ec93f07e7178b7246fa0e70
author: Turo Lamminen <[email protected]>
date: Tue Jul 12 16:48:51 EDT 2022
Add option to disable SDL2_mixer
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,9 +29,15 @@
endif()
option(ENABLE_SDL2_NET "Enable SDL2_net" On)
+option(ENABLE_SDL2_MIXER "Enable SDL2_mixer" On)
find_package(SDL2 2.0.7)
-find_package(SDL2_mixer 2.0.2)
+if(ENABLE_SDL2_MIXER)
+ find_package(SDL2_mixer 2.0.2)
+else()
+ add_compile_definitions(DISABLE_SDL2MIXER=1)
+endif()
+
if(ENABLE_SDL2_NET)
find_package(SDL2_net 2.0.0)
else()
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,14 @@
fi
PKG_CHECK_MODULES(SDL, [sdl2 >= 2.0.7])
-PKG_CHECK_MODULES(SDLMIXER, [SDL2_mixer >= 2.0.2])
+# Check for SDL2_mixer
+AC_ARG_ENABLE([sdl2mixer],
+AS_HELP_STRING([--disable-sdl2mixer], [Disable SDL2_mixer support])
+)
+AS_IF([test "x$enable_sdl2mixer" != xno], [
+ PKG_CHECK_MODULES(SDLMIXER, [SDL2_mixer >= 2.0.2])], [
+ AC_DEFINE([DISABLE_SDL2MIXER], [1], [SDL2_mixer disabled])
+])
# Check for networking
AC_ARG_ENABLE([sdl2net],
--- a/opl/CMakeLists.txt
+++ b/opl/CMakeLists.txt
@@ -12,4 +12,7 @@
target_include_directories(opl
INTERFACE "."
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
-target_link_libraries(opl SDL2::SDL2 SDL2::mixer)
+target_link_libraries(opl SDL2::SDL2)
+if(ENABLE_SDL2_mixer)
+ target_link_libraries(opl SDL2::mixer)
+endif()
--- a/opl/opl.c
+++ b/opl/opl.c
@@ -50,7 +50,9 @@
#ifdef _WIN32
&opl_win32_driver,
#endif
+#ifndef DISABLE_SDL2MIXER
&opl_sdl_driver,
+#endif // DISABLE_SDL2MIXER
NULL
};
--- a/opl/opl_sdl.c
+++ b/opl/opl_sdl.c
@@ -33,6 +33,10 @@
#include "opl_queue.h"
+
+#ifndef DISABLE_SDL2MIXER
+
+
#define MAX_SOUND_SLICE_TIME 100 /* ms */
typedef struct
@@ -511,3 +515,5 @@
OPL_SDL_AdjustCallbacks,
};
+
+#endif // DISABLE_SDL2MIXER
--- a/pcsound/CMakeLists.txt
+++ b/pcsound/CMakeLists.txt
@@ -8,4 +8,7 @@
target_include_directories(pcsound
INTERFACE "."
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
-target_link_libraries(pcsound SDL2::SDL2 SDL2::mixer)
+target_link_libraries(pcsound SDL2::SDL2)
+if(ENABLE_SDL2_mixer)
+ target_link_libraries(pcsound SDL2::mixer)
+endif()
--- a/pcsound/pcsound.c
+++ b/pcsound/pcsound.c
@@ -56,7 +56,9 @@
#ifdef _WIN32
&pcsound_win32_driver,
#endif
+#ifndef DISABLE_SDL2MIXER
&pcsound_sdl_driver,
+#endif // DISABLE_SDL2MIXER
NULL,
};
--- a/pcsound/pcsound_sdl.c
+++ b/pcsound/pcsound_sdl.c
@@ -24,6 +24,10 @@
#include "pcsound.h"
#include "pcsound_internal.h"
+
+#ifndef DISABLE_SDL2MIXER
+
+
#define MAX_SOUND_SLICE_TIME 70 /* ms */
#define SQUARE_WAVE_AMP 0x2000
@@ -248,3 +252,5 @@
PCSound_SDL_Shutdown,
};
+
+#endif // DISABLE_SDL2MIXER
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -124,7 +124,10 @@
set(SOURCE_FILES ${COMMON_SOURCE_FILES} ${GAME_SOURCE_FILES})
set(SOURCE_FILES_WITH_DEH ${SOURCE_FILES} ${DEHACKED_SOURCE_FILES})
-set(EXTRA_LIBS SDL2::SDL2main SDL2::SDL2 SDL2::mixer textscreen pcsound opl)
+set(EXTRA_LIBS SDL2::SDL2main SDL2::SDL2 textscreen pcsound opl)
+if(ENABLE_SDL2_MIXER)
+ list(APPEND EXTRA_LIBS SDL2::mixer)
+endif()
if(ENABLE_SDL2_NET)
list(APPEND EXTRA_LIBS SDL2::net)
endif()
@@ -219,7 +222,10 @@
target_include_directories("${PROGRAM_PREFIX}setup"
PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../")
-target_link_libraries("${PROGRAM_PREFIX}setup" SDL2::SDL2main SDL2::SDL2 SDL2::mixer setup textscreen)
+target_link_libraries("${PROGRAM_PREFIX}setup" SDL2::SDL2main SDL2::SDL2 setup textscreen)
+if(ENABLE_SDL2_mixer)
+ target_link_libraries("${PROGRAM_PREFIX}setup" SDL2::mixer)
+endif()
if(ENABLE_SDL2_NET)
target_link_libraries("${PROGRAM_PREFIX}setup" SDL2::net)
endif()
--- a/src/doom/CMakeLists.txt
+++ b/src/doom/CMakeLists.txt
@@ -68,7 +68,10 @@
wi_stuff.c wi_stuff.h)
target_include_directories(doom PRIVATE "../" "${CMAKE_CURRENT_BINARY_DIR}/../../")
-target_link_libraries(doom SDL2::SDL2 SDL2::mixer)
+target_link_libraries(doom SDL2::SDL2)
+if(ENABLE_SDL2_mixer)
+ target_link_libraries(doom SDL2::mixer)
+endif()
if(ENABLE_SDL2_NET)
target_link_libraries(doom SDL2::net)
endif()
--- a/src/heretic/CMakeLists.txt
+++ b/src/heretic/CMakeLists.txt
@@ -54,7 +54,10 @@
s_sound.c s_sound.h)
target_include_directories(heretic PRIVATE "../" "${CMAKE_CURRENT_BINARY_DIR}/../../")
-target_link_libraries(heretic textscreen SDL2::SDL2 SDL2::mixer)
+target_link_libraries(heretic textscreen SDL2::SDL2)
+if(ENABLE_SDL2_mixer)
+ target_link_libraries(heretic SDL2::mixer)
+endif()
if(ENABLE_SDL2_NET)
target_link_libraries(heretic SDL2::net)
endif()
--- a/src/hexen/CMakeLists.txt
+++ b/src/hexen/CMakeLists.txt
@@ -55,7 +55,10 @@
xddefs.h)
target_include_directories(hexen PRIVATE "../" "${CMAKE_CURRENT_BINARY_DIR}/../../")
-target_link_libraries(hexen SDL2::SDL2 SDL2::mixer)
+target_link_libraries(hexen SDL2::SDL2)
+if(ENABLE_SDL2_mixer)
+ target_link_libraries(hexen SDL2::mixer)
+endif()
if(ENABLE_SDL2_NET)
target_link_libraries(hexen SDL2::net)
endif()
--- a/src/i_musicpack.c
+++ b/src/i_musicpack.c
@@ -48,6 +48,9 @@
char *music_pack_path = "";
+#ifndef DISABLE_SDL2MIXER
+
+
#define MID_HEADER_MAGIC "MThd"
#define MUS_HEADER_MAGIC "MUS\x1a"
@@ -1378,3 +1381,83 @@
I_MP_PollMusic,
};
+
+#else // DISABLE_SDL2MIXER
+
+
+static boolean I_NULL_InitMusic(void)
+{
+ return false;
+}
+
+
+static void I_NULL_ShutdownMusic(void)
+{
+}
+
+
+static void I_NULL_SetMusicVolume(int volume)
+{
+}
+
+
+static void I_NULL_PauseSong(void)
+{
+}
+
+
+static void I_NULL_ResumeSong(void)
+{
+}
+
+
+static void *I_NULL_RegisterSong(void *data, int len)
+{
+ return NULL;
+}
+
+
+static void I_NULL_UnRegisterSong(void *handle)
+{
+}
+
+
+static void I_NULL_PlaySong(void *handle, boolean looping)
+{
+}
+
+
+static void I_NULL_StopSong(void)
+{
+}
+
+
+static boolean I_NULL_MusicIsPlaying(void)
+{
+ return false;
+}
+
+
+static void I_NULL_PollMusic(void)
+{
+}
+
+music_module_t music_pack_module =
+{
+ NULL,
+ 0,
+ I_NULL_InitMusic,
+ I_NULL_ShutdownMusic,
+ I_NULL_SetMusicVolume,
+ I_NULL_PauseSong,
+ I_NULL_ResumeSong,
+ I_NULL_RegisterSong,
+ I_NULL_UnRegisterSong,
+ I_NULL_PlaySong,
+ I_NULL_StopSong,
+ I_NULL_MusicIsPlaying,
+ I_NULL_PollMusic,
+};
+
+
+#endif // DISABLE_SDL2MIXER
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -126,6 +126,9 @@
}
+#ifndef DISABLE_SDL2MIXER
+
+
#define MAXMIDLENGTH (96 * 1024)
static boolean music_initialized = false;
@@ -591,3 +594,5 @@
NULL, // Poll
};
+
+#endif // DISABLE_SDL2MIXER
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -53,6 +53,9 @@
float libsamplerate_scale = 0.65f;
+#ifndef DISABLE_SDL2MIXER
+
+
#define LOW_PASS_FILTER
//#define DEBUG_DUMP_WAVS
#define NUM_CHANNELS 16
@@ -1138,3 +1141,5 @@
I_SDL_PrecacheSounds,
};
+
+#endif // DISABLE_SDL2MIXER
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -99,7 +99,9 @@
static sound_module_t *sound_modules[] =
{
+#ifndef DISABLE_SDL2MIXER
&sound_sdl_module,
+#endif // DISABLE_SDL2MIXER
&sound_pcsound_module,
NULL,
};
@@ -108,7 +110,9 @@
static music_module_t *music_modules[] =
{
+#ifndef DISABLE_SDL2MIXER
&music_sdl_module,
+#endif // DISABLE_SDL2MIXER
&music_opl_module,
NULL,
};
--- a/src/setup/CMakeLists.txt
+++ b/src/setup/CMakeLists.txt
@@ -15,4 +15,7 @@
txt_mouseinput.c txt_mouseinput.h)
target_include_directories(setup PRIVATE "../" "${CMAKE_CURRENT_BINARY_DIR}/../../")
-target_link_libraries(setup textscreen SDL2::SDL2 SDL2::mixer)
+target_link_libraries(setup textscreen SDL2::SDL2)
+if(ENABLE_SDL2_mixer)
+ target_link_libraries(setup SDL2::mixer)
+endif()
--- a/src/strife/CMakeLists.txt
+++ b/src/strife/CMakeLists.txt
@@ -70,7 +70,10 @@
add_library(strife STATIC ${STRIFE_SOURCES})
target_include_directories(strife PRIVATE "../" "../../win32/" "${CMAKE_CURRENT_BINARY_DIR}/../../")
-target_link_libraries(strife textscreen SDL2::SDL2 SDL2::mixer)
+target_link_libraries(strife textscreen SDL2::SDL2)
+if(ENABLE_SDL2_mixer)
+ target_link_libraries(strife SDL2::mixer)
+endif()
if(ENABLE_SDL2_NET)
target_link_libraries(strife SDL2::net)
endif()