2 AC_INIT([dnscrypt-proxy],[1.4.1],[http://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.9 dist-bzip2 tar-ustar gnu subdir-objects])
14 ISODATE=`date +%Y-%m-%d`
17 LX_CFLAGS=${CFLAGS-NONE}
22 [AS_HELP_STRING(--disable-ssp,Do not compile with -fstack-protector)],
24 AS_IF([test "x$enableval" = "xno"], [
35 [AS_HELP_STRING(--disable-pie,Do not produce position independent executables)],
36 enable_pie=$enableval, enable_pie="maybe")
38 AS_CASE([$host_os], [mingw*], [enable_pie="no"])
41 [AS_HELP_STRING(--with-safecode,For maintainers only - please do not use)],
42 [AS_IF([test "x$withval" = "xyes"], [
43 AC_ARG_VAR([SAFECODE_HOME], [set to the safecode base directory])
44 : ${SAFECODE_HOME:=/opt/safecode}
45 LDFLAGS="$LDFLAGS -L${SAFECODE_HOME}/lib"
46 LIBS="$LIBS -lsc_dbg_rt -lpoolalloc_bitmap -lstdc++"
47 CFLAGS="$CFLAGS -fmemsafety"
52 [AS_HELP_STRING(--enable-debug,For maintainers only - please do not use)],
54 AS_IF([test "x$enableval" = "xyes"], [
55 AS_IF([test "x$LX_CFLAGS" = "xNONE"], [
57 for flag in `echo $CFLAGS`; do
61 [*], [AS_VAR_APPEND([nxflags], [" $flag"])])
63 CFLAGS="$nxflags -O0 -g3"
65 CPPFLAGS="$CPPFLAGS -DDEBUG=1"
70 AC_ARG_ENABLE(plugins,
71 [AS_HELP_STRING(--enable-plugins,Enable support for plugins)],
73 AS_IF([test "x$enableval" != "xno"], [
74 CPPFLAGS="$CPPFLAGS -DPLUGINS=1"
78 AM_CONDITIONAL(PLUGINS, test x$plugins = xenabled)
80 relaxed_plugins_permissions=disabled
81 AC_ARG_ENABLE(relaxed-plugins-permissions,
82 [AS_HELP_STRING(--enable-relaxed-plugins-permissions,Allow loading plugins owned by other users)],
84 AS_IF([test "x$enableval" != "xno"], [
85 CPPFLAGS="$CPPFLAGS -DRELAXED_PLUGINS_PERMISSIONS=1"
86 relaxed_plugins_permissions=enabled
89 AM_CONDITIONAL(RELAXED_PLUGINS_PERMISSIONS, test x$relaxed_plugins_permissions = xenabled)
92 AC_ARG_ENABLE(plugins-root,
93 [AS_HELP_STRING(--enable-plugins-root,Only load plugins sitting in the default plugins directory)],
95 AS_IF([test "x$enableval" != "xno"], [
96 CPPFLAGS="$CPPFLAGS -DENABLE_PLUGINS_ROOT=1"
100 AM_CONDITIONAL(ENABLE_PLUGINS_ROOT, test x$plugins_root = xenabled)
107 AC_USE_SYSTEM_EXTENSIONS
108 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
110 AX_CHECK_COMPILE_FLAG([-fPIC], [
111 AX_CHECK_LINK_FLAG([-fPIC],
112 [CFLAGS="$CFLAGS -fPIC"]
116 AS_IF([test "$enable_pie" != "no"],[
117 AX_CHECK_COMPILE_FLAG([-fPIE], [
118 AX_CHECK_LINK_FLAG([-fPIE],
119 [AX_CHECK_LINK_FLAG([-pie],
120 [CFLAGS="$CFLAGS -fPIE"
121 LDFLAGS="$LDFLAGS -pie"])
126 AX_CHECK_COMPILE_FLAG([-fwrapv], [CFLAGS="$CFLAGS -fwrapv"])
127 AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
128 AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CFLAGS="$CFLAGS -fno-strict-overflow"])
131 [cygwin* | mingw* | pw32* | cegcc*], [
132 AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
133 AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
136 AS_IF([test "x$enable_ssp" != "xno"],[
139 [cygwin* | mingw* | pw32* | cegcc*], [ ],
141 AX_CHECK_COMPILE_FLAG([-fstack-protector], [
142 AX_CHECK_LINK_FLAG([-fstack-protector],
143 [CFLAGS="$CFLAGS -fstack-protector"]
148 AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [
149 AX_CHECK_LINK_FLAG([-fstack-protector-all],
150 [CFLAGS="$CFLAGS -fstack-protector-all"]
156 AX_CHECK_COMPILE_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"])
157 AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"])
158 AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
159 AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CFLAGS="$CFLAGS -Wsometimes-uninitialized"])
161 AC_ARG_VAR([CWFLAGS], [define to compilation flags for generating extra warnings])
163 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wall], [CWFLAGS="$CWFLAGS -Wall"])
164 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wextra], [CWFLAGS="$CWFLAGS -Wextra"])
166 AC_MSG_CHECKING(for clang)
167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
173 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wno-unknown-warning-option],
174 [CWFLAGS="$CWFLAGS -Wno-unknown-warning-option"])],
178 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wbad-function-cast], [CWFLAGS="$CWFLAGS -Wbad-function-cast"])
179 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-align], [CWFLAGS="$CWFLAGS -Wcast-align"])
180 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-qual], [CWFLAGS="$CWFLAGS -Wcast-qual"])
181 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wchar-subscripts], [CWFLAGS="$CWFLAGS -Wchar-subscripts"])
182 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcomment], [CWFLAGS="$CWFLAGS -Wcomment"])
183 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wfloat-equal], [CWFLAGS="$CWFLAGS -Wfloat-equal"])
184 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wformat=2], [CWFLAGS="$CWFLAGS -Wformat=2"])
185 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wimplicit], [CWFLAGS="$CWFLAGS -Wimplicit"])
186 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-declarations], [CWFLAGS="$CWFLAGS -Wmissing-declarations"])
187 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-prototypes], [CWFLAGS="$CWFLAGS -Wmissing-prototypes"])
188 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wnormalized=id], [CWFLAGS="$CWFLAGS -Wnormalized=id"])
189 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Woverride-init], [CWFLAGS="$CWFLAGS -Woverride-init"])
190 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wparentheses], [CWFLAGS="$CWFLAGS -Wparentheses"])
191 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wpointer-arith], [CWFLAGS="$CWFLAGS -Wpointer-arith"])
192 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wredundant-decls], [CWFLAGS="$CWFLAGS -Wredundant-decls"])
193 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wstrict-prototypes], [CWFLAGS="$CWFLAGS -Wstrict-prototypes"])
194 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wswitch-enum], [CWFLAGS="$CWFLAGS -Wswitch-enum"])
195 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wvariable-decl], [CWFLAGS="$CWFLAGS -Wvariable-decl"])
197 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
198 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
199 AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"])
202 AC_SUBST(LIBTOOL_DEPS)
204 AC_ARG_VAR([RONN], [path to the ronn text processor])
205 AC_PATH_PROG([RONN], [ronn], [#])
207 AC_ARG_VAR([SIXJACK], [path to 6jack])
208 AC_PATH_PROG([SIXJACK], [sixjack], [#])
210 AC_ARG_VAR([AR], [path to the ar utility])
211 AC_CHECK_TOOL([AR], [ar], [ar])
217 AC_ARG_VAR([DTRACE], [path to dtrace if you have it])
218 AC_PATH_PROG([DTRACE], [dtrace], [], [$PATH:/usr/local/sbin:/usr/sbin])
223 AS_IF([test -n "$DTRACE"],[
224 PROBES_SOURCE="probes_dnscrypt_proxy.h"
227 PROBES_SOURCE="probes_no_dtrace.h"
230 AC_SUBST([PROBES_SOURCE])
232 AS_IF([test -d /usr/local/include], [
233 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
236 AS_IF([test -d /usr/local/lib], [
237 LDFLAGS="$LDFLAGS -L/usr/local/lib"
240 dnl Checks for header files.
243 AC_CHECK_HEADERS([sys/cdefs.h sys/feature_tests.h])
244 AC_CHECK_HEADERS([execinfo.h paths.h pwd.h uuid/uuid.h])
245 AC_CHECK_HEADERS([sandbox.h])
246 AC_CHECK_HEADERS([ws2tcpip.h])
248 dnl Checks for typedefs, structures, and compiler characteristics.
254 AC_CHECK_TYPE([in_port_t], , [AC_DEFINE(in_port_t, uint16_t,
257 #include <sys/types.h>
261 #ifdef HAVE_WS2TCPIP_H
262 # include <ws2tcpip.h>
264 # include <sys/socket.h>
265 # include <netinet/in.h>
269 AC_MSG_CHECKING([whether sin_len is defined])
270 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
271 #include <sys/types.h>
276 #ifdef HAVE_WS2TCPIP_H
277 # include <ws2tcpip.h>
279 # include <sys/socket.h>
280 # include <netinet/in.h>
284 struct sockaddr_in a;
289 AC_DEFINE(HAVE_SIN_LEN,[1],[define if you have sin_len])
294 AC_MSG_CHECKING([whether __ss_family is defined])
295 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
296 #include <sys/types.h>
301 #ifdef HAVE_WS2TCPIP_H
302 # include <ws2tcpip.h>
304 # include <sys/socket.h>
305 # include <netinet/in.h>
309 struct sockaddr_storage a;
310 (void) a.__ss_family;
314 AC_DEFINE(HAVE___SS_FAMILY,[1],[define if you have __ss_family])
319 AC_MSG_CHECKING([whether ss_len is defined])
320 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
321 #include <sys/types.h>
326 #ifdef HAVE_WS2TCPIP_H
327 # include <ws2tcpip.h>
329 # include <sys/socket.h>
330 # include <netinet/in.h>
334 struct sockaddr_storage a;
339 AC_DEFINE(HAVE_SS_LEN,[1],[define if you have ss_len])
344 AC_MSG_CHECKING([whether __ss_len is defined])
345 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
346 #include <sys/types.h>
351 #ifdef HAVE_WS2TCPIP_H
352 # include <ws2tcpip.h>
354 # include <sys/socket.h>
355 # include <netinet/in.h>
359 struct sockaddr_storage a;
364 AC_DEFINE(HAVE___SS_LEN,[1],[define if you have __ss_len])
369 dnl Checks for library functions.
371 AC_SEARCH_LIBS(pow, [m])
372 AC_SEARCH_LIBS(dlopen, [dl])
373 AC_SEARCH_LIBS(clock_gettime, [rt],
374 [AC_DEFINE(HAVE_CLOCK_GETTIME,[1],[define if you have clock_gettime()])])
376 AC_SEARCH_LIBS(backtrace, [execinfo],
377 [AC_DEFINE(HAVE_BACKTRACE,[1],[define if you have backtrace()])])
379 AC_SEARCH_LIBS(gethostbyname, [resolv nsl])
380 AC_SEARCH_LIBS(recvfrom, [socket])
381 AC_SEARCH_LIBS(kvm_open, [kvm])
382 AC_SEARCH_LIBS(sodium_init, [sodium], [ ], AC_ERROR([libsodium not found]))
385 AC_CHECK_HEADER([ldns/ldns.h], [
386 AC_CHECK_LIB(ldns, ldns_wire2pkt, [
387 AC_DEFINE(USE_LDNS,[1],[define to use the ldns library])
392 [#include <sys/types.h>
395 #ifdef HAVE_WS2TCPIP_H
396 # include <ws2tcpip.h>
399 AM_CONDITIONAL(USE_LDNS, test x$use_ldns = xyes)
400 AC_SUBST([LDNS_LIBS])
403 cygwin* | mingw* | pw32* | cegcc*)
404 AC_CHECK_LIB([ws2_32], [_head_libws2_32_a])
405 AC_CHECK_LIB([psapi], [_head_libpsapi_a])
406 AC_CHECK_LIB([iphlpapi], [_head_libiphlpapi_a])
410 AC_CHECK_HEADER([CoreServices/CoreServices.h],
411 [LIBS="$LIBS -framework CoreFoundation -framework CoreServices"])
413 AC_CHECK_FUNCS([getpwnam sandbox_init setrlimit putc_unlocked gmtime_r])
414 AC_CHECK_FUNCS([sodium_mlock])
419 LT_CONFIG_LTDL_DIR([libltdl])
425 cygwin* | mingw* | pw32* | cegcc*) ;;
426 *) ac_configure_args="$ac_configure_args --disable-thread-support" ;;
429 ac_configure_args="$ac_configure_args --disable-dependency-tracking"
430 ac_configure_args="$ac_configure_args --disable-libevent-install"
431 ac_configure_args="$ac_configure_args --disable-openssl"
432 ac_configure_args="$ac_configure_args --disable-shared"
433 ac_configure_args="$ac_configure_args --enable-function-sections"
434 ac_configure_args="$ac_configure_args CC='$CC'"
435 ac_configure_args="$ac_configure_args CFLAGS='$CFLAGS'"
436 ac_configure_args="$ac_configure_args CPP='$CPP'"
437 ac_configure_args="$ac_configure_args CPPFLAGS='$CPPFLAGS'"
438 ac_configure_args="$ac_configure_args LDFLAGS='$LDFLAGS'"
439 ac_configure_args="$ac_configure_args LIBS='$LIBS'"
443 AH_VERBATIM([NDEBUG], [/* Never ever ignore assertions */
445 #/**/undef/**/ NDEBUG
448 AC_CONFIG_FILES([Makefile
456 src/include/dnscrypt/version.h
458 src/plugins/example/Makefile
459 src/plugins/example-logging/Makefile
460 src/plugins/example-ldns-aaaa-blocking/Makefile
461 src/plugins/example-ldns-blocking/Makefile
462 src/plugins/example-ldns-opendns-deviceid/Makefile
463 src/plugins/example-ldns-opendns-set-client-ip/Makefile