From 59d98b9ef64e597c331c27160715d7a1b40c8638 Mon Sep 17 00:00:00 2001 From: Nick Cao Date: Fri, 26 Jan 2024 17:52:24 -0500 Subject: [PATCH] Search for protobuf-c with pkg-config --- dnstap/dnstap.m4 | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/dnstap/dnstap.m4 b/dnstap/dnstap.m4 index be8b40c45..a9202c115 100644 --- a/dnstap/dnstap.m4 +++ b/dnstap/dnstap.m4 @@ -30,15 +30,24 @@ AC_DEFUN([dt_DNSTAP], fi LDFLAGS="$LDFLAGS -L$withval/lib" ], [ - # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0 - if test -f /usr/include/google/protobuf-c/protobuf-c.h; then - CFLAGS="$CFLAGS -I/usr/include/google" - else - if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then - CFLAGS="$CFLAGS -I/usr/local/include/google" - LDFLAGS="$LDFLAGS -L/usr/local/lib" - fi - fi + ifdef([PKG_CHECK_MODULES], [ + PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c], [ + CFLAGS="$CFLAGS $PROTOBUFC_CFLAGS" + LIBS="$LIBS $PROTOBUFC_LIBS" + ], [ + AC_MSG_ERROR([The protobuf-c package was not found with pkg-config. Please install protobuf-c!]) + ]) + ], [ + # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0 + if test -f /usr/include/google/protobuf-c/protobuf-c.h; then + CFLAGS="$CFLAGS -I/usr/include/google" + else + if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then + CFLAGS="$CFLAGS -I/usr/local/include/google" + LDFLAGS="$LDFLAGS -L/usr/local/lib" + fi + fi + ]) ]) AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [], AC_MSG_ERROR([The protobuf-c library was not found. Please install the development libraries for protobuf-c!])) -- 2.47.2