From 11af53fff6a1608fc6daef8b8fb2adf4ca87b8be Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 22 Sep 2020 13:31:29 -0400 Subject: [PATCH] configure.ac,Makefile.am,main.cpp,build.sh : Added --enable-alsa configure flag. --- Makefile.am | 7 +++++-- build/linux/debug/build.sh | 4 ++-- configure.ac | 26 +++++++++++++++++++++++++- src/cwtest/main.cpp | 22 +++++++++++++++++----- 4 files changed, 49 insertions(+), 10 deletions(-) diff --git a/Makefile.am b/Makefile.am index cc31eed..5cba293 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,21 +39,23 @@ if OS_64 AM_CFLAGS += -m64 endif +if cwALSA AM_LDFLAGS += -Wl,-Bstatic -lasound -Wl,-Bdynamic +endif endif include src/libcw/Makefile.am libcw_la_SOURCES = $(libcwSRC) $(libcwHDR) -lib_LTLIBRARIES += libcw.la +lib_LTLIBRARIES += libcw.la include_HEADERS += $(libcwHDR) src_cwtest_cwtest_SOURCES = src/cwtest/main.cpp # autoconfig manual recommends setting direct referenes to non-3rd party libraries rather than using -L and -l -src_cwtest_cwtest_LDADD = libcw.la -lpthread +src_cwtest_cwtest_LDADD = libcw.la -lpthread -ldl if cwWEBSOCK AM_CPPFLAGS += -I$(WS_DIR)/include @@ -61,5 +63,6 @@ if cwWEBSOCK src_cwtest_cwtest_LDADD += -lwebsockets endif + # src_cwtest_cwtest_CPPFLAGS = -I$(srcdir)/src/libcw $(AM_CPPFLAGS) bin_PROGRAMS += src/cwtest/cwtest diff --git a/build/linux/debug/build.sh b/build/linux/debug/build.sh index e0d4fdf..b9a24a8 100755 --- a/build/linux/debug/build.sh +++ b/build/linux/debug/build.sh @@ -13,9 +13,9 @@ cd ${curdir} # 3) Run gprof /libtool --mode=execute gprof ./foo # To enable websock: --enable-websock \ +# To enable alsa: --enable-alsa \ -../../../configure --prefix=${curdir} \ ---enable-debug \ +../../../configure --prefix=${curdir} --enable-debug --enable-alsa \ CFLAGS="-g -Wall" \ CXXFLAGS="-g -Wall" \ CPPFLAGS= \ diff --git a/configure.ac b/configure.ac index e99a1ba..d3d8a65 100644 --- a/configure.ac +++ b/configure.ac @@ -61,6 +61,9 @@ echo "OS='${ax_cv_os_type}'" AM_CONDITIONAL([OS_64],[test x"${ax_cv_os_64}" == xx86_64]) echo "ptr width='${ax_cv_os_64}'" +# +# Enable Debug +# AC_ARG_ENABLE([debug], [ --enable-debug Turn on debugging], @@ -78,7 +81,9 @@ if test x$debug = xfalse; then AC_DEFINE([NDEBUG], 1,[Debugging off.]) fi - +# +# Enable libwebsock +# AC_ARG_ENABLE([websock], [ --enable-websock Include websock dependencies], [case "${enableval}" in @@ -95,6 +100,25 @@ if test x"$websock" = xtrue; then AC_DEFINE([cwWEBSOCK], 1,[Use libwebsock.]) fi +# +# Enable ALSA +# +AC_ARG_ENABLE([alsa], + [ --enable-alsa Include ALSA dependencies], + [case "${enableval}" in + yes) alsa=true ;; + no) alsa=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-alsa]) ;; + esac],[alsa=false]) + +echo "alsa=${alsa}" + +AM_CONDITIONAL([cwALSA], [test x$alsa = xtrue]) + +if test x"$alsa" = xtrue; then +AC_DEFINE([cwALSA], 1,[Use libalsa.]) +fi + # AC_ARG_ENABLE([add_lib], diff --git a/src/cwtest/main.cpp b/src/cwtest/main.cpp index 2f5bab4..43ee317 100644 --- a/src/cwtest/main.cpp +++ b/src/cwtest/main.cpp @@ -27,10 +27,14 @@ #include "cwTime.h" #include "cwMidi.h" -#include "cwMidiPort.h" #include "cwAudioDevice.h" + +#if defined(cwALSA) +#include "cwMidiPort.h" #include "cwAudioDeviceTest.h" #include "cwAudioDeviceAlsa.h" +#endif + #include "cwAudioBuf.h" #include "cwTcpSocket.h" #include "cwTcpSocketSrv.h" @@ -326,12 +330,8 @@ void threadTest( const cw::object_t* cfg, const cw::object_t* args, in void spscBuf( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::spsc_buf::test(); } void spscQueueTmpl( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::testSpScQueueTmpl(); } void serialPortSrvTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::serialPortSrvTest(); } -void midiDeviceTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::midi::device::test();} void textBufTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::textBuf::test(); } void audioBufTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::audio::buf::test(); } -void audioDevTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::audio::device::test( argc, argv ); } -void audioDevAlsaTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::audio::device::alsa::report(); } -void audioDevRpt( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::audio::device::report(); } void mtxTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::mtx::test(args); } void audioFileTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::audiofile::test(args); } void audioFileOp( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::afop::test(args); } @@ -355,6 +355,18 @@ void uiTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const #endif +#if defined(cwALSA) +void midiDeviceTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::midi::device::test();} +void audioDevTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::audio::device::test( argc, argv ); } +void audioDevAlsaTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::audio::device::alsa::report(); } +void audioDevRpt( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { cw::audio::device::report(); } +#else +void _no_alsa() { cwLogError(cw::kResourceNotAvailableRC,"ALSA based functionality not included in this build."); } +void midiDeviceTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { _no_alsa();} +void audioDevTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { _no_alsa(); } +void audioDevAlsaTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { _no_alsa(); } +void audioDevRpt( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) { _no_alsa(); } +#endif void socketTest( const cw::object_t* cfg, const cw::object_t* args, int argc, const char* argv[] ) {