dnscrypt-proxy update: 1.4.1
[tomato.git] / release / src / router / dnscrypt / configure.ac
blob02712a8d1b111c7aa8656b4a50fb0bfa3f58795d
1 AC_PREREQ([2.65])
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])
8 AC_CANONICAL_HOST
9 AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar gnu subdir-objects])
10 AM_MAINTAINER_MODE
11 AM_DEP_TRACK
13 AC_SUBST(VERSION)
14 ISODATE=`date +%Y-%m-%d`
15 AC_SUBST(ISODATE)
17 LX_CFLAGS=${CFLAGS-NONE}
19 dnl Switches.
21 AC_ARG_ENABLE(ssp,
22 [AS_HELP_STRING(--disable-ssp,Do not compile with -fstack-protector)],
24   AS_IF([test "x$enableval" = "xno"], [
25     enable_ssp="no"
26   ], [
27     enable_ssp="yes"
28   ])
31   enable_ssp="yes"
34 AC_ARG_ENABLE(pie,
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"])
40 AC_ARG_WITH(safecode,
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"
48   ])
51 AC_ARG_ENABLE(debug,
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"], [
56       nxflags=""
57       for flag in `echo $CFLAGS`; do
58         AS_CASE([$flag],
59           [-O*], [ ],
60           [-g*], [ ],
61           [*], [AS_VAR_APPEND([nxflags], [" $flag"])])
62       done
63       CFLAGS="$nxflags -O0 -g3"
64     ])
65     CPPFLAGS="$CPPFLAGS -DDEBUG=1"
66   ])
69 plugins=disabled
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"
75                 plugins=enabled
76         ])
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
87         ])
89 AM_CONDITIONAL(RELAXED_PLUGINS_PERMISSIONS, test x$relaxed_plugins_permissions = xenabled)
91 plugins_root=disabled
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"
97                 plugins_root=enabled
98         ])
100 AM_CONDITIONAL(ENABLE_PLUGINS_ROOT, test x$plugins_root = xenabled)
102 AC_SUBST([MAINT])
104 dnl Checks
106 AC_PROG_CC_C99
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"]
113   )
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"])
122     ])
123   ])
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"])
130 AS_CASE([$host_os],
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"])
134   ])
136 AS_IF([test "x$enable_ssp" != "xno"],[
138 AS_CASE([$host_os],
139   [cygwin* | mingw* | pw32* | cegcc*], [ ],
140   [dragonfly*], [
141     AX_CHECK_COMPILE_FLAG([-fstack-protector], [
142       AX_CHECK_LINK_FLAG([-fstack-protector],
143         [CFLAGS="$CFLAGS -fstack-protector"]
144       )
145     ])
146   ],
147   [*], [
148     AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [
149       AX_CHECK_LINK_FLAG([-fstack-protector-all],
150         [CFLAGS="$CFLAGS -fstack-protector-all"]
151       )
152     ])
153   ])
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([[]], [[
168 #ifndef __clang__
169 be sad
170 #endif
171 ]])],
172   [AC_MSG_RESULT(yes)
173    AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wno-unknown-warning-option],
174   [CWFLAGS="$CWFLAGS -Wno-unknown-warning-option"])],
175   [AC_MSG_RESULT(no)
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"])
201 LT_INIT
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])
213 case $host_os in
214   darwin*)
215     case $build_os in
216       darwin*)
217         AC_ARG_VAR([DTRACE], [path to dtrace if you have it])
218         AC_PATH_PROG([DTRACE], [dtrace], [], [$PATH:/usr/local/sbin:/usr/sbin])
219       ;;
220     esac
221   ;;
222 esac
223 AS_IF([test -n "$DTRACE"],[
224   PROBES_SOURCE="probes_dnscrypt_proxy.h"
226   DTRACE="#"
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.
242 AC_SYS_LARGEFILE
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.
250 AC_C_INLINE
251 AC_C_BIGENDIAN
252 AC_C_RESTRICT
254 AC_CHECK_TYPE([in_port_t], , [AC_DEFINE(in_port_t, uint16_t,
255 [in_port_t type])],
257 #include <sys/types.h>
258 #ifdef HAVE_UNISTD_H
259 # include <unistd.h>
260 #endif
261 #ifdef HAVE_WS2TCPIP_H
262 # include <ws2tcpip.h>
263 #else
264 # include <sys/socket.h>
265 # include <netinet/in.h>
266 #endif
269 AC_MSG_CHECKING([whether sin_len is defined])
270 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
271 #include <sys/types.h>
272 #include <stdio.h>
273 #ifdef HAVE_UNISTD_H
274 # include <unistd.h>
275 #endif
276 #ifdef HAVE_WS2TCPIP_H
277 # include <ws2tcpip.h>
278 #else
279 # include <sys/socket.h>
280 # include <netinet/in.h>
281 #endif
282 ]], [[
283 do {
284  struct sockaddr_in a;
285  (void) a.sin_len;
286 } while(0)
287 ]])],[
288   AC_MSG_RESULT(yes)
289   AC_DEFINE(HAVE_SIN_LEN,[1],[define if you have sin_len])
291   AC_MSG_RESULT(no)
294 AC_MSG_CHECKING([whether __ss_family is defined])
295 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
296 #include <sys/types.h>
297 #include <stdio.h>
298 #ifdef HAVE_UNISTD_H
299 # include <unistd.h>
300 #endif
301 #ifdef HAVE_WS2TCPIP_H
302 # include <ws2tcpip.h>
303 #else
304 # include <sys/socket.h>
305 # include <netinet/in.h>
306 #endif
307 ]], [[
308 do {
309  struct sockaddr_storage a;
310  (void) a.__ss_family;
311 } while(0)
312 ]])],[
313   AC_MSG_RESULT(yes)
314   AC_DEFINE(HAVE___SS_FAMILY,[1],[define if you have __ss_family])
316   AC_MSG_RESULT(no)
319 AC_MSG_CHECKING([whether ss_len is defined])
320 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
321 #include <sys/types.h>
322 #include <stdio.h>
323 #ifdef HAVE_UNISTD_H
324 # include <unistd.h>
325 #endif
326 #ifdef HAVE_WS2TCPIP_H
327 # include <ws2tcpip.h>
328 #else
329 # include <sys/socket.h>
330 # include <netinet/in.h>
331 #endif
332 ]], [[
333 do {
334  struct sockaddr_storage a;
335  (void) a.ss_len;
336 } while(0)
337 ]])],[
338   AC_MSG_RESULT(yes)
339   AC_DEFINE(HAVE_SS_LEN,[1],[define if you have ss_len])
341   AC_MSG_RESULT(no)
344 AC_MSG_CHECKING([whether __ss_len is defined])
345 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
346 #include <sys/types.h>
347 #include <stdio.h>
348 #ifdef HAVE_UNISTD_H
349 # include <unistd.h>
350 #endif
351 #ifdef HAVE_WS2TCPIP_H
352 # include <ws2tcpip.h>
353 #else
354 # include <sys/socket.h>
355 # include <netinet/in.h>
356 #endif
357 ]], [[
358 do {
359  struct sockaddr_storage a;
360  (void) a.__ss_len;
361 } while(0)
362 ]])],[
363   AC_MSG_RESULT(yes)
364   AC_DEFINE(HAVE___SS_LEN,[1],[define if you have __ss_len])
366   AC_MSG_RESULT(no)
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]))
384 use_ldns=no
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])
388     LDNS_LIBS=-lldns
389     use_ldns=yes
390   ])
391 ], [ ],
392 [#include <sys/types.h>
393  #include <stdlib.h>
394  #include <stdint.h>
395  #ifdef HAVE_WS2TCPIP_H
396  # include <ws2tcpip.h>
397  #endif
399 AM_CONDITIONAL(USE_LDNS, test x$use_ldns = xyes)
400 AC_SUBST([LDNS_LIBS])
402 case $host_os in
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])
407   ;;
408 esac
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])
416 dnl Libtool.
418 LT_INIT([dlopen])
419 LT_CONFIG_LTDL_DIR([libltdl])
420 LTDL_INIT
422 dnl Subconfig.
424 case $host_os in
425   cygwin* | mingw* | pw32* | cegcc*) ;;
426   *) ac_configure_args="$ac_configure_args --disable-thread-support" ;;
427 esac
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'"
441 dnl Output.
443 AH_VERBATIM([NDEBUG], [/* Never ever ignore assertions */
444 #ifdef NDEBUG
445 #/**/undef/**/ NDEBUG
446 #endif])
448 AC_CONFIG_FILES([Makefile
449                  dist-build/Makefile
450                  man/Makefile
451                  src/Makefile
452                  src/hostip/Makefile
453                  src/proxy/Makefile
454                  src/ext/Makefile
455                  src/include/Makefile
456                  src/include/dnscrypt/version.h
457                  src/plugins/Makefile
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
464                  test/Makefile])
466 AC_OUTPUT