NGINX: Upstream update to version 1.4.4
[tomato.git] / release / src / router / dnscrypt / configure.ac
blobfc39a5d051b0b6e717fb2e4fc7909a43d1130c1e
1 AC_PREREQ([2.61])
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])
8 AC_CANONICAL_HOST
9 AM_INIT_AUTOMAKE([1.9 dist-bzip2 tar-ustar])
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}
18 AC_PROG_CC_C99
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"]
25   )
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"])
34     ])
35   ])
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"])
42 case $host_os in
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"])
46   ;;
47   dragonfly*)
48     AX_CHECK_COMPILE_FLAG([-fstack-protector], [
49       AX_CHECK_LINK_FLAG([-fstack-protector],
50         [CFLAGS="$CFLAGS -fstack-protector"]
51       )
52     ])
53   ;;
54   *)
55     AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [
56       AX_CHECK_LINK_FLAG([-fstack-protector-all],
57         [CFLAGS="$CFLAGS -fstack-protector-all"]
58       )
59     ])
60   ;;
61 esac
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([[]], [[
75 #ifndef __clang__
76 be sad
77 #endif
78 ]])],
79   [AC_MSG_RESULT(yes)
80    AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wno-unknown-warning-option],
81   [CWFLAGS="$CWFLAGS -Wno-unknown-warning-option"])],
82   [AC_MSG_RESULT(no)
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"])
108 LT_INIT
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])
120 case $host_os in
121   darwin*)
122     case $build_os in
123       darwin*)
124         AC_ARG_VAR([DTRACE], [path to dtrace if you have it])
125         AC_PATH_PROG([DTRACE], [dtrace])
126       ;;
127     esac
128   ;;
129 esac
130 AS_IF([test -n "$DTRACE"],[
131   PROBES_SOURCE="probes_dnscrypt_proxy.h"
133   DTRACE="#"
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.
147 AC_SYS_LARGEFILE
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.
154 AC_C_BIGENDIAN
155 AC_C_RESTRICT
157 AC_CHECK_TYPE([in_port_t], , [AC_DEFINE(in_port_t, uint16_t,
158 [in_port_t type])],
160 #ifdef HAVE_UNISTD_H
161 # include <unistd.h>
162 #endif
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([[
170 #include <stdio.h>
171 #ifdef HAVE_UNISTD_H
172 # include <unistd.h>
173 #endif
174 #include <sys/types.h>
175 #include <sys/socket.h>
176 #include <netinet/in.h>
177 ]], [[
178 do {
179  struct sockaddr_in a;
180  (void) a.sin_len;
181 } while(0)
182 ]])],[
183   AC_MSG_RESULT(yes)
184   AC_DEFINE(HAVE_SIN_LEN,[1],[define if you have sin_len])
186   AC_MSG_RESULT(no)
189 AC_MSG_CHECKING([whether __ss_family is defined])
190 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
191 #include <stdio.h>
192 #ifdef HAVE_UNISTD_H
193 # include <unistd.h>
194 #endif
195 #include <sys/types.h>
196 #include <sys/socket.h>
197 ]], [[
198 do {
199  struct sockaddr_storage a;
200  (void) a.__ss_family;
201 } while(0)
202 ]])],[
203   AC_MSG_RESULT(yes)
204   AC_DEFINE(HAVE___SS_FAMILY,[1],[define if you have __ss_family])
206   AC_MSG_RESULT(no)
209 AC_MSG_CHECKING([whether ss_len is defined])
210 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
211 #include <stdio.h>
212 #ifdef HAVE_UNISTD_H
213 # include <unistd.h>
214 #endif
215 #include <sys/types.h>
216 #include <sys/socket.h>
217 ]], [[
218 do {
219  struct sockaddr_storage a;
220  (void) a.ss_len;
221 } while(0)
222 ]])],[
223   AC_MSG_RESULT(yes)
224   AC_DEFINE(HAVE_SS_LEN,[1],[define if you have ss_len])
226   AC_MSG_RESULT(no)
229 AC_MSG_CHECKING([whether __ss_len is defined])
230 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
231 #include <stdio.h>
232 #ifdef HAVE_UNISTD_H
233 # include <unistd.h>
234 #endif
235 #include <sys/types.h>
236 #include <sys/socket.h>
237 ]], [[
238 do {
239  struct sockaddr_storage a;
240  (void) a.__ss_len;
241 } while(0)
242 ]])],[
243   AC_MSG_RESULT(yes)
244   AC_DEFINE(HAVE___SS_LEN,[1],[define if you have __ss_len])
246   AC_MSG_RESULT(no)
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)
266 use_ldns=no
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])
270     LDNS_LIBS=-lldns
271     use_ldns=yes
272   ])
273 ], [ ],
274 [#include <stdlib.h>
275  #include <stdint.h>])
276 AM_CONDITIONAL(USE_LDNS, test x$use_ldns = xyes)
277 AC_SUBST([LDNS_LIBS])
279 case $host_os in
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])
284   ;;
285 esac
287 AC_CHECK_HEADER([CoreServices/CoreServices.h],
288   [LIBS="$LIBS -framework CoreFoundation -framework CoreServices"])
290 AC_CHECK_FUNCS([getpwnam sandbox_init setrlimit putc_unlocked])
292 dnl Switches.
294 AC_ARG_ENABLE(pie,
295 [AS_HELP_STRING(--enable-pie,Produce position independent executables @<:@default=yes@:>@)],
296  enable_pie=$enableval, enable_pie="maybe")
298 AC_ARG_ENABLE(ssp,
299 [AS_HELP_STRING(--disable-ssp,Don't compile with -fstack-protector)],
300 [AS_IF([test "x$enableval" = "xno"], [
301     nxflags=""
302     for flag in `echo $CFLAGS`; do
303       case "$flag" in
304        -fstack-protector*) ;;
305         *) AS_VAR_APPEND([nxflags], [" $flag"]) ;;
306       esac
307     done
308     CFLAGS="$nxflags"
309   ])
312 plugins=disabled
313 AC_ARG_ENABLE(plugins,
314 [AS_HELP_STRING(--enable-plugins,Enable support for plugins - experimental)],
315 [CPPFLAGS="$CPPFLAGS -DPLUGINS=1"
316  plugins=enabled])
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])])
337 AC_ARG_ENABLE(debug,
338 [AS_HELP_STRING(--enable-debug,For maintainers only - please do not use)],
340   AS_IF([test "x$LX_CFLAGS" = "xNONE"], [
341     nxflags=""
342     for flag in `echo $CFLAGS`; do
343       case "$flag" in
344         -O*) ;;
345         -g*) ;;
346         *) AS_VAR_APPEND([nxflags], [" $flag"]) ;;
347       esac
348     done
349     CFLAGS="$nxflags -O0 -g3"
350   ])
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"
362   ])
365 AC_SUBST([MAINT])
366 AC_SUBST([PROBES_SOURCE])
368 dnl Libtool.
370 LT_INIT([dlopen])
371 LT_CONFIG_LTDL_DIR([libltdl])
372 LTDL_INIT
374 dnl Subconfig.
376 case $host_os in
377   cygwin* | mingw* | pw32* | cegcc*) ;;
378   *) ac_configure_args="$ac_configure_args --disable-thread-support" ;;
379 esac
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"
386 export CC
387 export CFLAGS
388 export CPP
389 export CPPFLAGS
390 export LDFLAGS
391 export LIBS
393 dnl Output.
395 AH_VERBATIM([NDEBUG], [/* Never ever ignore assertions */
396 #ifdef NDEBUG
397 #/**/undef/**/ NDEBUG
398 #endif])
400 AC_CONFIG_FILES([Makefile
401                  dist-build/Makefile
402                  man/Makefile
403                  src/Makefile
404                  src/hostip/Makefile
405                  src/proxy/Makefile
406                  src/ext/Makefile
407                  src/include/Makefile
408                  src/include/dnscrypt/version.h
409                  src/plugins/Makefile
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
417                  test/Makefile])
419 AC_OUTPUT