xref: /freebsd/contrib/unbound/dnstap/dnstap.m4 (revision 1719886f)
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_C], [protoc-c])
22        if test -z "$PROTOC_C"; then
23          AC_MSG_ERROR([The protoc-c program was not found. Please install protobuf-c!])
24        fi
25        AC_ARG_WITH([protobuf-c],
26            AS_HELP_STRING([--with-protobuf-c=path], [Path where protobuf-c is installed, for dnstap]),
27            [
28                # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
29                if test -f $withval/include/google/protobuf-c/protobuf-c.h; then
30                    CFLAGS="$CFLAGS -I$withval/include/google"
31                else
32                    CFLAGS="$CFLAGS -I$withval/include"
33                fi
34                LDFLAGS="$LDFLAGS -L$withval/lib"
35            ],
36            [
37                ifdef([PKG_CHECK_MODULES],
38                    [
39                        PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c],
40                            [
41                                CFLAGS="$CFLAGS $PROTOBUFC_CFLAGS"
42                                LIBS="$LIBS $PROTOBUFC_LIBS"
43                            ],
44                            [
45                                # pkg-config failed; try falling back to known values
46                                # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
47                                if test -f /usr/include/google/protobuf-c/protobuf-c.h; then
48                                    CFLAGS="$CFLAGS -I/usr/include/google"
49                                else
50                                    if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then
51                                        CFLAGS="$CFLAGS -I/usr/local/include/google"
52                                        LDFLAGS="$LDFLAGS -L/usr/local/lib"
53                                    else
54                                        AC_MSG_ERROR([The protobuf-c package was not found with pkg-config. Please install protobuf-c!])
55                                    fi
56                                fi
57                            ]
58                        )
59                    ],
60                    [
61                        # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
62                        if test -f /usr/include/google/protobuf-c/protobuf-c.h; then
63                            CFLAGS="$CFLAGS -I/usr/include/google"
64                        else
65                            if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then
66                                CFLAGS="$CFLAGS -I/usr/local/include/google"
67                                LDFLAGS="$LDFLAGS -L/usr/local/lib"
68                            fi
69                        fi
70                    ]
71                )
72            ]
73        )
74        AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [],
75            AC_MSG_ERROR([The protobuf-c library was not found. Please install the development libraries for protobuf-c!]))
76        $2
77    else
78        $3
79    fi
80])
81