# Copyright (C) 2001-2025 Zabbix SIA
# This program is free software: you can redistribute it and/or modify it under the terms of
# the GNU Affero General Public License as published by the Free Software Foundation, version 3.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.
AC_DEFUN([CMOCKA_TRY_LINK],
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
cmocka_run_group_tests(NULL, NULL, NULL);
]])],[found_cmocka="yes"],[])
AC_DEFUN([CMOCKA_CHECK_CONFIG],
If you want to specify cmocka installation directories:
AS_HELP_STRING([--with-cmocka@<:@=DIR@:>@],[use specific cmocka library @<:@default=yes@:>@, DIR is the cmocka library install directory.])],
if test "$withval" = "no"; then
elif test "$withval" = "yes"; then
want_cmocka=ifelse([$1],,[yes],[$1])
if test "x$want_cmocka" = "xyes"; then
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:])
AC_MSG_CHECKING(for cmocka support)
if test "x$_libcmocka_dir" = "xno"; then
if test -x "$PKG_CONFIG" && `$PKG_CONFIG --exists cmocka`; then
CMOCKA_CFLAGS="`$PKG_CONFIG --cflags cmocka`"
CMOCKA_LDFLAGS="`$PKG_CONFIG --libs cmocka`"
CMOCKA_LIBS="`$PKG_CONFIG --libs cmocka`"