From 1c7f25390572025baa6783ede14523e22fc73043 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Mon, 1 Jul 2013 10:23:03 +0200 Subject: BUILD: Use pkg-config to detect cmocka --- src/external/libcmocka.m4 | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'src/external/libcmocka.m4') diff --git a/src/external/libcmocka.m4 b/src/external/libcmocka.m4 index c5732761..740d9ad2 100644 --- a/src/external/libcmocka.m4 +++ b/src/external/libcmocka.m4 @@ -1,19 +1,18 @@ -dnl this file will be simplified when cmocka carries a .pc file -AC_SUBST(CMOCKA_LIBS) -AC_SUBST(CMOCKA_CFLAGS) - -AC_CHECK_HEADERS( - [setjmp.h cmocka.h], - [AC_CHECK_LIB([cmocka], [_will_return], - [ CMOCKA_LIBS="-lcmocka" - have_cmocka="yes" ], - [AC_MSG_WARN([No libcmocka library found]) - have_cmocka="no" ])], - [AC_MSG_WARN([libcmocka header files not installed])], - [[ #include - # include - #ifdef HAVE_SETJMP_H - # include - #endif - ]] -) +dnl A macro to check presence of cmocka on the system +AC_DEFUN([AM_CHECK_CMOCKA], +[ + PKG_CHECK_EXISTS(cmocka, + [AC_CHECK_HEADERS([stdarg.h stddef.h setjmp.h], + [], dnl We are only intrested in action-if-not-found + [AC_MSG_WARN([Header files stdarg.h stddef.h setjmp.h are required by cmocka]) + cmocka_required_headers="no" + ] + ) + AS_IF([test x"$cmocka_required_headers" != x"no"], + [PKG_CHECK_MODULES([CMOCKA], [cmocka], [have_cmocka="yes"])] + )], + dnl PKG_CHECK_EXISTS ACTION-IF-NOT-FOUND + [AC_MSG_WARN([No libcmocka library found, cmocka tests will not be built])] + ) + AM_CONDITIONAL([HAVE_CMOCKA], [test x$have_cmocka = xyes]) +]) -- cgit