TOR: fix compilation
[tomato.git] / release / src / router / dnscrypt / configure.ac
blob9f66398780602d740816caf066be10661dca3550
1 AC_PREREQ([2.65])
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])
8 AC_CANONICAL_HOST
9 AM_INIT_AUTOMAKE([1.11 dist-bzip2 tar-ustar gnu subdir-objects])
10 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
11 AM_MAINTAINER_MODE
12 AM_DEP_TRACK
14 AC_SUBST(VERSION)
15 ISODATE=`date +%Y-%m-%d`
16 AC_SUBST(ISODATE)
18 AC_LANG_ASSERT(C)
19 LX_CFLAGS=${CFLAGS-NONE}
21 dnl Switches.
23 AC_ARG_ENABLE(ssp,
24 [AS_HELP_STRING(--disable-ssp,Do not compile with -fstack-protector)],
26   AS_IF([test "x$enableval" = "xno"], [
27     enable_ssp="no"
28   ], [
29     enable_ssp="yes"
30   ])
33   enable_ssp="yes"
36 AC_ARG_ENABLE(pie,
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"])
42 AC_ARG_WITH(safecode,
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"
50   ])
53 AC_ARG_ENABLE(plugins,
54 [AS_HELP_STRING(--disable-plugins,Disable support for plugins)],
56   AS_IF([test "x$enableval" = "xno"], [
57     plugins="disabled"
58   ], [
59     plugins="enabled"
60   ])
63   plugins="enabled"
65 AS_IF([test "$plugins" = "enabled"], [
66   CPPFLAGS="$CPPFLAGS -DPLUGINS=1"
68 AM_CONDITIONAL(PLUGINS, test x$plugins = xenabled)
70 AC_ARG_ENABLE(debug,
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"], [
75       nxflags=""
76       for flag in `echo $CFLAGS`; do
77         AS_CASE([$flag],
78           [-O*], [ ],
79           [-g*], [ ],
80           [*], [AS_VAR_APPEND([nxflags], [" $flag"])])
81       done
82       CFLAGS="$nxflags -O0 -g3"
83     ])
84     CPPFLAGS="$CPPFLAGS -DDEBUG=1"
85   ])
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
95         ])
97 AM_CONDITIONAL(RELAXED_PLUGINS_PERMISSIONS, test x$relaxed_plugins_permissions = xenabled)
99 plugins_root=disabled
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"
105                 plugins_root=enabled
106         ])
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])
114 have_systemd=no
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])
118   ])
119   AS_CASE([$with_systemd:$have_systemd],
120     [yes:no],
121       [AC_MSG_ERROR([systemd expected but libsystemd not found -- maybe you need to install the pkg-config and libsystemd-dev packages])],
122     [*:yes],
123        AC_DEFINE([HAVE_LIBSYSTEMD], [1], [Define if libsystemd is available])
124   )
126 AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$have_systemd" = "xyes"])
128 AC_SUBST([MAINT])
130 dnl Checks
132 AC_PROG_CC_C99
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"]
147     ])
148   ])
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"])
156 AS_CASE([$host_os],
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"])
161   ])
163 AS_IF([test "x$enable_ssp" != "xno"],[
165 AS_CASE([$host_os],
166   [cygwin* | mingw* | pw32* | cegcc*], [ ],
167   [*], [
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"])]
172     )
173   ])
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([[]], [[
188 #ifndef __clang__
189 be sad
190 #endif
191 ]])],
192   [AC_MSG_RESULT(yes)
193    AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wno-unknown-warning-option],
194   [CWFLAGS="$CWFLAGS -Wno-unknown-warning-option"])],
195   [AC_MSG_RESULT(no)
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"])
221 LT_INIT
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])
230 case $host_os in
231   darwin*)
232     case $build_os in
233       darwin*)
234         AC_ARG_VAR([DTRACE], [path to dtrace if you have it])
235         AC_PATH_PROG([DTRACE], [dtrace], [], [$PATH:/usr/local/sbin:/usr/sbin])
236       ;;
237     esac
238   ;;
239 esac
240 AS_IF([test -n "$DTRACE"],[
241   PROBES_SOURCE="probes_dnscrypt_proxy.h"
243   DTRACE="#"
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"
258 ], [
259   AS_IF([test -d /usr/local/opt/openssl/include], [
260     CPPFLAGS="$CPPFLAGS -I/usr/local/opt/openssl/include"
261   ])
263 AS_IF([test -d /usr/local/opt/libressl/lib], [
264   LDFLAGS="$LDFLAGS -L/usr/local/opt/libressl/lib"
265 ], [
266   AS_IF([test -d /usr/local/opt/openssl/lib], [
267     LDFLAGS="$LDFLAGS -L/usr/local/opt/openssl/lib"
268   ])
271 dnl Checks for header files.
273 AC_SYS_LARGEFILE
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.
281 AC_C_INLINE
282 AC_C_BIGENDIAN
283 AC_C_RESTRICT
285 AC_CHECK_TYPE([in_port_t], , [AC_DEFINE(in_port_t, uint16_t,
286 [in_port_t type])],
288 #include <sys/types.h>
289 #ifdef HAVE_UNISTD_H
290 # include <unistd.h>
291 #endif
292 #ifdef HAVE_WS2TCPIP_H
293 # include <ws2tcpip.h>
294 #else
295 # include <sys/socket.h>
296 # include <netinet/in.h>
297 #endif
300 AC_MSG_CHECKING([whether sin_len is defined])
301 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
302 #include <sys/types.h>
303 #include <stdio.h>
304 #ifdef HAVE_UNISTD_H
305 # include <unistd.h>
306 #endif
307 #ifdef HAVE_WS2TCPIP_H
308 # include <ws2tcpip.h>
309 #else
310 # include <sys/socket.h>
311 # include <netinet/in.h>
312 #endif
313 ]], [[
314 do {
315  struct sockaddr_in a;
316  (void) a.sin_len;
317 } while(0)
318 ]])],[
319   AC_MSG_RESULT(yes)
320   AC_DEFINE(HAVE_SIN_LEN,[1],[define if you have sin_len])
322   AC_MSG_RESULT(no)
325 AC_MSG_CHECKING([whether __ss_family is defined])
326 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
327 #include <sys/types.h>
328 #include <stdio.h>
329 #ifdef HAVE_UNISTD_H
330 # include <unistd.h>
331 #endif
332 #ifdef HAVE_WS2TCPIP_H
333 # include <ws2tcpip.h>
334 #else
335 # include <sys/socket.h>
336 # include <netinet/in.h>
337 #endif
338 ]], [[
339 do {
340  struct sockaddr_storage a;
341  (void) a.__ss_family;
342 } while(0)
343 ]])],[
344   AC_MSG_RESULT(yes)
345   AC_DEFINE(HAVE___SS_FAMILY,[1],[define if you have __ss_family])
347   AC_MSG_RESULT(no)
350 AC_MSG_CHECKING([whether ss_len is defined])
351 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
352 #include <sys/types.h>
353 #include <stdio.h>
354 #ifdef HAVE_UNISTD_H
355 # include <unistd.h>
356 #endif
357 #ifdef HAVE_WS2TCPIP_H
358 # include <ws2tcpip.h>
359 #else
360 # include <sys/socket.h>
361 # include <netinet/in.h>
362 #endif
363 ]], [[
364 do {
365  struct sockaddr_storage a;
366  (void) a.ss_len;
367 } while(0)
368 ]])],[
369   AC_MSG_RESULT(yes)
370   AC_DEFINE(HAVE_SS_LEN,[1],[define if you have ss_len])
372   AC_MSG_RESULT(no)
375 AC_MSG_CHECKING([whether __ss_len is defined])
376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
377 #include <sys/types.h>
378 #include <stdio.h>
379 #ifdef HAVE_UNISTD_H
380 # include <unistd.h>
381 #endif
382 #ifdef HAVE_WS2TCPIP_H
383 # include <ws2tcpip.h>
384 #else
385 # include <sys/socket.h>
386 # include <netinet/in.h>
387 #endif
388 ]], [[
389 do {
390  struct sockaddr_storage a;
391  (void) a.__ss_len;
392 } while(0)
393 ]])],[
394   AC_MSG_RESULT(yes)
395   AC_DEFINE(HAVE___SS_LEN,[1],[define if you have __ss_len])
397   AC_MSG_RESULT(no)
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]))
415 use_ldns=no
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])
419     LDNS_LIBS=-lldns
420     use_ldns=yes
421   ])
422 ], [ ],
423 [#include <sys/types.h>
424  #include <stdlib.h>
425  #include <stdint.h>
426  #ifdef HAVE_WS2TCPIP_H
427  # include <ws2tcpip.h>
428  #endif
430 AM_CONDITIONAL(USE_LDNS, test x$use_ldns = xyes)
431 AC_SUBST([LDNS_LIBS])
433 case $host_os in
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])
438   ;;
439 esac
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])
444 dnl Libtool.
446 LT_INIT([dlopen])
447 LT_CONFIG_LTDL_DIR([libltdl])
448 LTDL_INIT
450 dnl Subconfig.
452 case $host_os in
453   cygwin* | mingw* | pw32* | cegcc*) ;;
454   *) ac_configure_args="$ac_configure_args --disable-thread-support" ;;
455 esac
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'"
469 dnl Output.
471 AH_VERBATIM([NDEBUG], [/* Never ever ignore assertions */
472 #ifdef NDEBUG
473 #/**/undef/**/ NDEBUG
474 #endif])
476 AC_CONFIG_FILES([Makefile
477                  contrib/Makefile
478                  dist-build/Makefile
479                  man/Makefile
480                  src/Makefile
481                  src/hostip/Makefile
482                  src/proxy/Makefile
483                  src/ext/Makefile
484                  src/include/Makefile
485                  src/include/dnscrypt/version.h
486                  src/plugins/Makefile
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
495                  test/Makefile])
497 AC_OUTPUT