]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/recursordist/configure.ac
Don't clobber C{,XX}FLAGS when set in env
[thirdparty/pdns.git] / pdns / recursordist / configure.ac
1 AC_PREREQ([2.61])
2
3 AC_INIT([pdns-recursor], m4_esyscmd(build-aux/gen-version))
4 AC_CONFIG_AUX_DIR([build-aux])
5 AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip tar-ustar -Wno-portability subdir-objects parallel-tests 1.11])
6 AM_SILENT_RULES([yes])
7 AC_CONFIG_SRCDIR([pdns_recursor.cc])
8 AC_CONFIG_MACRO_DIR([m4])
9
10 AC_CONFIG_HEADERS([config.h])
11
12 AC_CANONICAL_HOST
13 # Add some default CFLAGS and CXXFLAGS, can be appended to using the environment variables
14 CFLAGS="-Wall -g -O2 $CFLAGS"
15 CXXFLAGS="-Wall -g -O2 $CXXFLAGS"
16
17 AC_SUBST([pdns_configure_args],["$ac_configure_args"])
18 AC_DEFINE_UNQUOTED([PDNS_CONFIG_ARGS],
19 ["$pdns_configure_args"],
20 [pdns-recursor configure arguments]
21 )
22
23 AC_PROG_CC
24 AC_PROG_CXX
25 AC_LANG([C++])
26
27 AC_GNU_SOURCE
28
29 AC_DEFINE([RECURSOR], [1],
30 [This is the PowerDNS Recursor]
31 )
32
33 # Warn when pkg.m4 is missing
34 m4_pattern_forbid([^_?PKG_[A-Z_]+$], [*** pkg.m4 missing, please install pkg-config])
35
36 AX_CXX_COMPILE_STDCXX_11([ext], [mandatory])
37 AC_PROG_LIBTOOL
38
39 PDNS_CHECK_OS
40 PDNS_CHECK_NETWORK_LIBS
41 PTHREAD_SET_NAME
42
43 # Boost Context was introduced in 1.51 (Aug 2012), but there was an immediate
44 # API break in 1.52 (Nov 2012), so we only support that, and later.
45 pdns_context_library="System V ucontexts"
46
47 AC_DEFUN([PDNS_SELECT_CONTEXT_IMPL], [
48 AC_MSG_CHECKING([whether Boost is new enough to use the context library...])
49 if test $boost_major_version -ge 152; then
50 AC_MSG_RESULT([yes])
51 if test $boost_major_version -ge 157; then
52 BOOST_THREAD([$1])
53 m4_pattern_allow([^BOOST_THREAD_(LIBS|LDFLAGS)$])dnl
54 LIBS="$LIBS $BOOST_THREAD_LIBS"
55 LDFLAGS="$LDFLAGS $BOOST_THREAD_LDFLAGS"
56 fi
57 AC_MSG_NOTICE([checking whether the Boost context library actually links...])
58 if test $boost_major_version -ge 161; then
59 BOOST_FIND_HEADER([boost/context/detail/fcontext.hpp], [ : ], [
60 BOOST_FIND_LIB([context], [$1], [boost/context/detail/fcontext.hpp], [[]])
61 ])
62 else
63 BOOST_FIND_HEADER([boost/context/fcontext.hpp], [ : ], [
64 BOOST_FIND_LIB([context], [$1], [boost/context/fcontext.hpp], [[]])
65 ])
66 fi
67 case $boost_cv_lib_context in
68 (yes)
69 pdns_context_library="Boost context"
70 AC_MSG_NOTICE([MTasker will use the Boost context library for context switching])
71 ;;
72 *)
73 AC_MSG_NOTICE([Boost context library is missing])
74 AC_MSG_NOTICE([MTasker will use System V ucontexts for context switching])
75 ;;
76 esac
77 else
78 AC_MSG_RESULT([no])
79 AC_MSG_NOTICE([MTasker will use System V ucontexts for context switching])
80 fi
81 ])
82
83 PDNS_CHECK_CLOCK_GETTIME
84
85 boost_required_version=1.35
86
87 PDNS_WITH_PROTOBUF
88 AS_IF([test "x$PROTOBUF_LIBS" != "x" -a x"$PROTOC" != "x"],
89 # The protobuf code needs boost::uuid, which is available from 1.42 onward
90 [AC_MSG_WARN([Bumping minimal Boost requirement to 1.42. To keep the requirement at 1.35, disable protobuf support])
91 boost_required_version=1.42]
92 )
93
94 BOOST_REQUIRE([$boost_required_version])
95
96 # Check against flat_set header that requires boost >= 1.48
97 BOOST_FIND_HEADER([boost/container/flat_set.hpp], [AC_MSG_NOTICE([boost::container::flat_set not available, will fallback to std::set])])
98
99 PDNS_SELECT_CONTEXT_IMPL
100
101 PDNS_ENABLE_UNIT_TESTS
102 PDNS_ENABLE_REPRODUCIBLE
103
104 PDNS_WITH_LUA([mandatory])
105 AS_IF([test "x$LUAPC" = "xluajit"], [
106 # export all symbols to be able to use the Lua FFI interface
107 AC_MSG_NOTICE([Adding -rdynamic to export all symbols for the Lua FFI interface])
108 LDFLAGS="$LDFLAGS -rdynamic"
109 ])
110
111 PDNS_CHECK_LUA_HPP
112
113 PDNS_ENABLE_VERBOSE_LOGGING
114
115 # Crypto libraries
116 PDNS_CHECK_LIBCRYPTO([
117 ],[
118 AC_MSG_ERROR([OpenSSL/libcrypto not found])
119 ]
120 )
121 PDNS_CHECK_LIBCRYPTO_ECDSA
122 PDNS_CHECK_LIBCRYPTO_EDDSA
123 PDNS_WITH_LIBSODIUM
124 PDNS_WITH_LIBDECAF
125 PDNS_WITH_LIBCAP
126
127 PDNS_WITH_NET_SNMP
128
129 # check for tools we might need
130 PDNS_CHECK_RAGEL([pdns/dnslabeltext.cc], [www.powerdns.com])
131 PDNS_CHECK_CURL
132
133 AC_CHECK_FUNCS_ONCE([strcasestr getrandom arc4random])
134
135 PDNS_CHECK_PTHREAD_NP
136
137 AC_SUBST([socketdir])
138 socketdir="/var/run"
139 AC_ARG_WITH([socketdir],
140 [AS_HELP_STRING([--with-socketdir], [where the controlsocket lives @<:@default=/var/run@:>@])],
141 [socketdir="$withval"]
142 )
143
144 PDNS_ENABLE_NOD
145
146 AM_COND_IF([NOD_ENABLED],
147 [
148 BOOST_FILESYSTEM
149 AS_IF([test -z "$BOOST_FILESYSTEM_LIBS"], [ AC_MSG_ERROR([Boost filesystem library is not installed])])],
150 [])
151
152 AC_SUBST([nodcachedir])
153 nodcachedir='${localstatedir}/lib/pdns-recursor'
154 AC_ARG_WITH([nod-cache-dir],
155 [AS_HELP_STRING([--with-nodcachedir], [where newly observed domain cache files live @<:@default=LOCALSTATEDIR/lib/pdns-recursor@:>@])],
156 [nodcachedir="$withval"]
157 )
158
159 AC_MSG_CHECKING([whether we will enable compiler security checks])
160 AC_ARG_ENABLE([hardening],
161 [AS_HELP_STRING([--disable-hardening], [disable compiler security checks @<:@default=no@:>@])],
162 [enable_hardening=$enableval],
163 [enable_hardening=yes]
164 )
165 AC_MSG_RESULT([$enable_hardening])
166
167 AS_IF([test "x$enable_hardening" != "xno"], [
168 AC_CC_PIE
169 AC_CC_STACK_PROTECTOR
170 AC_CC_PARAM_SSP_BUFFER_SIZE([4])
171 AC_CC_D_FORTIFY_SOURCE
172 AC_LD_RELRO
173 ])
174
175 PDNS_ENABLE_SANITIZERS
176 PDNS_ENABLE_MALLOC_TRACE
177 PDNS_ENABLE_VALGRIND
178 AX_AVAILABLE_SYSTEMD
179 AX_CHECK_SYSTEMD_FEATURES
180 AM_CONDITIONAL([HAVE_SYSTEMD], [ test x"$systemd" = "xy" ])
181 PDNS_CHECK_VIRTUALENV
182
183 AC_SUBST(LIBS)
184
185 AC_SUBST([AM_CPPFLAGS],
186 ["AS_ESCAPE([-I$(top_builddir) -I$(top_srcdir)]) $THREADFLAGS $BOOST_CPPFLAGS"]
187 )
188
189 AC_SUBST([YAHTTP_CFLAGS], ['-I$(top_srcdir)/ext/yahttp'])
190 AC_SUBST([YAHTTP_LIBS], ['$(top_builddir)/ext/yahttp/yahttp/libyahttp.la'])
191
192 LDFLAGS="$RELRO_LDFLAGS $LDFLAGS"
193 CFLAGS="$PIE_CFLAGS $CFLAGS"
194 CXXFLAGS="$SANITIZER_FLAGS $PIE_CFLAGS $CXXFLAGS"
195 PROGRAM_LDFLAGS="$PIE_LDFLAGS $PROGRAM_LDFLAGS"
196 AC_SUBST([PROGRAM_LDFLAGS])
197
198 AC_CONFIG_FILES([Makefile
199 ext/Makefile
200 ext/json11/Makefile
201 ext/probds/Makefile
202 ext/yahttp/Makefile
203 ext/yahttp/yahttp/Makefile])
204
205 AC_OUTPUT
206
207 AC_MSG_NOTICE([])
208 AC_MSG_NOTICE([Configuration summary])
209 AC_MSG_NOTICE([=====================])
210 AC_MSG_NOTICE([])
211 AS_IF([test "x$pdns_configure_args" != "x"],
212 [summary_conf_opts=$pdns_configure_args],
213 [summary_conf_opts="(no options)"]
214 )
215 AC_MSG_NOTICE([PowerDNS Recursor configured with: $summary_conf_opts])
216 AC_MSG_NOTICE([])
217 AC_MSG_NOTICE([CC: $CC])
218 AC_MSG_NOTICE([CXX: $CXX])
219 AC_MSG_NOTICE([LD: $LD])
220 AC_MSG_NOTICE([CFLAGS: $CFLAGS])
221 AC_MSG_NOTICE([CPPFLAGS: $CPPFLAGS])
222 AC_MSG_NOTICE([CXXFLAGS: $CXXFLAGS])
223 AC_MSG_NOTICE([LDFLAGS: $LDFLAGS])
224 AC_MSG_NOTICE([LIBS: $LIBS])
225 AC_MSG_NOTICE([BOOST_CPPFLAGS: $BOOST_CPPFLAGS])
226 AC_MSG_NOTICE([])
227 AC_MSG_NOTICE([Features enabled])
228 AC_MSG_NOTICE([----------------])
229 AC_MSG_NOTICE([Lua: $LUAPC])
230 AC_MSG_NOTICE([OpenSSL ECDSA: $libcrypto_ecdsa])
231 AS_IF([test "x$LIBSODIUM_LIBS" != "x" || test "x$LIBDECAF_LIBS" != "x" || test "x$libcrypto_ed25519" = "xyes"],
232 [AC_MSG_NOTICE([ed25519: yes])],
233 [AC_MSG_NOTICE([ed25519: no])]
234 )
235 AS_IF([test "x$LIBDECAF_LIBS" != "x" || test "x$libcrypto_ed448" = "xyes"],
236 [AC_MSG_NOTICE([ed448: yes])],
237 [AC_MSG_NOTICE([ed448: no])]
238 )
239 AS_IF([test "x$PROTOBUF_LIBS" != "x" -a x"$PROTOC" != "x"],
240 [AC_MSG_NOTICE([Protobuf: yes])],
241 [AC_MSG_NOTICE([Protobuf: no])]
242 )
243 AS_IF([test "x$NET_SNMP_LIBS" != "x"],
244 [AC_MSG_NOTICE([SNMP: yes])],
245 [AC_MSG_NOTICE([SNMP: no])]
246 )
247 AS_IF([test "x$systemd" != "xn"],
248 [AC_MSG_NOTICE([systemd: yes])],
249 [AC_MSG_NOTICE([systemd: no])]
250 )
251 AM_COND_IF([NOD_ENABLED],
252 [AC_MSG_NOTICE([nod: yes])],
253 [AC_MSG_NOTICE([nod: no])]
254 )
255 AC_MSG_NOTICE([Context library: $pdns_context_library])
256 AC_MSG_NOTICE([])