mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-24 16:11:03 +03:00
configure.ac: simplify the CUnit check by pkg-config
The old behaviour on testing for CUnit library and header files (that
are needed while building the internal testbinary) was done on manually
search for the header and the library file without a real need because
CUnit ships a pkg-config file with a version for longer time.
By using the PKG_CHECK_MODULES macro the check is much easier as the
pkg-config file is serving all the needed information like the search
path for the header files as also LDFLAGS for linking against. This
ensures the environment variables are always setup correctly.
Note that FreeBSD uses for example /usr/include and /user/local/include
for the header files, the pkg-config files can be found in
/usr{/local}/libdata/pkgconfig. The pkg-config file will pick up the
right places then.
This commit is contained in:
1 parent
de80514661
commit
2be9ec9dff
2 files changed
+19
-24
No files matched your search
+10
-1
@@ -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
|
||||
|
||||
+9
-23
@@ -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"])
|
||||
|
||||
|
||||
Reference in new issue
Block a user