1 # +------------------------------------------------------------------+
2 # | ____ _ _ __ __ _ __ |
3 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
4 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
5 # | | |___| | | | __/ (__| < | | | | . \ |
6 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
8 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
9 # +------------------------------------------------------------------+
11 # This file is part of Check_MK.
12 # The official homepage is at http://mathias-kettner.de/check_mk.
14 # check_mk is free software; you can redistribute it and/or modify it
15 # under the terms of the GNU General Public License as published by
16 # the Free Software Foundation in version 2. check_mk is distributed
17 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
18 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
19 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
20 # tails. You should have received a copy of the GNU General Public
21 # License along with GNU Make; see the file COPYING. If not, write
22 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 # Boston, MA 02110-1301 USA.
25 # Process this file with autoconf to produce a configure script.
28 AC_INIT([MK Livestatus], [1.6.0i1], [mk@mathias-kettner.de])
29 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign])
30 AC_CONFIG_MACRO_DIR([m4])
31 AC_CONFIG_SRCDIR([config.h.in])
32 AC_CONFIG_HEADER([config.h])
33 AC_DEFINE_UNQUOTED([BUILD_DATE], ["`date -R`"], [build date])
34 AC_DEFINE_UNQUOTED([BUILD_HOSTNAME], ["`uname -n`"], [name of the build host])
35 AC_REQUIRE_AUX_FILE([compile])
36 AC_REQUIRE_AUX_FILE([config.guess])
37 AC_REQUIRE_AUX_FILE([config.sub])
39 # Old (pre-1.6.0) versions of librrd were not thread-safe, so one has to use the
40 # thread-safe variant librrd_th explicitly. This in itself is already tragic
41 # enough, but to make things worse, you can't write a compile-time check to
42 # distinguish these versions. :-/ So we default to the assumption that librrd is
43 # thread-safe (which is the case within OMD) and the user of e.g. a standalone
44 # version of Livestatus on an old system has to use the configure flag below.
45 # Not really nice, but we can't really do much about that.
46 AC_ARG_ENABLE([rrd-is-thread-safe],
47 AS_HELP_STRING([--disable-rrd-is-thread-safe], [Use librrd_th instead of librrd]))
48 AS_IF([test "x$enable_rrd_is_thread_safe" != "xno"], [RRDLIB_TO_CHECK=rrd],
49 [RRDLIB_TO_CHECK=rrd_th])
51 # Checks for programs.
52 AC_PROG_CC([gcc-8 clang-7 gcc-7 clang-6.0 clang-5.0 gcc clang])
53 AC_PROG_CC_C99([], [])
54 if test "x$ac_cv_prog_cc_c99" = xno; then
55 AC_MSG_ERROR([Need a C99-compliant C compiler])
57 AC_PROG_CXX([g++-8 clang++-7 g++-7 clang++-6.0 clang++-5.0 g++ clang++])
58 AC_DEFINE_UNQUOTED([BUILD_CXX], ["`$CXX --version | head -n1`"], [C++ compiler])
59 AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
61 # automake 1.12 seems to require this, but automake 1.11 doesn't recognize it. :-P
62 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
64 # Checks for libraries.
65 AC_CHECK_LIB(socket, socket)
66 AC_CHECK_LIB(socket, connect)
67 AC_CHECK_LIB(socket, shutdown)
69 # Passing through the right RRD library is a bit tricky: We can't simply put
70 # -lrrd_th or -lrrd globally into LIBS. The problem is that our SUID programs
71 # icmpsender and icmpreceiver would be linked with that option, too, but because
72 # of security reasons the dynamic linker will ignore our LD_LIBRARY_PATH => no
73 # RRD library found or even the wrong one... :-/
76 AC_SEARCH_LIBS([rrd_xport], [$RRDLIB_TO_CHECK],
77 [test "$ac_cv_search_rrd_xport" = "none required" || RRDLIB="$ac_cv_search_rrd_xport"],
78 [AC_MSG_ERROR([unable to find the rrd_xport function])])
82 # Checks for header files.
86 AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/socket.h sys/time.h sys/timeb.h syslog.h unistd.h])
88 # Checks for C++ features
89 AX_BOOST_BASE(,,AC_MSG_ERROR([Boost library not found or too old]))
91 if test "x$ax_cv_boost_asio" = xno; then
92 AC_MSG_ERROR([Boost::ASIO library not found])
97 AC_MSG_CHECKING([whether C++17 headers are supported by default])
99 [AC_LANG_PROGRAM([#include <optional>
100 #include <shared_mutex>], [std::shared_mutex sm])],
101 [AC_MSG_RESULT([yes])],
103 CXX="$CXX -stdlib=libc++"
104 CXXCPP="$CXXCPP -stdlib=libc++"
105 AC_MSG_CHECKING([whether C++17 headers are supported with -stdlib=libc++])
107 [AC_LANG_PROGRAM([#include <optional>
108 #include <shared_mutex>], [std::shared_mutex sm])],
109 [AC_MSG_RESULT([yes])],
111 AC_MSG_ERROR([C++ headers are too old. Please install a newer g++/clang/libc++-dev package.])])])
115 [AS_HELP_STRING([--with-re2@<:@=ARG@:>@],
116 [use RE2 library from a standard location (ARG=yes),
117 from the specified location (ARG=<path>),
118 or disable it (ARG=no) @<:@ARG=no@:>@ ])],
120 [no],[want_re2="no";_AX_RE2_BASE_re2_path=""],
121 [yes],[want_re2="yes";_AX_RE2_BASE_re2_path=""],
122 [want_re2="yes";_AX_RE2_BASE_re2_path="$withval"])],
127 AS_IF([test "x$want_re2" = "xyes"],
128 [AS_IF([test "x$_AX_RE2_BASE_re2_path" != x],
129 [RE2_CPPFLAGS="-I$_AX_RE2_BASE_re2_path/include"
130 RE2_LDFLAGS="-L$_AX_RE2_BASE_re2_path/lib"])
132 CPPFLAGS_SAVED=$CPPFLAGS
133 CPPFLAGS="$CPPFLAGS $RE2_CPPFLAGS"
134 AC_CHECK_HEADER([re2/re2.h], [], [AC_MSG_ERROR([could not find a working RE2 header])])
135 AC_MSG_CHECKING([for RE2 library])
136 LDFLAGS_SAVED=$LDFLAGS
137 LDFLAGS="$LDFLAGS $RE2_LDFLAGS"
139 LIBS="$LIBS $RE2_LIBS -pthread"
140 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <re2/re2.h>]],
141 [[RE2::FullMatch("hello", "e")]])],
142 [AC_MSG_RESULT([yes])],
144 AC_MSG_ERROR([could not find a working RE2 library])])
146 LDFLAGS=$LDFLAGS_SAVED
147 CPPFLAGS=$CPPFLAGS_SAVED
148 AC_DEFINE([HAVE_RE2], [1], [Define to 1 if RE2 should be used.])])
149 AC_SUBST(RE2_CPPFLAGS)
150 AC_SUBST(RE2_LDFLAGS)
155 # Checks for typedefs, structures, and compiler characteristics.
167 # Checks for library functions.
168 AC_FUNC_SELECT_ARGTYPES
171 AC_CHECK_FUNCS([accept4 memmove select socket strerror strtoul])
173 AC_ARG_WITH(nagios4,AC_HELP_STRING([--with-nagios4],[enabled compilation for nagios 4]), [
174 CPPFLAGS="${CFLAGS} -DNAGIOS4"
175 nagios_headers=nagios4
177 nagios_headers=nagios)
178 AC_SUBST(nagios_headers)
180 # Compiling or executing a std::regex can fail with a stack overflow, causing
181 # our Livestatus threads to die, see e.g. the related bug report
182 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61582. A workaround for this is
183 # to limit the number of NFA states, but this must be done at compile-time. To
184 # be sure that the limit is defined before <regex> is included, we set it
185 # here. If the limit is reached during runtime, the regex library will throw a
186 # std::regex_error with a std::regex_constants::error_space code. This whole
187 # thing is a kind of a hack, but currently there seems to be no way around that,
188 # at least not until the libstdc++ uses heap allocated memory instead of the
191 # Some numbers for x86_64: At the point where we compile or execute a regex, we
192 # already use almost 12kB stack. For compilation of a regex, each level of
193 # recursion uses additional 112 bytes. For executing a regex, each level of
194 # recursion uses additional 384 bytes. Our current stack size for the Livestatus
195 # threads is 1MB, so we can handle roughly 2700 states. To be on the safe side,
196 # we leave some breathing room and use a slightly lower limit.
197 AC_DEFINE([_GLIBCXX_REGEX_STATE_LIMIT], [2500],
198 [the maximum number of states the regex NFA can have])
200 AC_DEFINE([BOOST_SYSTEM_NO_DEPRECATED], [1], [we do not want any old stuff])
202 # GCC is a bit picky about redefinitions of built-in macros. Alas, "built-in"
203 # simply means "starts with double underscore", so we have to hack around that
204 # below. Note that clang is happy, even without the guard.
205 AH_VERBATIM([__STDC_WANT_LIB_EXT1__], [/* we want C11 library extensions */
206 #ifndef __STDC_WANT_LIB_EXT1__
207 # define __STDC_WANT_LIB_EXT1__ 1
210 # HACKING ALERT: automake can't really handle optional subdirectories, so we
211 # have to do this in a slightly hacky way by using M4's silent includes.
212 m4_sinclude([livestatus/config_files.m4])
213 m4_sinclude([enterprise/config_files.m4])
214 m4_sinclude([standalone/config_files.m4])