--- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ FFMPEG_CFLAGS += $(shell pkg-config --cflags libswresample) FFMPEG_LIBS += $(shell pkg-config --libs libswresample) -CMUS_LIBS = $(PTHREAD_LIBS) $(NCURSES_LIBS) $(ICONV_LIBS) $(DL_LIBS) $(DISCID_LIBS) \ +CMUS_LIBS = $(ATOMIC_LIBS) $(PTHREAD_LIBS) $(NCURSES_LIBS) $(ICONV_LIBS) $(DL_LIBS) $(DISCID_LIBS) \ -lm $(COMPAT_LIBS) $(LIBSYSTEMD_LIBS) input.o main.o ui_curses.o op/pulse.lo: .version --- a/configure +++ b/configure @@ -39,7 +39,35 @@ return 1 } +readonly atomic_code=" +#include +int main(int argc, char *argv[]) +{ + static atomic_llong x = ATOMIC_VAR_INIT(1); + return atomic_fetch_add_explicit(&x, argc, memory_order_relaxed) == 2; +} +" + +check_atomic() +{ + msg_checking "if -latomic is needed for C11 atomics" + if try_compile_link "$atomic_code" + then + msg_result "no" + ATOMIC_LIBS= + elif try_compile_link "$atomic_code" -latomic + then + msg_result "yes" + ATOMIC_LIBS=-latomic + else + msg_result "no C11 atomics?!" + return 1 + fi + makefile_vars ATOMIC_LIBS + return 0 +} + check_compat() { COMPAT_LIBS= @@ -517,6 +545,7 @@ check check_cflags check check_cc_depgen check check_endianness +check check_atomic check check_compat check check_dl check check_pthread