From e7cabdb5927c3e46321c876af92344dbbb28d865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tin=20=C5=A0vagelj?= Date: Sat, 16 Nov 2024 06:53:18 +0100 Subject: [PATCH] Fix sndio linking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also simplified HAVE_SOUNDCARD_H handling because it was unnecessarily complicated, and added an option to disable mixer support completely because why not. Signed-off-by: Tin Å vagelj --- cmake/ConkyBuildOptions.cmake | 2 ++ cmake/ConkyPlatformChecks.cmake | 27 ++++++++++++++++++++------- cmake/config.h.in | 3 +-- src/CMakeLists.txt | 4 ++-- src/core.cc | 4 ++-- src/main.cc | 4 ++-- src/mixer.cc | 10 +++++----- 7 files changed, 34 insertions(+), 20 deletions(-) diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index 8a4f7ceef..ae0b869fb 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -228,6 +228,8 @@ dependent_option(BUILD_LUA_RSVG "Build rsvg bindings for Lua" false "BUILD_GUI" false "RSVG Lua bindings depend on BUILD_GUI") +option(BUILD_OPENSOUNDSYS "Build with Open Sound System support" true) + option(BUILD_AUDACIOUS "Build audacious (music player) support" false) option(BUILD_MPD "Enable if you want MPD (music player) support" true) diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index 6f9442d7f..402cee907 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -147,17 +147,30 @@ endif(NOT NOT OS_DARWIN) -# Check for soundcard header if(OS_LINUX) - check_include_files("linux/soundcard.h" HAVE_SOME_SOUNDCARD_H) - check_include_files("linux/soundcard.h" HAVE_LINUX_SOUNDCARD_H) check_include_files("linux/sockios.h" HAVE_LINUX_SOCKIOS_H) -elseif(OS_OPENBSD) - check_include_files("soundcard.h" HAVE_SOME_SOUNDCARD_H) -else(OS_LINUX) - check_include_files("sys/soundcard.h" HAVE_SOME_SOUNDCARD_H) endif(OS_LINUX) +# Handle Open Sound System +if(BUILD_OPENSOUNDSYS) + if(OS_LINUX) + check_include_files("linux/soundcard.h" HAVE_SOUNDCARD_H) + elseif(OS_OPENBSD) + check_include_files("soundcard.h" HAVE_SOUNDCARD_H) + # OpenBSD (and FreeBSD?) provide emulation header that links to sndio. + if(HAVE_SOUNDCARD_H) + find_library(SNDIO_LIB + NAMES sndio + PATHS /usr/lib + /usr/local/lib) + set(conky_libs ${conky_libs} ${SNDIO_LIB}) + endif(HAVE_SOUNDCARD_H) + else(OS_LINUX) + check_include_files("sys/soundcard.h" HAVE_SOUNDCARD_H) + endif(OS_LINUX) +endif(BUILD_OPENSOUNDSYS) + + if(BUILD_I18N) include(FindIntl) find_package(Intl) diff --git a/cmake/config.h.in b/cmake/config.h.in index 5eeff2076..015dac8bb 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -29,8 +29,7 @@ #cmakedefine HAVE_SYS_INOTIFY_H 1 #cmakedefine HAVE_DIRENT_H 1 -#cmakedefine HAVE_SOME_SOUNDCARD_H 1 -#cmakedefine HAVE_LINUX_SOUNDCARD_H 1 +#cmakedefine HAVE_SOUNDCARD_H 1 #cmakedefine HAVE_STRNDUP 1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d36f4dbc2..7e4be4183 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -189,10 +189,10 @@ if(OS_DARWIN) endif(OS_DARWIN) # Optional sources -if(HAVE_SOME_SOUNDCARD_H) +if(HAVE_SOUNDCARD_H) set(mixer mixer.cc mixer.h) set(optional_sources ${optional_sources} ${mixer}) -endif(HAVE_SOME_SOUNDCARD_H) +endif(HAVE_SOUNDCARD_H) if(BUILD_AUDACIOUS) set(audacious audacious.cc audacious.h) diff --git a/src/core.cc b/src/core.cc index 197e54956..d7aa10b4c 100644 --- a/src/core.cc +++ b/src/core.cc @@ -1247,7 +1247,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, END OBJ(memwithbuffersgraph, &update_meminfo) scan_graph(obj, arg, 1, FALSE); obj->callbacks.graphval = &mem_with_buffers_barval; #endif /* BUILD_GUI*/ -#ifdef HAVE_SOME_SOUNDCARD_H +#ifdef HAVE_SOUNDCARD_H END OBJ(mixer, 0) parse_mixer_arg(obj, arg); obj->callbacks.percentage = &mixer_percentage; END OBJ(mixerl, 0) parse_mixer_arg(obj, arg); @@ -1262,7 +1262,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line, obj->callbacks.barval = &mixerr_barval; END OBJ_IF(if_mixer_mute, 0) parse_mixer_arg(obj, arg); obj->callbacks.iftest = &check_mixer_muted; -#endif /* HAVE_SOME_SOUNDCARD_H */ +#endif /* HAVE_SOUNDCARD_H */ #ifdef BUILD_GUI END OBJ(monitor, nullptr) obj->callbacks.print = &print_monitor; END OBJ(monitor_number, nullptr) obj->callbacks.print = &print_monitor_number; diff --git a/src/main.cc b/src/main.cc index 909d12cfc..dcd8c13b8 100644 --- a/src/main.cc +++ b/src/main.cc @@ -124,9 +124,9 @@ static void print_version() { #ifdef BUILD_IMLIB2 << _(" * Imlib2\n") #endif /* BUILD_IMLIB2 */ -#ifdef HAVE_SOME_SOUNDCARD_H +#ifdef HAVE_SOUNDCARD_H << _(" * OSS mixer support\n") -#endif /* HAVE_SOME_SOUNDCARD_H */ +#endif /* HAVE_SOUNDCARD_H */ #ifdef BUILD_MIXER_ALSA << _(" * ALSA mixer support\n") #endif /* BUILD_MIXER_ALSA */ diff --git a/src/mixer.cc b/src/mixer.cc index e238fec7b..6dad8dec2 100644 --- a/src/mixer.cc +++ b/src/mixer.cc @@ -36,15 +36,15 @@ #include "specials.h" #include "text_object.h" -#ifdef HAVE_LINUX_SOUNDCARD_H +#ifdef HAVE_SOUNDCARD_H +#if defined(__linux__) #include -#else -#ifdef __OpenBSD__ +#elif defined(__OpenBSD__) #include #else #include -#endif /* __OpenBSD__ */ -#endif /* HAVE_LINUX_SOUNDCARD_H */ +#endif +#endif /* HAVE_SOUNDCARD_H */ #if defined(__sun) #include