2 AC_INIT([dnscrypt-proxy],[1.9.4],[https://dnscrypt.org])
3 AC_CONFIG_MACRO_DIR([m4])
4 AC_CONFIG_AUX_DIR([libltdl/config])
5 AC_CONFIG_SRCDIR([src/proxy/app.c])
6 AC_CONFIG_HEADER([config.h])
7 AC_CONFIG_SUBDIRS([src/libevent-modified])
9 AM_INIT_AUTOMAKE([1.11 dist-bzip2 tar-ustar gnu subdir-objects])
10 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
15 ISODATE=`date +%Y-%m-%d`
19 LX_CFLAGS=${CFLAGS-NONE}
24 [AS_HELP_STRING(--disable-ssp,Do not compile with -fstack-protector)],
26 AS_IF([test "x$enableval" = "xno"], [
37 [AS_HELP_STRING(--disable-pie,Do not produce position independent executables)],
38 enable_pie=$enableval, enable_pie="maybe")
40 AS_CASE([$host_os], [mingw*], [enable_pie="no"])
43 [AS_HELP_STRING(--with-safecode,For maintainers only - please do not use)],
44 [AS_IF([test "x$withval" = "xyes"], [
45 AC_ARG_VAR([SAFECODE_HOME], [set to the safecode base directory])
46 : ${SAFECODE_HOME:=/opt/safecode}
47 LDFLAGS="$LDFLAGS -L${SAFECODE_HOME}/lib"
48 LIBS="$LIBS -lsc_dbg_rt -lpoolalloc_bitmap -lstdc++"
49 CFLAGS="$CFLAGS -fmemsafety"
53 AC_ARG_ENABLE(plugins,
54 [AS_HELP_STRING(--disable-plugins,Disable support for plugins)],
56 AS_IF([test "x$enableval" = "xno"], [
65 AS_IF([test "$plugins" = "enabled"], [
66 CPPFLAGS="$CPPFLAGS -DPLUGINS=1"
68 AM_CONDITIONAL(PLUGINS, test x$plugins = xenabled)
71 [AS_HELP_STRING(--enable-debug,For maintainers only - please do not use)],
73 AS_IF([test "x$enableval" = "xyes"], [
74 AS_IF([test "x$LX_CFLAGS" = "xNONE"], [
76 for flag in `echo $CFLAGS`; do
80 [*], [AS_VAR_APPEND([nxflags], [" $flag"])])
82 CFLAGS="$nxflags -O0 -g3"
84 CPPFLAGS="$CPPFLAGS -DDEBUG=1"
88 relaxed_plugins_permissions=disabled
89 AC_ARG_ENABLE(relaxed-plugins-permissions,
90 [AS_HELP_STRING(--enable-relaxed-plugins-permissions,Allow loading plugins owned by other users)],
92 AS_IF([test "x$enableval" != "xno"], [
93 CPPFLAGS="$CPPFLAGS -DRELAXED_PLUGINS_PERMISSIONS=1"
94 relaxed_plugins_permissions=enabled
97 AM_CONDITIONAL(RELAXED_PLUGINS_PERMISSIONS, test x$relaxed_plugins_permissions = xenabled)
100 AC_ARG_ENABLE(plugins-root,
101 [AS_HELP_STRING(--enable-plugins-root,Only load plugins sitting in the default plugins directory)],
103 AS_IF([test "x$enableval" != "xno"], [
104 CPPFLAGS="$CPPFLAGS -DENABLE_PLUGINS_ROOT=1"
108 AM_CONDITIONAL(ENABLE_PLUGINS_ROOT, test x$plugins_root = xenabled)
110 AC_ARG_WITH([systemd],
111 AS_HELP_STRING([--with-systemd], [build with support for systemd])
115 AS_IF([test "x$with_systemd" = "xyes"], [
116 PKG_CHECK_MODULES([SYSTEMD], [libsystemd], [have_systemd=yes], [
117 PKG_CHECK_MODULES([SYSTEMD_DAEMON], [libsystemd-daemon], [have_systemd=yes], [have_systemd=no])
119 AS_CASE([$with_systemd:$have_systemd],
121 [AC_MSG_ERROR([systemd expected but libsystemd not found -- maybe you need to install the pkg-config and libsystemd-dev packages])],
123 AC_DEFINE([HAVE_LIBSYSTEMD], [1], [Define if libsystemd is available])
126 AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$have_systemd" = "xyes"])
133 AC_USE_SYSTEM_EXTENSIONS
135 AX_CHECK_COMPILE_FLAG([-D_FORTIFY_SOURCE=2],
136 [CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"])
138 AS_CASE([$host_os], [cygwin*|mingw*|msys|pw32*|cegcc*], [ ], [
139 AX_CHECK_COMPILE_FLAG([-fPIC], [CFLAGS="$CFLAGS -fPIC"])
142 AS_IF([test "$enable_pie" != "no"],[
143 AX_CHECK_COMPILE_FLAG([-fPIE], [
144 AX_CHECK_LINK_FLAG([-pie], [
145 [CFLAGS="$CFLAGS -fPIE"
146 LDFLAGS="$LDFLAGS -pie"]
151 AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
152 AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CFLAGS="$CFLAGS -fno-strict-overflow"], [
153 AX_CHECK_COMPILE_FLAG([-fwrapv], [CFLAGS="$CFLAGS -fwrapv"])
157 [cygwin* | mingw* | pw32* | cegcc*], [
158 AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
159 AX_CHECK_LINK_FLAG([-Wl,--high-entropy-va], [LDFLAGS="$LDFLAGS -Wl,--high-entropy-va"])
160 AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
163 AS_IF([test "x$enable_ssp" != "xno"],[
166 [cygwin* | mingw* | pw32* | cegcc*], [ ],
168 AX_CHECK_COMPILE_FLAG([-fstack-protector-strong],
169 [CFLAGS="$CFLAGS -fstack-protector-strong"],
170 [AX_CHECK_COMPILE_FLAG([-fstack-protector-all],
171 [CFLAGS="$CFLAGS -fstack-protector-all"])]
176 AX_CHECK_COMPILE_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"])
177 AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"])
178 AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
179 AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CFLAGS="$CFLAGS -Wsometimes-uninitialized"])
181 AC_ARG_VAR([CWFLAGS], [define to compilation flags for generating extra warnings])
183 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wall], [CWFLAGS="$CWFLAGS -Wall"])
184 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wextra], [CWFLAGS="$CWFLAGS -Wextra"])
186 AC_MSG_CHECKING(for clang)
187 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
193 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wno-unknown-warning-option],
194 [CWFLAGS="$CWFLAGS -Wno-unknown-warning-option"])],
198 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wbad-function-cast], [CWFLAGS="$CWFLAGS -Wbad-function-cast"])
199 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-align], [CWFLAGS="$CWFLAGS -Wcast-align"])
200 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-qual], [CWFLAGS="$CWFLAGS -Wcast-qual"])
201 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wchar-subscripts], [CWFLAGS="$CWFLAGS -Wchar-subscripts"])
202 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcomment], [CWFLAGS="$CWFLAGS -Wcomment"])
203 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wfloat-equal], [CWFLAGS="$CWFLAGS -Wfloat-equal"])
204 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wformat=2], [CWFLAGS="$CWFLAGS -Wformat=2"])
205 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wimplicit], [CWFLAGS="$CWFLAGS -Wimplicit"])
206 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-declarations], [CWFLAGS="$CWFLAGS -Wmissing-declarations"])
207 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-prototypes], [CWFLAGS="$CWFLAGS -Wmissing-prototypes"])
208 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wnormalized=id], [CWFLAGS="$CWFLAGS -Wnormalized=id"])
209 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Woverride-init], [CWFLAGS="$CWFLAGS -Woverride-init"])
210 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wparentheses], [CWFLAGS="$CWFLAGS -Wparentheses"])
211 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wpointer-arith], [CWFLAGS="$CWFLAGS -Wpointer-arith"])
212 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wredundant-decls], [CWFLAGS="$CWFLAGS -Wredundant-decls"])
213 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wstrict-prototypes], [CWFLAGS="$CWFLAGS -Wstrict-prototypes"])
214 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wswitch-enum], [CWFLAGS="$CWFLAGS -Wswitch-enum"])
215 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wvariable-decl], [CWFLAGS="$CWFLAGS -Wvariable-decl"])
217 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
218 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
219 AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"])
222 AC_SUBST(LIBTOOL_DEPS)
224 AC_ARG_VAR([RONN], [path to the ronn text processor])
225 AC_PATH_PROG([RONN], [ronn], [#])
227 AC_ARG_VAR([AR], [path to the ar utility])
228 AC_CHECK_TOOL([AR], [ar], [ar])
234 AC_ARG_VAR([DTRACE], [path to dtrace if you have it])
235 AC_PATH_PROG([DTRACE], [dtrace], [], [$PATH:/usr/local/sbin:/usr/sbin])
240 AS_IF([test -n "$DTRACE"],[
241 PROBES_SOURCE="probes_dnscrypt_proxy.h"
244 PROBES_SOURCE="probes_no_dtrace.h"
247 AC_SUBST([PROBES_SOURCE])
249 AS_IF([test -d /usr/local/include], [
250 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
252 AS_IF([test -d /usr/local/lib], [
253 LDFLAGS="$LDFLAGS -L/usr/local/lib"
256 AS_IF([test -d /usr/local/opt/libressl/include], [
257 CPPFLAGS="$CPPFLAGS -I/usr/local/opt/libressl/include"
259 AS_IF([test -d /usr/local/opt/openssl/include], [
260 CPPFLAGS="$CPPFLAGS -I/usr/local/opt/openssl/include"
263 AS_IF([test -d /usr/local/opt/libressl/lib], [
264 LDFLAGS="$LDFLAGS -L/usr/local/opt/libressl/lib"
266 AS_IF([test -d /usr/local/opt/openssl/lib], [
267 LDFLAGS="$LDFLAGS -L/usr/local/opt/openssl/lib"
271 dnl Checks for header files.
274 AC_CHECK_HEADERS([sys/cdefs.h sys/feature_tests.h])
275 AC_CHECK_HEADERS([execinfo.h paths.h pwd.h grp.h uuid/uuid.h])
276 AC_CHECK_HEADERS([sandbox.h linux/filter.h linux/random.h])
277 AC_CHECK_HEADERS([ws2tcpip.h])
279 dnl Checks for typedefs, structures, and compiler characteristics.
285 AC_CHECK_TYPE([in_port_t], , [AC_DEFINE(in_port_t, uint16_t,
288 #include <sys/types.h>
292 #ifdef HAVE_WS2TCPIP_H
293 # include <ws2tcpip.h>
295 # include <sys/socket.h>
296 # include <netinet/in.h>
300 AC_MSG_CHECKING([whether sin_len is defined])
301 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
302 #include <sys/types.h>
307 #ifdef HAVE_WS2TCPIP_H
308 # include <ws2tcpip.h>
310 # include <sys/socket.h>
311 # include <netinet/in.h>
315 struct sockaddr_in a;
320 AC_DEFINE(HAVE_SIN_LEN,[1],[define if you have sin_len])
325 AC_MSG_CHECKING([whether __ss_family is defined])
326 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
327 #include <sys/types.h>
332 #ifdef HAVE_WS2TCPIP_H
333 # include <ws2tcpip.h>
335 # include <sys/socket.h>
336 # include <netinet/in.h>
340 struct sockaddr_storage a;
341 (void) a.__ss_family;
345 AC_DEFINE(HAVE___SS_FAMILY,[1],[define if you have __ss_family])
350 AC_MSG_CHECKING([whether ss_len is defined])
351 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
352 #include <sys/types.h>
357 #ifdef HAVE_WS2TCPIP_H
358 # include <ws2tcpip.h>
360 # include <sys/socket.h>
361 # include <netinet/in.h>
365 struct sockaddr_storage a;
370 AC_DEFINE(HAVE_SS_LEN,[1],[define if you have ss_len])
375 AC_MSG_CHECKING([whether __ss_len is defined])
376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
377 #include <sys/types.h>
382 #ifdef HAVE_WS2TCPIP_H
383 # include <ws2tcpip.h>
385 # include <sys/socket.h>
386 # include <netinet/in.h>
390 struct sockaddr_storage a;
395 AC_DEFINE(HAVE___SS_LEN,[1],[define if you have __ss_len])
400 dnl Checks for library functions.
402 AC_SEARCH_LIBS(pow, [m])
403 AC_SEARCH_LIBS(dlopen, [dl])
404 AC_SEARCH_LIBS(clock_gettime, [rt],
405 [AC_DEFINE(HAVE_CLOCK_GETTIME,[1],[define if you have clock_gettime()])])
407 AC_SEARCH_LIBS(backtrace, [execinfo],
408 [AC_DEFINE(HAVE_BACKTRACE,[1],[define if you have backtrace()])])
410 AC_SEARCH_LIBS(gethostbyname, [resolv nsl])
411 AC_SEARCH_LIBS(recvfrom, [socket])
412 AC_SEARCH_LIBS(kvm_open, [kvm])
413 AC_SEARCH_LIBS(sodium_hex2bin, [sodium], [ ], AC_ERROR([libsodium >= 0.7.0 not found]))
416 AC_CHECK_HEADER([ldns/ldns.h], [
417 AC_CHECK_LIB(ldns, ldns_wire2pkt, [
418 AC_DEFINE(USE_LDNS,[1],[define to use the ldns library])
423 [#include <sys/types.h>
426 #ifdef HAVE_WS2TCPIP_H
427 # include <ws2tcpip.h>
430 AM_CONDITIONAL(USE_LDNS, test x$use_ldns = xyes)
431 AC_SUBST([LDNS_LIBS])
434 cygwin* | mingw* | pw32* | cegcc*)
435 AC_CHECK_LIB([ws2_32], [_head_libws2_32_a])
436 AC_CHECK_LIB([psapi], [_head_libpsapi_a])
437 AC_CHECK_LIB([iphlpapi], [_head_libiphlpapi_a])
441 AC_CHECK_FUNCS([getpwnam sandbox_init setrlimit putc_unlocked gmtime_r initgroups])
442 AC_CHECK_FUNCS([crypto_box_easy_afternm crypto_core_hchacha20 crypto_box_curve25519xchacha20poly1305_open_easy_afternm])
447 LT_CONFIG_LTDL_DIR([libltdl])
453 cygwin* | mingw* | pw32* | cegcc*) ;;
454 *) ac_configure_args="$ac_configure_args --disable-thread-support" ;;
457 ac_configure_args="$ac_configure_args --disable-dependency-tracking"
458 ac_configure_args="$ac_configure_args --disable-libevent-install"
459 ac_configure_args="$ac_configure_args --disable-openssl"
460 ac_configure_args="$ac_configure_args --disable-shared"
461 ac_configure_args="$ac_configure_args --enable-function-sections"
462 ac_configure_args="$ac_configure_args CC='$CC'"
463 ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS'"
464 ac_configure_args="$ac_configure_args CPP='$CPP'"
465 ac_configure_args="$ac_configure_args CPPFLAGS='$CPPFLAGS'"
466 ac_configure_args="$ac_configure_args LDFLAGS='$LDFLAGS'"
467 ac_configure_args="$ac_configure_args LIBS='$LIBS'"
471 AH_VERBATIM([NDEBUG], [/* Never ever ignore assertions */
473 #/**/undef/**/ NDEBUG
476 AC_CONFIG_FILES([Makefile
485 src/include/dnscrypt/version.h
487 src/plugins/example/Makefile
488 src/plugins/example-cache/Makefile
489 src/plugins/example-logging/Makefile
490 src/plugins/example-ldns-aaaa-blocking/Makefile
491 src/plugins/example-ldns-blocking/Makefile
492 src/plugins/example-ldns-forwarding/Makefile
493 src/plugins/vendor-specific/example-ldns-opendns-deviceid/Makefile
494 src/plugins/vendor-specific/example-ldns-opendns-set-client-ip/Makefile