2 AC_INIT([dnscrypt-proxy],[1.3.0],[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 src/libsodium])
9 AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar])
14 ISODATE=`date +%Y-%m-%d`
17 LX_CFLAGS=${CFLAGS-NONE}
19 AC_USE_SYSTEM_EXTENSIONS
20 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
22 AX_CHECK_COMPILE_FLAG([-fPIC], [
23 AX_CHECK_LINK_FLAG([-fPIC],
24 [CFLAGS="$CFLAGS -fPIC"]
28 AS_IF([test "$enable_pie" != "no"],[
29 AX_CHECK_COMPILE_FLAG([-fPIE], [
30 AX_CHECK_LINK_FLAG([-fPIE],
31 [AX_CHECK_LINK_FLAG([-pie],
32 [CFLAGS="$CFLAGS -fPIE"
33 LDFLAGS="$LDFLAGS -pie"])
38 AX_CHECK_COMPILE_FLAG([-fwrapv], [CFLAGS="$CFLAGS -fwrapv"])
39 AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
40 AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CFLAGS="$CFLAGS -fno-strict-overflow"])
43 cygwin* | mingw* | pw32* | cegcc*)
44 AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
45 AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
48 AX_CHECK_COMPILE_FLAG([-fstack-protector], [
49 AX_CHECK_LINK_FLAG([-fstack-protector],
50 [CFLAGS="$CFLAGS -fstack-protector"]
55 AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [
56 AX_CHECK_LINK_FLAG([-fstack-protector-all],
57 [CFLAGS="$CFLAGS -fstack-protector-all"]
63 AX_CHECK_COMPILE_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"])
64 AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"])
65 AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
66 AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CFLAGS="$CFLAGS -Wsometimes-uninitialized"])
68 AC_ARG_VAR([CWFLAGS], [define to compilation flags for generating extra warnings])
70 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wall], [CWFLAGS="$CWFLAGS -Wall"])
71 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wextra], [CWFLAGS="$CWFLAGS -Wextra"])
73 AC_MSG_CHECKING(for clang)
74 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
80 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wno-unknown-warning-option],
81 [CWFLAGS="$CWFLAGS -Wno-unknown-warning-option"])],
85 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wbad-function-cast], [CWFLAGS="$CWFLAGS -Wbad-function-cast"])
86 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-align], [CWFLAGS="$CWFLAGS -Wcast-align"])
87 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-qual], [CWFLAGS="$CWFLAGS -Wcast-qual"])
88 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wchar-subscripts], [CWFLAGS="$CWFLAGS -Wchar-subscripts"])
89 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcomment], [CWFLAGS="$CWFLAGS -Wcomment"])
90 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wfloat-equal], [CWFLAGS="$CWFLAGS -Wfloat-equal"])
91 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wformat=2], [CWFLAGS="$CWFLAGS -Wformat=2"])
92 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wimplicit], [CWFLAGS="$CWFLAGS -Wimplicit"])
93 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-declarations], [CWFLAGS="$CWFLAGS -Wmissing-declarations"])
94 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-prototypes], [CWFLAGS="$CWFLAGS -Wmissing-prototypes"])
95 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wnormalized=id], [CWFLAGS="$CWFLAGS -Wnormalized=id"])
96 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Woverride-init], [CWFLAGS="$CWFLAGS -Woverride-init"])
97 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wparentheses], [CWFLAGS="$CWFLAGS -Wparentheses"])
98 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wpointer-arith], [CWFLAGS="$CWFLAGS -Wpointer-arith"])
99 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wredundant-decls], [CWFLAGS="$CWFLAGS -Wredundant-decls"])
100 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wstrict-prototypes], [CWFLAGS="$CWFLAGS -Wstrict-prototypes"])
101 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wswitch-enum], [CWFLAGS="$CWFLAGS -Wswitch-enum"])
102 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wvariable-decl], [CWFLAGS="$CWFLAGS -Wvariable-decl"])
104 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
105 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
106 AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"])
109 AC_SUBST(LIBTOOL_DEPS)
111 AC_ARG_VAR([RONN], [path to the ronn text processor])
112 AC_PATH_PROG([RONN], [ronn], [#])
114 AC_ARG_VAR([SIXJACK], [path to 6jack])
115 AC_PATH_PROG([SIXJACK], [sixjack], [#])
117 AC_ARG_VAR([AR], [path to the ar utility])
118 AC_CHECK_TOOL([AR], [ar], [ar])
124 AC_ARG_VAR([DTRACE], [path to dtrace if you have it])
125 AC_PATH_PROG([DTRACE], [dtrace])
130 AS_IF([test -n "$DTRACE"],[
131 PROBES_SOURCE="probes_dnscrypt_proxy.h"
134 PROBES_SOURCE="probes_no_dtrace.h"
137 AS_IF([test -d /usr/local/include], [
138 CPPFLAGS="$CPPFLAGS -I/usr/local/include"
141 AS_IF([test -d /usr/local/lib], [
142 LDFLAGS="$LDFLAGS -L/usr/local/lib"
145 dnl Checks for header files.
148 AC_CHECK_HEADERS([sys/cdefs.h sys/feature_tests.h])
149 AC_CHECK_HEADERS([execinfo.h paths.h pwd.h uuid/uuid.h])
150 AC_CHECK_HEADERS([sandbox.h])
152 dnl Checks for typedefs, structures, and compiler characteristics.
157 AC_CHECK_TYPE([in_port_t], , [AC_DEFINE(in_port_t, uint16_t,
163 #include <sys/types.h>
164 #include <sys/socket.h>
165 #include <netinet/in.h>
168 AC_MSG_CHECKING([whether sin_len is defined])
169 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
174 #include <sys/types.h>
175 #include <sys/socket.h>
176 #include <netinet/in.h>
179 struct sockaddr_in a;
184 AC_DEFINE(HAVE_SIN_LEN,[1],[define if you have sin_len])
189 AC_MSG_CHECKING([whether __ss_family is defined])
190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
195 #include <sys/types.h>
196 #include <sys/socket.h>
199 struct sockaddr_storage a;
200 (void) a.__ss_family;
204 AC_DEFINE(HAVE___SS_FAMILY,[1],[define if you have __ss_family])
209 AC_MSG_CHECKING([whether ss_len is defined])
210 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
215 #include <sys/types.h>
216 #include <sys/socket.h>
219 struct sockaddr_storage a;
224 AC_DEFINE(HAVE_SS_LEN,[1],[define if you have ss_len])
229 AC_MSG_CHECKING([whether __ss_len is defined])
230 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
235 #include <sys/types.h>
236 #include <sys/socket.h>
239 struct sockaddr_storage a;
244 AC_DEFINE(HAVE___SS_LEN,[1],[define if you have __ss_len])
249 dnl Checks for library functions.
251 AC_SEARCH_LIBS(pow, [m])
252 AC_SEARCH_LIBS(dlopen, [dl])
253 AC_SEARCH_LIBS(clock_gettime, [rt],
254 [AC_DEFINE(HAVE_CLOCK_GETTIME,[1],[define if you have clock_gettime()])])
256 AC_SEARCH_LIBS(backtrace, [execinfo],
257 [AC_DEFINE(HAVE_BACKTRACE,[1],[define if you have backtrace()])])
259 AC_SEARCH_LIBS(gethostbyname, [resolv nsl])
260 AC_SEARCH_LIBS(recvfrom, [socket])
261 AC_SEARCH_LIBS(kvm_open, [kvm])
262 AC_SEARCH_LIBS(sodium_init, [sodium])
264 AM_CONDITIONAL(USE_BUILTIN_LIBSODIUM, test x$ac_cv_search_sodium_init = xno)
267 AC_CHECK_HEADER([ldns/ldns.h], [
268 AC_CHECK_LIB(ldns, ldns_wire2pkt, [
269 AC_DEFINE(USE_LDNS,[1],[define to use the ldns library])
275 #include <stdint.h>])
276 AM_CONDITIONAL(USE_LDNS, test x$use_ldns = xyes)
277 AC_SUBST([LDNS_LIBS])
280 cygwin* | mingw* | pw32* | cegcc*)
281 AC_CHECK_LIB([ws2_32], [_head_libws2_32_a])
282 AC_CHECK_LIB([psapi], [_head_libpsapi_a])
283 AC_CHECK_LIB([iphlpapi], [_head_libiphlpapi_a])
287 AC_CHECK_HEADER([CoreServices/CoreServices.h],
288 [LIBS="$LIBS -framework CoreFoundation -framework CoreServices"])
290 AC_CHECK_FUNCS([getpwnam sandbox_init setrlimit putc_unlocked])
295 [AS_HELP_STRING(--enable-pie,Produce position independent executables @<:@default=yes@:>@)],
296 enable_pie=$enableval, enable_pie="maybe")
299 [AS_HELP_STRING(--disable-ssp,Don't compile with -fstack-protector)],
300 [AS_IF([test "x$enableval" = "xno"], [
302 for flag in `echo $CFLAGS`; do
304 -fstack-protector*) ;;
305 *) AS_VAR_APPEND([nxflags], [" $flag"]) ;;
313 AC_ARG_ENABLE(plugins,
314 [AS_HELP_STRING(--enable-plugins,Enable support for plugins - experimental)],
315 [CPPFLAGS="$CPPFLAGS -DPLUGINS=1"
317 AM_CONDITIONAL(PLUGINS, test x$plugins = xenabled)
319 relaxed_plugins_permissions=disabled
320 AC_ARG_ENABLE(relaxed-plugins-permissions,
321 [AS_HELP_STRING(--enable-relaxed-plugins-permissions,Allow loading plugins owned by other users)],
322 [CPPFLAGS="$CPPFLAGS -DRELAXED_PLUGINS_PERMISSIONS=1"
323 relaxed_plugins_permissions=enabled])
324 AM_CONDITIONAL(RELAXED_PLUGINS_PERMISSIONS, test x$relaxed_plugins_permissions = xenabled)
326 plugins_root=disabled
327 AC_ARG_ENABLE(plugins-root,
328 [AS_HELP_STRING(--enable-plugins-root,Only load plugins sitting in the default plugins directory)],
329 [CPPFLAGS="$CPPFLAGS -DENABLE_PLUGINS_ROOT=1"
330 plugins_root=enabled])
331 AM_CONDITIONAL(ENABLE_PLUGINS_ROOT, test x$plugins_root = xenabled)
333 AC_ARG_ENABLE(blocking-random,
334 [AS_HELP_STRING(--enable-blocking-random,Use /dev/random instead of /dev/urandom)],
335 [AC_DEFINE([USE_BLOCKING_RANDOM], [1], [Use blocking random])])
338 [AS_HELP_STRING(--enable-debug,For maintainers only - please do not use)],
340 AS_IF([test "x$LX_CFLAGS" = "xNONE"], [
342 for flag in `echo $CFLAGS`; do
346 *) AS_VAR_APPEND([nxflags], [" $flag"]) ;;
349 CFLAGS="$nxflags -O0 -g3"
351 CPPFLAGS="$CPPFLAGS -DDEBUG=1"
354 AC_ARG_WITH(safecode,
355 [AS_HELP_STRING(--with-safecode,For maintainers only - please do not use)],
356 [AS_IF([test "x$withval" = "xyes"], [
357 AC_ARG_VAR([SAFECODE_HOME], [set to the safecode base directory])
358 : ${SAFECODE_HOME:=/opt/safecode}
359 LDFLAGS="$LDFLAGS -L${SAFECODE_HOME}/lib"
360 LIBS="$LIBS -lsc_dbg_rt -lpoolalloc_bitmap -lstdc++"
361 CFLAGS="$CFLAGS -fmemsafety"
366 AC_SUBST([PROBES_SOURCE])
371 LT_CONFIG_LTDL_DIR([libltdl])
377 cygwin* | mingw* | pw32* | cegcc*) ;;
378 *) ac_configure_args="$ac_configure_args --disable-thread-support" ;;
381 ac_configure_args="$ac_configure_args --disable-dependency-tracking"
382 ac_configure_args="$ac_configure_args --disable-libevent-install"
383 ac_configure_args="$ac_configure_args --disable-openssl"
384 ac_configure_args="$ac_configure_args --disable-shared"
385 ac_configure_args="$ac_configure_args --enable-function-sections"
395 AH_VERBATIM([NDEBUG], [/* Never ever ignore assertions */
397 #/**/undef/**/ NDEBUG
400 AC_CONFIG_FILES([Makefile
408 src/include/dnscrypt/version.h
410 src/plugins/example/Makefile
411 src/plugins/example-ldns-forward-after-nxdomain/Makefile
412 src/plugins/example-logging/Makefile
413 src/plugins/example-ldns-aaaa-blocking/Makefile
414 src/plugins/example-ldns-blocking/Makefile
415 src/plugins/example-ldns-opendns-deviceid/Makefile
416 src/plugins/example-ldns-opendns-set-client-ip/Makefile