Skip to content

Commit

Permalink
Fix sndio linking
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Caellian committed Nov 16, 2024
1 parent c6e5bba commit e7cabdb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 20 deletions.
2 changes: 2 additions & 0 deletions cmake/ConkyBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 20 additions & 7 deletions cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
10 changes: 5 additions & 5 deletions src/mixer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
#include "specials.h"
#include "text_object.h"

#ifdef HAVE_LINUX_SOUNDCARD_H
#ifdef HAVE_SOUNDCARD_H
#if defined(__linux__)
#include <linux/soundcard.h>
#else
#ifdef __OpenBSD__
#elif defined(__OpenBSD__)
#include <soundcard.h>
#else
#include <sys/soundcard.h>
#endif /* __OpenBSD__ */
#endif /* HAVE_LINUX_SOUNDCARD_H */
#endif
#endif /* HAVE_SOUNDCARD_H */

#if defined(__sun)
#include <stropts.h>
Expand Down

0 comments on commit e7cabdb

Please sign in to comment.