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. 6 AC_DEFUN([dt_DNSTAP], 7 [ 8 AC_ARG_ENABLE([dnstap], 9 AS_HELP_STRING([--disable-dnstap], 10 [Disable dnstap support (requires fstrm, protobuf-c)]), 11 [opt_dnstap=$enableval], [opt_dnstap=yes]) 12 13 AC_ARG_WITH([dnstap-socket-path], 14 AS_HELP_STRING([--with-dnstap-socket-path=pathname], 15 [set default dnstap socket path]), 16 [opt_dnstap_socket_path=$withval], [opt_dnstap_socket_path="$1"]) 17 18 if test "x$opt_dnstap" != "xno"; then 19 AC_PATH_PROG([PROTOC], [protoc]) 20 # 'protoc-c' is deprecated. We use 'protoc' instead. If it can not be 21 # found, try 'protoc-c'. 22 if test -z "$PROTOC"; then 23 AC_PATH_PROG([PROTOC_C], [protoc-c]) 24 else 25 PROTOC_C="$PROTOC" 26 fi 27 if test -z "$PROTOC_C"; then 28 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]]) 29 fi 30 31 # Check for protoc-gen-c plugin 32 AC_PATH_PROG([PROTOC_GEN_C], [protoc-gen-c]) 33 if test -z "$PROTOC_GEN_C"; then 34 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]]) 35 fi 36 37 # Test that protoc-gen-c actually works 38 AC_MSG_CHECKING([if protoc-gen-c plugin works]) 39 cat > conftest.proto << EOF 40 syntax = "proto2"; 41 message TestMessage { 42 optional string test_field = 1; 43 } 44 EOF 45 if $PROTOC_C --c_out=. conftest.proto >/dev/null 2>&1; then 46 AC_MSG_RESULT([yes]) 47 rm -f conftest.proto conftest.pb-c.c conftest.pb-c.h 48 else 49 AC_MSG_RESULT([no]) 50 rm -f conftest.proto conftest.pb-c.c conftest.pb-c.h 51 AC_MSG_ERROR([[The protoc-gen-c plugin is not working properly. Please ensure protobuf-c-compiler is properly installed]]) 52 fi 53 54 AC_ARG_WITH([protobuf-c], AS_HELP_STRING([--with-protobuf-c=path], 55 [Path where protobuf-c is installed, for dnstap]), [ 56 # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0 57 if test -f $withval/include/google/protobuf-c/protobuf-c.h; then 58 CFLAGS="$CFLAGS -I$withval/include/google" 59 else 60 CFLAGS="$CFLAGS -I$withval/include" 61 fi 62 LDFLAGS="$LDFLAGS -L$withval/lib" 63 ], [ 64 # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0 65 if test -f /usr/include/google/protobuf-c/protobuf-c.h; then 66 CFLAGS="$CFLAGS -I/usr/include/google" 67 else 68 if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then 69 CFLAGS="$CFLAGS -I/usr/local/include/google" 70 LDFLAGS="$LDFLAGS -L/usr/local/lib" 71 fi 72 fi 73 ]) 74 AC_ARG_WITH([libfstrm], AS_HELP_STRING([--with-libfstrm=path], 75 [Path where libfstrm is installed, for dnstap]), [ 76 CFLAGS="$CFLAGS -I$withval/include" 77 LDFLAGS="$LDFLAGS -L$withval/lib" 78 ]) 79 AC_SEARCH_LIBS([fstrm_iothr_init], [fstrm], [], 80 AC_MSG_ERROR([[The fstrm library was not found. It is needed for dnstap, use --disable-dnstap, or install fstrm-devel]])) 81 AC_CHECK_FUNCS([fstrm_tcp_writer_options_init], [], 82 AC_MSG_ERROR([[The fstrm library >= 0.4 was not found. It is needed for dnstap, use --disable-dnstap, or install fstrm-devel]])) 83 AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [], 84 AC_MSG_ERROR([[The protobuf-c library was not found. It is needed for dnstap, use --disable-dnstap, or install protobuf-c]])) 85 $2 86 else 87 $3 88 fi 89 ]) 90