diff --git a/daemon/configure.ac b/daemon/configure.ac
index 3050f20adfdb6c851f7b1e8c1d64b1ceeaceadcf..1b247bdfd19eab993c8554f5cd091ec9d83f89d7 100644
--- a/daemon/configure.ac
+++ b/daemon/configure.ac
@@ -402,12 +402,7 @@ AC_ARG_WITH([speex],
         [],
         [with_speex=yes])
 
-AS_IF([test "x$with_speex" != xno],
-      [AC_CHECK_HEADER([speex/speex.h], , AC_MSG_FAILURE([Missing speex development files. You may use --without-speex to compile without speex codec support.]))]
-        [AC_CHECK_LIB([speex], [speex_decode_int],
-        [],
-        [AC_MSG_FAILURE([libspeex link test failed.   You may use --without-speex to compile without speex codec support.])])
-        ])
+AS_IF([test "x$with_speex" != xno], [PKG_CHECK_MODULES([SPEEX], [speex])])
 
 AC_DEFINE_UNQUOTED([HAVE_SPEEX], `if test "x$with_speex" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libspeex])
 AM_CONDITIONAL(BUILD_SPEEX, test "x$with_speex" = "xyes" )
@@ -422,15 +417,11 @@ AC_ARG_WITH([speexdsp],
     [],
     [with_speexdsp=yes])
 
-AS_IF([test "x$with_speexdsp" != xno],
-      AC_CHECK_HEADER([speex/speex_preprocess.h], , AC_MSG_FAILURE([Missing libspeexdsp development files used for Noise Suppression and Automatic Gain Control.]))
-    AC_SEARCH_LIBS([speex_preprocess_run], [speexdsp], [], [AC_MSG_ERROR([Unable to find speexdsp development files])])
-    )
+AS_IF([test "x$with_speexdsp" != xno], [PKG_CHECK_MODULES([SPEEXDSP], [speexdsp])])
 
 AC_DEFINE_UNQUOTED([HAVE_SPEEXDSP], `if test "x$with_speexdsp" = "xyes"; then echo 1; else echo 0; fi`, [Define if you have libspeexdsp])
 AM_CONDITIONAL(BUILD_SPEEXDSP, test "x$with_speexdsp" = "xyes" )
 
-
 dnl iLBC is enabled if it's installed
 AC_ARG_WITH([with-libilbc],
   [AS_HELP_STRING([--with-libilbc],
diff --git a/daemon/src/audio/Makefile.am b/daemon/src/audio/Makefile.am
index 52737f3024cf608869a5a9b9948e656d6de09701..f88b75b50393d47ee7f0ca2ed613ab281edb0d1a 100644
--- a/daemon/src/audio/Makefile.am
+++ b/daemon/src/audio/Makefile.am
@@ -39,6 +39,12 @@ libaudio_la_SOURCES = \
 		dcblocker.cpp
 
 libaudio_la_CXXFLAGS = -I$(top_srcdir)/src
+libaudio_la_LDFLAGS =
+
+if BUILD_SPEEXDSP
+libaudio_la_CXXFLAGS += @SPEEXDSP_CFLAGS@
+libaudio_la_LDFLAGS += @SPEEXDSP_LIBS@
+endif
 
 noinst_HEADERS = \
 		audiobuffer.h \
@@ -64,7 +70,7 @@ endif
 
 if BUILD_JACK
 libaudio_la_LIBADD += ./jack/libjacklayer.la
-libaudio_la_LDFLAGS = @JACK_LIBS@ -pthread
+libaudio_la_LDFLAGS += @JACK_LIBS@ -pthread
 endif
 
 if BUILD_ALSA
@@ -73,5 +79,5 @@ endif
 
 if BUILD_OPENSL
 libaudio_la_LIBADD += ./opensl/libopensl.la
-libaudio_la_LDFLAGS = -lOpenSLES
+libaudio_la_LDFLAGS += -lOpenSLES
 endif
diff --git a/daemon/src/audio/codecs/Makefile.am b/daemon/src/audio/codecs/Makefile.am
index 35af2bd77d798eea166b5f8b21e0a58b65f2d0a7..0ef029b1f1088764972a63392e0ed3681fcfad44 100644
--- a/daemon/src/audio/codecs/Makefile.am
+++ b/daemon/src/audio/codecs/Makefile.am
@@ -17,22 +17,22 @@ endif
 if BUILD_SPEEX
 SPEEX_NB_LIB = libcodec_speex_nb.so
 libcodec_speex_nb_so_SOURCES = speexcodec_nb.cpp speexcodec.h
-libcodec_speex_nb_so_CXXFLAGS = -fPIC -g -Wall $(SPEEXDSP)
-libcodec_speex_nb_so_LDFLAGS = --shared -lc -lspeex
+libcodec_speex_nb_so_CXXFLAGS = -fPIC -g -Wall @SPEEX_CFLAGS@
+libcodec_speex_nb_so_LDFLAGS = --shared -lc @SPEEX_LIBS@
 libcodec_speex_nb_so_LDADD = libcodecdescriptor.la
 INSTALL_SPEEX_NB_RULE = install-libcodec_speex_nb_so
 
 SPEEX_WB_LIB = libcodec_speex_wb.so
 libcodec_speex_wb_so_SOURCES = speexcodec_wb.cpp speexcodec.h
-libcodec_speex_wb_so_CXXFLAGS = -fPIC -g -Wall $(SPEEXDSP)
-libcodec_speex_wb_so_LDFLAGS = --shared -lc -lspeex
+libcodec_speex_wb_so_CXXFLAGS = -fPIC -g -Wall @SPEEX_CFLAGS@
+libcodec_speex_wb_so_LDFLAGS = --shared -lc @SPEEX_LIBS@
 libcodec_speex_wb_so_LDADD = libcodecdescriptor.la
 INSTALL_SPEEX_WB_RULE = install-libcodec_speex_wb_so
 
 SPEEX_UB_LIB = libcodec_speex_ub.so
 libcodec_speex_ub_so_SOURCES = speexcodec_ub.cpp speexcodec.h
-libcodec_speex_ub_so_CXXFLAGS = -fPIC -g -Wall $(SPEEXDSP)
-libcodec_speex_ub_so_LDFLAGS = --shared -lc -lspeex
+libcodec_speex_ub_so_CXXFLAGS = -fPIC -g -Wall @SPEEX_CFLAGS@
+libcodec_speex_ub_so_LDFLAGS = --shared -lc @SPEEX_LIBS@
 libcodec_speex_ub_so_LDADD = libcodecdescriptor.la
 INSTALL_SPEEX_UB_RULE = install-libcodec_speex_ub_so
 endif