diff --git a/autogen.sh b/autogen.sh index 2067c33c..0b8694e9 100755 --- a/autogen.sh +++ b/autogen.sh @@ -76,6 +76,15 @@ else echo "Found 'aclocal'." fi +# checking for pkg-config +check_helper pkg-config +if [ "$RET" = "1" ]; then + echo "You probably need to install the package 'pkg-config|pkgconf'." + ERROR=1 +else + echo "Found 'pkg-config'." +fi + # checking for libtool # The libtool helper maybe installed as 'libtoolize', checking for 'libtool' first. check_helper libtool @@ -100,7 +109,7 @@ if [ "$ERROR" = "1" ]; then echo "One or more needed tools are missing, exiting ..." echo "Please install the needed software packages and restart 'autogen.sh' again." echo - exit + exit 1 fi echo diff --git a/configure.ac b/configure.ac index 486b2eb3..b74b7121 100644 --- a/configure.ac +++ b/configure.ac @@ -16,6 +16,7 @@ m4_define([libcoap_version],[libcoap_major_version.libcoap_minor_version.libcoap AC_INIT([libcoap], [libcoap_version], [libcoap-developers@lists.sourceforge.net], [libcoap], [https://libcoap.net/]) AC_PREREQ([2.64]) AM_INIT_AUTOMAKE([1.10 -Wall no-define no-dist-gzip dist-bzip2]) +PKG_PROG_PKG_CONFIG([0.20]) # Generate one configuration header file for building the library itself with # an autogenerated template. We need later a second one (include/libcoap.h) @@ -219,29 +220,14 @@ AC_ARG_ENABLE([tests], [build_tests="no"]) if test "x$build_tests" = "xyes"; then - # CUnit ships not version within the pkgconfig file cunit.pc so we have to do some more work here - # Check for CUnit header files - AC_CHECK_HEADERS([CUnit/CUnit.h], - [], - [AC_MSG_WARN([==> You want to build the testing binary but the needed header files for CUnit could not be found!]) - AC_MSG_ERROR([==> Install the package that contains the headers or disable the testing binary using --disable-tests.]) - ]) - # Check now for libcunit - save_LIBS="$LIBS" - LIBS="" - CUNIT_LIBS="" - have_cunit=no - AC_SEARCH_LIBS([CU_add_suite], - [cunit], - [CUNIT_LIBS="$LIBS" - AC_DEFINE(HAVE_LIBCUNIT, [1], [Define if the system has libcunit]) - ], - [AC_MSG_WARN([==> You want to build the testing binary but the needed library 'libcunit' for linking could not be found!]) - AC_MSG_ERROR([==> Install the package that contains the library or disable the testing binary using --disable-tests.]) - ]) - LIBS="$save_LIBS" - AC_SUBST(CUNIT_LIBS) - HAVE_CUNIT="YES" + PKG_CHECK_MODULES([CUNIT], + [cunit >= 2.1], + [have_cunit=yes + AC_DEFINE(HAVE_LIBCUNIT, [1], [Define if the system has libcunit])], + [have_cunit=no + AC_MSG_WARN([==> You want to build the testing binary but the pkg-config file cunit.pc could not be found or installed CUnit version is too old!]) + AC_MSG_ERROR([==> Install the package(s) containing the development files for CUnit or disable the testing binary using --disable-tests.]) + ]) fi AM_CONDITIONAL(HAVE_CUNIT, [test "x$CUNIT_LIBS" != "x"])