xref: /freebsd/contrib/unbound/dnstap/dnstap.m4 (revision fed1ca4b719c56c930f2259d80663cd34be812bb)
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 fstrm, protobuf-c)]),
11    [opt_dnstap=$enableval], [opt_dnstap=no])
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_C], [protoc-c])
20    if test -z "$PROTOC_C"; then
21      AC_MSG_ERROR([The protoc-c program was not found. Please install protobuf-c!])
22    fi
23    AC_ARG_WITH([protobuf-c], AC_HELP_STRING([--with-protobuf-c=path],
24    	[Path where protobuf-c is installed, for dnstap]), [
25	  # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
26	  if test -f $withval/include/google/protobuf-c/protobuf-c.h; then
27	    CFLAGS="$CFLAGS -I$withval/include/google"
28	  else
29	    CFLAGS="$CFLAGS -I$withval/include"
30	  fi
31	  LDFLAGS="$LDFLAGS -L$withval/lib"
32	], [
33	  # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
34	  if test -f /usr/include/google/protobuf-c/protobuf-c.h; then
35	    CFLAGS="$CFLAGS -I/usr/include/google"
36	  else
37	    if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then
38	      CFLAGS="$CFLAGS -I/usr/local/include/google"
39	      LDFLAGS="$LDFLAGS -L/usr/local/lib"
40	    fi
41	  fi
42    ])
43    AC_ARG_WITH([libfstrm], AC_HELP_STRING([--with-libfstrm=path],
44    	[Path where libfstrm is installed, for dnstap]), [
45	CFLAGS="$CFLAGS -I$withval/include"
46	LDFLAGS="$LDFLAGS -L$withval/lib"
47    ])
48    AC_SEARCH_LIBS([fstrm_iothr_init], [fstrm], [],
49      AC_MSG_ERROR([The fstrm library was not found. Please install fstrm!]))
50    AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [],
51      AC_MSG_ERROR([The protobuf-c library was not found. Please install protobuf-c!]))
52    $2
53  else
54    $3
55  fi
56])
57