xref: /freebsd/contrib/unbound/dnstap/dnstap.m4 (revision 5685098846d7f11ad642d9804d94dc7429a7b212)
1ff825849SDag-Erling Smørgrav# dnstap.m4
2ff825849SDag-Erling Smørgrav
3ff825849SDag-Erling Smørgrav# dt_DNSTAP(default_dnstap_socket_path, [action-if-true], [action-if-false])
4ff825849SDag-Erling Smørgrav# --------------------------------------------------------------------------
5ff825849SDag-Erling Smørgrav# Check for required dnstap libraries and add dnstap configure args.
6ff825849SDag-Erling SmørgravAC_DEFUN([dt_DNSTAP],
7ff825849SDag-Erling Smørgrav[
8ff825849SDag-Erling Smørgrav    AC_ARG_ENABLE([dnstap],
9ff825849SDag-Erling Smørgrav        AS_HELP_STRING([--enable-dnstap],
1025039b37SCy Schubert            [Enable dnstap support (requires protobuf-c)]),
11b7c0c8c1SCy Schubert        [opt_dnstap=$enableval],
12b7c0c8c1SCy Schubert        [opt_dnstap=no])
13ff825849SDag-Erling Smørgrav
14ff825849SDag-Erling Smørgrav    AC_ARG_WITH([dnstap-socket-path],
15ff825849SDag-Erling Smørgrav        AS_HELP_STRING([--with-dnstap-socket-path=pathname],
16ff825849SDag-Erling Smørgrav            [set default dnstap socket path]),
17b7c0c8c1SCy Schubert        [opt_dnstap_socket_path=$withval],
18b7c0c8c1SCy Schubert        [opt_dnstap_socket_path="$1"])
19ff825849SDag-Erling Smørgrav
20ff825849SDag-Erling Smørgrav    if test "x$opt_dnstap" != "xno"; then
21ff825849SDag-Erling Smørgrav        AC_PATH_PROG([PROTOC_C], [protoc-c])
22ff825849SDag-Erling Smørgrav        if test -z "$PROTOC_C"; then
23ff825849SDag-Erling Smørgrav          AC_MSG_ERROR([The protoc-c program was not found. Please install protobuf-c!])
24ff825849SDag-Erling Smørgrav        fi
25b7c0c8c1SCy Schubert        AC_ARG_WITH([protobuf-c],
26b7c0c8c1SCy Schubert            AS_HELP_STRING([--with-protobuf-c=path], [Path where protobuf-c is installed, for dnstap]),
27b7c0c8c1SCy Schubert            [
28ff825849SDag-Erling Smørgrav                # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
29ff825849SDag-Erling Smørgrav                if test -f $withval/include/google/protobuf-c/protobuf-c.h; then
30ff825849SDag-Erling Smørgrav                    CFLAGS="$CFLAGS -I$withval/include/google"
31ff825849SDag-Erling Smørgrav                else
32ff825849SDag-Erling Smørgrav                    CFLAGS="$CFLAGS -I$withval/include"
33ff825849SDag-Erling Smørgrav                fi
34ff825849SDag-Erling Smørgrav                LDFLAGS="$LDFLAGS -L$withval/lib"
35b7c0c8c1SCy Schubert            ],
36b7c0c8c1SCy Schubert            [
37*56850988SCy Schubert                if test -n "$PKG_CONFIG"; then
38b7c0c8c1SCy Schubert                    PKG_CHECK_MODULES([PROTOBUFC], [libprotobuf-c],
39b7c0c8c1SCy Schubert                        [
40b7c0c8c1SCy Schubert                            CFLAGS="$CFLAGS $PROTOBUFC_CFLAGS"
41b7c0c8c1SCy Schubert                            LIBS="$LIBS $PROTOBUFC_LIBS"
42b7c0c8c1SCy Schubert                        ],
43b7c0c8c1SCy Schubert                        [
44b7c0c8c1SCy Schubert                            # pkg-config failed; try falling back to known values
45b7c0c8c1SCy Schubert                            # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
46b7c0c8c1SCy Schubert                            if test -f /usr/include/google/protobuf-c/protobuf-c.h; then
47b7c0c8c1SCy Schubert                                CFLAGS="$CFLAGS -I/usr/include/google"
48b7c0c8c1SCy Schubert                            else
49b7c0c8c1SCy Schubert                                if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then
50b7c0c8c1SCy Schubert                                    CFLAGS="$CFLAGS -I/usr/local/include/google"
51b7c0c8c1SCy Schubert                                    LDFLAGS="$LDFLAGS -L/usr/local/lib"
52b7c0c8c1SCy Schubert                                else
53b7c0c8c1SCy Schubert                                    AC_MSG_ERROR([The protobuf-c package was not found with pkg-config. Please install protobuf-c!])
54b7c0c8c1SCy Schubert                                fi
55b7c0c8c1SCy Schubert                            fi
56b7c0c8c1SCy Schubert                        ]
57b7c0c8c1SCy Schubert                    )
58*56850988SCy Schubert                else
59ff825849SDag-Erling Smørgrav                    # workaround for protobuf-c includes at old dir before protobuf-c-1.0.0
60ff825849SDag-Erling Smørgrav                    if test -f /usr/include/google/protobuf-c/protobuf-c.h; then
61ff825849SDag-Erling Smørgrav                        CFLAGS="$CFLAGS -I/usr/include/google"
62ff825849SDag-Erling Smørgrav                    else
63ff825849SDag-Erling Smørgrav                        if test -f /usr/local/include/google/protobuf-c/protobuf-c.h; then
64ff825849SDag-Erling Smørgrav                            CFLAGS="$CFLAGS -I/usr/local/include/google"
65ff825849SDag-Erling Smørgrav                            LDFLAGS="$LDFLAGS -L/usr/local/lib"
66ff825849SDag-Erling Smørgrav                        fi
67ff825849SDag-Erling Smørgrav                    fi
68*56850988SCy Schubert                fi
69b7c0c8c1SCy Schubert            ]
70b7c0c8c1SCy Schubert        )
71ff825849SDag-Erling Smørgrav        AC_SEARCH_LIBS([protobuf_c_message_pack], [protobuf-c], [],
72103ba509SCy Schubert            AC_MSG_ERROR([The protobuf-c library was not found. Please install the development libraries for protobuf-c!]))
73ff825849SDag-Erling Smørgrav        $2
74ff825849SDag-Erling Smørgrav    else
75ff825849SDag-Erling Smørgrav        $3
76ff825849SDag-Erling Smørgrav    fi
77ff825849SDag-Erling Smørgrav])
78