diff --git a/configure.ac b/configure.ac
index 3928803d635ebfe84a85ec06ded8106f9b927fa3..3ec22c1ed0a4ff137b9eb966f43620c06295a097 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,6 +143,11 @@ AC_MSG_RESULT($rtc_ok)
 # Check for feenableexcept, should be present in C99, also checks for -lm.
 AC_CHECK_LIB([m],[feenableexcept])
 
+# Some examples require CBLAS and LAPACK, check for that and set conditional.
+AC_CHECK_HEADER([cblas.h])
+AC_CHECK_HEADER([lapacke.h])
+AM_CONDITIONAL([HAVECBLAS], [test $ac_cv_header_cblas_h = "yes" -a $ac_cv_header_lapacke_h = "yes"])
+
 # Check for git, needed for revision stamps.
 AC_PATH_PROG([GIT_CMD], [git])
 AC_SUBST([GIT_CMD])
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 61c0267a1446077a4c6dee450fc7f36ad12a4043..e3f0f9a18e12902b51ac702681eb46f5b95899ae 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -22,7 +22,10 @@ AM_CFLAGS = -I../src -DCPU_TPS=2.67e9 -DTIMERS
 AM_LDFLAGS =
 
 # Set-up the library
-bin_PROGRAMS = test test_qr test_bh test_bh_sorted test_fmm_sorted
+bin_PROGRAMS = test test_bh test_bh_sorted test_fmm_sorted
+if HAVECBLAS
+bin_PROGRAMS += test_qr 
+endif
 
 # Sources for test
 test_SOURCES = test.c