fix the SO_REUSEPORT check in configure.ac
[lwes-journaller/github-mirror.git] / configure.ac
blob153c926eb8bed752d0e7a3965b7404cbff6dcbd5
1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT([lwes-journaller], [1.1.2], [lwes-devel@lists.sourceforge.net])
4 AM_INIT_AUTOMAKE([foreign])
6 dnl Determine the host type for the host specific inclusion below
7 AC_CANONICAL_HOST
9 dnl --- Variables I use later on --
11 SHORT_DESC="The LWES (Light Weight Event System) is a system for sending structured self describing events over multicast.  This is a journaller implementation that receives events and saves them to disk."
12 MAJOR_VERSION=`echo "[$]PACKAGE_VERSION" |
13                perl -ne 'm%^(\d+)\.% && print "[$]1"'`
14 MINOR_VERSION=`echo "[$]PACKAGE_VERSION" |
15                perl -ne 'm%^\d+\.(\d+)% && print "[$]1"'`
16 RELEASE_NUMBER=`echo "[$]PACKAGE_VERSION" |
17                 perl -ne 'm%^\d+\.\d+\.(\d+)% && print "[$]1"'`
18 MAJOR_VERSION_UNDERLINE=`echo "[$]MAJOR_VERSION" | perl -pe 'chomp; s/\W/_/g;'`
19 PACKAGE_UNDERLINE=`echo "[$]PACKAGE_NAME" | perl -pe 'chomp; s/\W/_/g;'`
20 PACKAGEPACKED=`echo "[$]PACKAGE_NAME" | perl -pe 'chomp; s/\W//g;'`
21 VERSION_UNDERLINE=`echo "[$]PACKAGE_VERSION" | perl -pe 'chomp; s/\W/_/g;'`
23 AC_SUBST(MAJOR_VERSION)
24 AC_SUBST(MINOR_VERSION)
25 AC_SUBST(RELEASE_NUMBER)
26 AC_SUBST(SHORT_DESC)
28 AC_SUBST(MAJOR_VERSION_UNDERLINE)
29 AC_SUBST(PACKAGE_UNDERLINE)
30 AC_SUBST(PACKAGEPACKED)
31 AC_SUBST(VERSION_UNDERLINE)
33 dnl -- set maintainer mode
34 AM_MAINTAINER_MODE
35 AC_SUBST(USE_MAINTAINER_MODE)
37 dnl -- we want a header to include in our source files with configure
38 dnl    info
39 AM_CONFIG_HEADER(src/config.h)
41 dnl -- make sure we have a C compiler and libtool
42 AC_PROG_CC
43 AM_PROG_LIBTOOL
45 dnl Checks for header files.
46 AC_HEADER_STDC
47 AC_HEADER_SYS_WAIT
48 AC_CHECK_HEADERS(fcntl.h limits.h sys/time.h unistd.h getopt.h sched.h)
49 AC_CHECK_HEADER(valgrind/valgrind.h,
50                 AC_DEFINE([HAVE_VALGRIND_HEADER],
51                           [1],
52                           [Define to 1 if the <valgrind/valgrind.h> header is on the system]))
53 AC_CHECK_HEADER(pthread.h,
54   AC_CHECK_LIB(pthread, pthread_join,[
55    THREAD_LIBS="-lpthread"
56    AC_DEFINE([HAVE_LIBPTHREAD], [1], [Define if pthread library is there (-lpthread)])
57    AC_DEFINE([HAVE_PTHREAD_H], [1], [Define if <pthread.h> is there])
58    WITH_THREADS="1"]))
59 AC_SUBST(THREAD_LIBS)
61 AX_PTHREAD_SET_NAME
63 AC_CHECK_HEADER(zlib.h,
64   AC_CHECK_LIB(z, gzopen,[
65    Z_LIBS="-lz"
66    AC_DEFINE([HAVE_LIBZ], [1], [Define if zlib library is there (-lz)])
67    AC_DEFINE([HAVE_LIBZ_H], [1], [Define if <zlib.h> is there])
68    WITH_ZLIB="1"]))
69 AC_SUBST(Z_LIBS)
71 dnl Check for LWES installed
72 PKG_CHECK_MODULES([LWES], [lwes-1 >= 1.1.2])
73 AC_SUBST(LWES_CFLAGS)
74 AC_SUBST(LWES_LIBS)
76 dnl Check for mondemand installed, if requested
77 AC_ARG_WITH([mondemand], AS_HELP_STRING([--with-mondemand],
78                           [Build with support for mondemand logging and statistics (default: disabled)]))
79 if test "x$with_mondemand" == "xyes"; then
80   PKG_CHECK_MODULES([MONDEMAND], [mondemand-4 >= 4.4.2])
81   AC_SUBST(MONDEMAND_CFLAGS)
82   AC_SUBST(MONDEMAND_LIBS)
83   AC_DEFINE(HAVE_MONDEMAND, 1, [System supports mondemand])
86 dnl Check for messaging
87 AC_MSG_CHECKING(for sys/msg support)
88 AC_TRY_COMPILE([
89                 #include <sys/msg.h>
90                 ],[ ],g_have_sys_msg=yes,g_have_sys_msg=no)
91 AC_MSG_RESULT($g_have_sys_msg)
92 if test "x$g_have_sys_msg" = "xyes" ; then
93   AC_DEFINE(HAVE_SYS_MSG_H, 1, [System supports sys/msg.h])
96 dnl Check for mqueue
97 AC_MSG_CHECKING(for mqueue support)
98 AC_TRY_COMPILE([
99                 #include <mqueue.h>
100                 ],[ ],g_have_mqueue=yes,g_have_mqueue=no)
101 AC_MSG_RESULT($g_have_mqueue)
102 if test "x$g_have_mqueue" = "xyes" ; then
103   AC_DEFINE(HAVE_MQUEUE_H, 1, [System supports mqueue.h])
105 AC_CHECK_LIB(rt, main)
107 dnl Checks for typedefs, structures, and compiler characteristics.
108 AC_C_CONST
109 AC_TYPE_MODE_T
110 AC_TYPE_SIZE_T
111 AC_HEADER_TIME
112 AC_STRUCT_TM
114 dnl Found this check here https://github.com/varnish/hitch with license
115 dnl ------------- BEGIN included chunk
116 dnl Copyright 2015-2016 Varnish Software
117 dnl Copyright 2012 Bump Technologies, Inc. All rights reserved.
118 dnl 
119 dnl Redistribution and use in source and binary forms, with or without modification, are
120 dnl permitted provided that the following conditions are met:
121 dnl 
122 dnl    1. Redistributions of source code must retain the above copyright notice, this list of
123 dnl       conditions and the following disclaimer.
124 dnl 
125 dnl    2. Redistributions in binary form must reproduce the above copyright notice, this list
126 dnl       of conditions and the following disclaimer in the documentation and/or other materials
127 dnl       provided with the distribution.
128 dnl 
129 dnl THIS SOFTWARE IS PROVIDED BY BUMP TECHNOLOGIES, INC. ``AS IS'' AND ANY EXPRESS OR IMPLIED
130 dnl WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
131 dnl FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BUMP TECHNOLOGIES, INC. OR
132 dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
133 dnl CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
134 dnl SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
135 dnl ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
136 dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
137 dnl ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
138 dnl 
139 dnl The views and conclusions contained in the software and documentation are those of the
140 dnl authors and should not be interpreted as representing official policies, either expressed
141 dnl or implied, of Bump Technologies, Inc.
142 AC_CACHE_CHECK([whether SO_REUSEPORT works],
143   [ac_cv_so_reuseport_works],
144   [AC_RUN_IFELSE(
145     [AC_LANG_PROGRAM([[
146 #include <sys/types.h>
147 #include <sys/socket.h>
148     ]], [[
149   int s = socket(AF_INET, SOCK_STREAM, 0);
150   int i = 5;
151   if (setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &i, sizeof i) < 0)
152     return (1);
153   return (0);
154 ]])],
155   [ac_cv_so_reuseport_works=yes],
156   [ac_cv_so_reuseport_works=no])
157   ]
159 if test "$ac_cv_so_reuseport_works" = yes; then
160   AC_DEFINE([HAVE_SO_REUSEPORT], [1], [Define if SO_REUSEPORT works])
162 dnl ------------- END included chunk
164 dnl Checks for library functions.
165 AC_FUNC_ALLOCA
166 AC_FUNC_MEMCMP
167 AC_FUNC_MMAP
168 AC_FUNC_VPRINTF
169 AC_CHECK_FUNCS(gettimeofday socket strerror)
171 dnl These are mostly for solaris
172 AC_CHECK_LIB(socket,main)
173 AC_CHECK_LIB(nsl,main)
174 AC_CHECK_LIB(xnet,main)
175 AC_CHECK_LIB(resolv,main)
177 dnl syslog check
178 AC_CHECK_FUNCS(syslog)
179 AC_CHECK_LIB(syslog,main)
181 dnl allow for an external gettimeofday function, mostly useful for people have
182 dnl reimplemented gettimeofday because the system call is slow (FreeBSD 4.11)
183 AC_ARG_ENABLE(external-gettimeofday,
184               [  --enable-external-gettimeofday=<header>  Provide an external definition of the gettimeofday function.  The header pointed to should contain a macro which defines GETTIMEOFDAY(t,tz).  The header will be included in the appropriate place, so that your macro is substituted],
185               [AC_DEFINE([HAVE_EXTERNAL_GETTIMEOFDAY], [1], [Define to 1 if there is an external gettimeofday defined])
186                AC_DEFINE_UNQUOTED([EXTERNAL_GETTIMEOFDAY_HEADER], "$enable_external_gettimeofday", [Header for external gettime of day])
187                ],
188               AC_MSG_WARN(using system gettimeofday))
190 dnl  -- determine the type of varargs this platform supports --
191 # check for flavours of varargs macros
192 AC_MSG_CHECKING(for ISO C99 varargs macros in C)
193 AC_TRY_COMPILE([],[
194 int a(int p1, int p2, int p3);
195 #define call_a(...) a(1,__VA_ARGS__)
196 call_a(2,3);
197 ],g_have_iso_c_varargs=yes,g_have_iso_c_varargs=no)
198 AC_MSG_RESULT($g_have_iso_c_varargs)
199 if test "x$g_have_iso_c_varargs" = "xyes" ; then
200   AC_DEFINE(HAVE_ISO_C_VARARGS, 1, [ISO C varargs])
203 AC_MSG_CHECKING(for GNUC varargs macros)
204 AC_TRY_COMPILE([],[
205 int a(int p1, int p2, int p3);
206 #define call_a(params...) a(1,params)
207 call_a(2,3);
208 ],g_have_gnuc_varargs=yes,g_have_gnuc_varargs=no)
209 AC_MSG_RESULT($g_have_gnuc_varargs)
210 if test "x$g_have_gnuc_varargs" = "xyes" ; then
211   AC_DEFINE(HAVE_GNUC_C_VARARGS, 1, [GNUC varargs])
215 # --- Coverage hooks ---
217 AC_ARG_ENABLE(coverage,
218               [  --enable-coverage      turn on -fprofile-arcs -ftest-coverage],              [case "${enableval}" in
219                 yes) ENABLE_COVERAGE=1 ;;
220                 no) ENABLE_COVERAGE=0 ;;
221                 *) AC_MSG_ERROR(bad value ${enableval} for --enable-cov) ;;
222               esac],
223               [ENABLE_COVERAGE=2])
225 if test "x[$]ENABLE_COVERAGE" = "x1"; then
226   AC_MSG_WARN(enable coverage)
227   CFLAGS="`echo \"[$]CFLAGS\" | perl -pe 's/-O\d+//g;'` -fprofile-arcs -ftest-coverage"
228   CXXFLAGS="`echo \"[$]CXXFLAGS\" | perl -pe 's/-O\d+//g;'` -fprofile-arcs -ftest-coverage"
231 AC_SUBST(ENABLE_COVERAGE)
233 # --- Compiler warnings ---
235 # for developer use, enable lots of compile warnings,
236 # but don't require this generally, because some system's
237 # header files (BSD) can't handle it
239 # NB: must add -Werror after AC_PROG_CC, etc., so do this last
241 AC_ARG_ENABLE(hardcore,
242               [  --disable-hardcore      turn off -W -Wall -Werror],
243               [case "${enableval}" in
244                 yes) ENABLE_HARDCORE=1 ;;
245                 no) ENABLE_HARDCORE=0 ;;
246                 *) AC_MSG_ERROR(bad value ${enableval} for --disable-hardcore) ;;              esac],
247               [ENABLE_HARDCORE=1])
249 if test "x[$]ENABLE_HARDCORE" = "x1"; then
250   AC_MSG_WARN(enable hardcore compile warnings)
251   if test "x$CXX" = "x"; then
252     dnl - only valid for C with newer gcc's
253     CPPFLAGS="[$]CPPFLAGS -Wmissing-prototypes"
254   fi
255   CPPFLAGS="[$]CPPFLAGS -Werror -W -Wall -Wpointer-arith -Wcast-align -Wwrite-strings"
259 AC_CONFIG_FILES([Makefile
260                  src/Makefile
261                  tests/Makefile
262                  doxygen.config])
263 AC_CONFIG_FILES([tests/test-wrapper.sh],
264                 [chmod +x tests/test-wrapper.sh])
266 AC_OUTPUT