xref: /freebsd/contrib/unbound/dnstap/dnstap.m4 (revision d9a42747950146bf03cda7f6e25d219253f8a57a)
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], [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], AS_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_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [],
44      AC_MSG_ERROR([The protobuf-c library was not found. Please install protobuf-c!]))
45    $2
46  else
47    $3
48  fi
49])
50