1AC_PREREQ(2.64)
2
3m4_define(nmsg_major_version, 1)
4m4_define(nmsg_minor_version, 0)
5m4_define(nmsg_patchlevel_version, 1)
6m4_define(nmsg_version,
7	  nmsg_major_version.nmsg_minor_version.nmsg_patchlevel_version)
8m4_define(nmsg_version_number,
9	  m4_eval(nmsg_major_version * 1000000 + nmsg_minor_version * 1000 + nmsg_patchlevel_version))
10
11AC_INIT([nmsg],
12        [nmsg_version()],
13        [https://github.com/farsightsec/nmsg/issues],
14        [nmsg],
15        [https://github.com/farsightsec/nmsg])
16AC_CONFIG_SRCDIR([nmsg/nmsg.h])
17AC_CONFIG_AUX_DIR([build-aux])
18AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules subdir-objects])
19AC_PROG_CC_STDC
20AC_USE_SYSTEM_EXTENSIONS
21AC_SYS_LARGEFILE
22AC_CONFIG_MACRO_DIR([m4])
23AM_SILENT_RULES([yes])
24LT_INIT
25
26NMSG_MAJOR_VERSION=nmsg_major_version()
27NMSG_MINOR_VERSION=nmsg_minor_version()
28NMSG_PATCHLEVEL_VERSION=nmsg_patchlevel_version()
29NMSG_VERSION=nmsg_version()
30NMSG_VERSION_NUMBER=nmsg_version_number()
31
32AC_SUBST(NMSG_MAJOR_VERSION)
33AC_SUBST(NMSG_MINOR_VERSION)
34AC_SUBST(NMSG_PATCHLEVEL_VERSION)
35AC_SUBST(NMSG_VERSION)
36AC_SUBST(NMSG_VERSION_NUMBER)
37
38AC_PROG_LN_S
39
40AC_CONFIG_FILES([Makefile doc/doxygen/Doxyfile nmsg/libnmsg.pc nmsg/version.h])
41
42AC_CONFIG_FILES([tests/json-utf8-tests/test.sh],
43                [chmod +x tests/json-utf8-tests/test.sh])
44
45AC_CONFIG_FILES([tests/nmsg-dnstap-tests/test.sh],
46                [chmod +x tests/nmsg-dnstap-tests/test.sh])
47
48AC_CONFIG_FILES([tests/udp-checksum-tests/test.sh],
49                [chmod +x tests/udp-checksum-tests/test.sh])
50
51AC_CONFIG_FILES([tests/payload-crc32c-tests/test.sh],
52                [chmod +x tests/payload-crc32c-tests/test.sh])
53
54AC_CONFIG_FILES([tests/string-tests/test.sh],
55                [chmod +x tests/string-tests/test.sh])
56
57AC_CONFIG_HEADER([config.h])
58
59my_PKG_CONFIG_FILES([LIBNMSG_PC], [nmsg/libnmsg.pc])
60
61my_CFLAGS="-Wall \
62-Wmissing-declarations -Wmissing-prototypes \
63-Wnested-externs -Wpointer-arith \
64-Wpointer-arith -Wsign-compare -Wchar-subscripts \
65-Wstrict-prototypes -Wshadow \
66-Wformat-security"
67AC_SUBST([my_CFLAGS])
68
69AC_CHECK_HEADERS([libgen.h])
70
71AC_SEARCH_LIBS([socket], [socket])
72AC_CHECK_FUNCS([socket])
73
74AC_SEARCH_LIBS([inet_pton], [nsl])
75AC_CHECK_FUNCS([inet_pton])
76
77AC_SEARCH_LIBS([clock_gettime], [rt])
78AC_CHECK_FUNCS([clock_gettime])
79
80AC_SEARCH_LIBS([clock_nanosleep], [rt])
81AC_CHECK_FUNCS([clock_nanosleep])
82
83AC_SEARCH_LIBS([dlopen], [dl])
84AC_CHECK_FUNCS([dlopen])
85
86AC_SEARCH_LIBS([floor], [m])
87AC_CHECK_FUNCS([floor])
88
89AX_PTHREAD([
90    LIBS="$PTHREAD_LIBS $LIBS"
91    CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
92    CC="$PTHREAD_CC"
93])
94
95AC_C_BIGENDIAN
96
97AC_CHECK_HEADERS([sys/endian.h endian.h])
98AC_CHECK_DECLS([htole32, le32toh], [], [], [
99#ifdef HAVE_ENDIAN_H
100# include <endian.h>
101#else
102# ifdef HAVE_SYS_ENDIAN_H
103#  include <sys/endian.h>
104# endif
105#endif
106])
107
108AC_CHECK_HEADERS([sys/types.h sys/socket.h])
109AC_CHECK_MEMBER(
110    [struct sockaddr.sa_len],
111    AC_DEFINE([HAVE_SA_LEN], [1], [Define to 1 if struct sockaddr has an sa_len member.]),
112    [],
113    [[
114#ifdef HAVE_SYS_TYPES_H
115# include <sys/types.h>
116#endif
117
118#ifdef HAVE_SYS_SOCKET_H
119# include <sys/socket.h>
120#endif
121    ]]
122)
123
124###
125### External library dependencies: libpcap, libprotobuf-c, libwdns, zeromq, yajl, libz
126###
127
128MY_CHECK_LIBPCAP
129
130PKG_CHECK_MODULES([libprotobuf_c], [libprotobuf-c >= 1.0.1])
131AC_PATH_PROG([PROTOC_C], [protoc-c])
132AS_IF([test -z "$PROTOC_C"],
133      [AC_MSG_ERROR([The protoc-c program was not found. Please install the protobuf-c compiler!])])
134
135PKG_CHECK_MODULES([libwdns], [libwdns >= 0.8.0])
136
137AC_ARG_WITH([zmq], AS_HELP_STRING([--without-libzmq], [Disable zmq support]))
138if test "x$with_libzmq" != "xno"; then
139    PKG_CHECK_MODULES([libzmq], [libzmq >= 4.2.0])
140    AC_DEFINE([HAVE_LIBZMQ], [1], [Define to 1 if libzmq support is enabled.])
141    use_libzmq="true"
142else
143    use_libzmq="false"
144fi
145
146AC_ARG_WITH([yajl], AS_HELP_STRING([--without-yajl], [Disable yajl support]))
147if test "x$with_yajl" != "xno"; then
148    PKG_CHECK_MODULES([yajl], [yajl >= 2.1.0])
149    AC_DEFINE([HAVE_YAJL], [1], [Define to 1 if yajl support is enabled.])
150    use_yajl="true"
151else
152    use_yajl="false"
153fi
154
155AC_CHECK_HEADER([zlib.h], [], [ AC_MSG_ERROR([required header file not found]) ])
156AC_CHECK_LIB([z], [deflate], [], [ AC_MSG_ERROR([required library not found]) ])
157
158###
159### External documentation toolchain dependencies: doxygen, docbook
160###
161
162AC_PATH_PROG([DOXYGEN], [doxygen])
163AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
164if test -n "$DOXYGEN"; then
165    DOC_HTML_MSG="yes, doxygen available: $DOXYGEN"
166else
167    DOC_HTML_MSG="no, doxygen not available"
168fi
169
170AX_PROG_XSLTPROC([--nonet])
171MY_CHECK_DOCBOOK_NS_XSLT_MIN(1.76.1)
172AM_CONDITIONAL([BUILD_MAN], [test "x$XSLTPROC" != "x" -a "x$DOCBOOK_NS_XSLT_CURRENT_VERSION" != "xno"])
173if test "x$XSLTPROC" != "x" -a "x$DOCBOOK_NS_XSLT_CURRENT_VERSION" != "xno"; then
174    DOC_MAN_MSG="yes"
175else
176    DOC_MAN_MSG="no"
177fi
178
179###
180### libnmsg etc and plugin directories.
181###
182
183AX_DEFINE_DIR([NMSG_ETCDIR], ["sysconfdir"], [nmsg etc directory])
184
185AC_ARG_WITH(
186    [pluginsdir],
187    AC_HELP_STRING([--with-pluginsdir=DIR], [nmsg plugins directory]),
188    [ AX_DEFINE_DIR([NMSG_PLUGINSDIR], ["withval"], [nmsg plugins directory]) ],
189    [
190        nmsg_pluginsdir=$libdir/nmsg
191        AX_DEFINE_DIR([NMSG_PLUGINSDIR], ["nmsg_pluginsdir"], [nmsg plugins directory])
192    ]
193)
194
195AC_OUTPUT
196AC_MSG_RESULT([
197    $PACKAGE $VERSION
198
199        compiler:               ${CC}
200        cflags:                 ${CFLAGS}
201        ldflags:                ${LDFLAGS}
202        libs:                   ${LIBS}
203
204        prefix:                 ${prefix}
205        sysconfdir:             ${sysconfdir}
206        libdir:                 ${libdir}
207        includedir:             ${includedir}
208        pkgconfigdir:           ${pkgconfigdir}
209
210        plugins directory:      ${NMSG_PLUGINSDIR}
211
212        bigendian:              ${ac_cv_c_bigendian}
213        libzmq support:         ${use_libzmq}
214        yajl support:           ${use_yajl}
215
216        building html docs:     ${DOC_HTML_MSG}
217        building manpage docs:  ${DOC_MAN_MSG}
218])
219