1# dnstap.m4 2 3# dt_DNSTAP(default_dnstap_socket_path, [action-if-true], [action-if-false]) 4# -------------------------------------------------------------------------- 5# Check for required dnstap libraries and add dnstap configure args. 6AC_DEFUN([dt_DNSTAP], 7[ 8 AC_ARG_ENABLE([dnstap], 9 AS_HELP_STRING([--enable-dnstap], 10 [Enable dnstap support (requires protobuf-c)]), 11 [opt_dnstap=$enableval], 12 [opt_dnstap=no]) 13 14 AC_ARG_WITH([dnstap-socket-path], 15 AS_HELP_STRING([--with-dnstap-socket-path=pathname], 16 [set default dnstap socket path]), 17 [opt_dnstap_socket_path=$withval], 18 [opt_dnstap_socket_path="$1"]) 19 20 if test "x$opt_dnstap" != "xno"; then 21 AC_PATH_PROG([PROTOC], [protoc]) 22 # 'protoc-c' is deprecated. We use 'protoc' instead. If it can not be 23 # found, try 'protoc-c'. 24 if test -z "$PROTOC"; then 25 AC_PATH_PROG([PROTOC_C], [protoc-c]) 26 else 27 PROTOC_C="$PROTOC" 28 fi 29 if test -z "$PROTOC_C"; then 30 AC_MSG_ERROR([[The protoc or protoc-c program was not found. It is needed for dnstap, use --disable-dnstap, or install protobuf-c to provide protoc or protoc-c]]) 31 fi 32 33 # Check for protoc-gen-c plugin 34 AC_PATH_PROG([PROTOC_GEN_C], [protoc-gen-c]) 35 if test -z "$PROTOC_GEN_C"; then 36 AC_MSG_ERROR([[The protoc-gen-c plugin was not found. It is needed for dnstap, use --disable-dnstap, or install protobuf-c-compiler to provide protoc-gen-c]]) 37 fi 38 39 # Test that protoc-gen-c actually works 40 AC_MSG_CHECKING([if protoc-gen-c plugin works]) 41 cat > conftest.proto << EOF 42syntax = "proto2"; 43message TestMessage { 44 optional string test_field = 1; 45} 46EOF 47 if $PROTOC_C --c_out=. conftest.proto >/dev/null 2>&1; then 48 AC_MSG_RESULT([yes]) 49 rm -f conftest.proto conftest.pb-c.c conftest.pb-c.h 50 else 51 AC_MSG_RESULT([no]) 52 rm -f conftest.proto conftest.pb-c.c conftest.pb-c.h 53 AC_MSG_ERROR([[The protoc-gen-c plugin is not working properly. Please ensure protobuf-c-compiler is properly installed]]) 54 fi 55 56 AC_ARG_WITH([protobuf-c], 57 AS_HELP_STRING([--with-protobuf-c=path], [Path where protobuf-c is installed, for dnstap]), 58 [ 59 # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0 60 if test -f $withval/include/google/protobuf-c/protobuf-c.h; then 61 CFLAGS="$CFLAGS -I$withval/include/google" 62 else 63 CFLAGS="$CFLAGS -I$withval/include" 64 fi 65 LDFLAGS="$LDFLAGS -L$withval/lib" 66 ], 67 [ 68 if test -n "$PKG_CONFIG"; then 69 PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c], 70 [ 71 CFLAGS="$CFLAGS $PROTOBUFC_CFLAGS" 72 LIBS="$LIBS $PROTOBUFC_LIBS" 73 ], 74 [ 75 # pkg-config failed; try falling back to known values 76 # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0 77 if test -f /usr/include/google/protobuf-c/protobuf-c.h; then 78 CFLAGS="$CFLAGS -I/usr/include/google" 79 else 80 if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then 81 CFLAGS="$CFLAGS -I/usr/local/include/google" 82 LDFLAGS="$LDFLAGS -L/usr/local/lib" 83 else 84 AC_MSG_ERROR([The protobuf-c package was not found with pkg-config. Please install protobuf-c!]) 85 fi 86 fi 87 ] 88 ) 89 else 90 # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0 91 if test -f /usr/include/google/protobuf-c/protobuf-c.h; then 92 CFLAGS="$CFLAGS -I/usr/include/google" 93 else 94 if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then 95 CFLAGS="$CFLAGS -I/usr/local/include/google" 96 LDFLAGS="$LDFLAGS -L/usr/local/lib" 97 fi 98 fi 99 fi 100 ] 101 ) 102 AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [], 103 AC_MSG_ERROR([The protobuf-c library was not found. Please install the development libraries for protobuf-c!])) 104 $2 105 else 106 $3 107 fi 108]) 109