Changes to update Tomato RAF.
[tomato.git] / release / src / router / dnscrypt / configure.ac
blobd219e9d8af6ba3db3640d72278e931d97dbad10e
1 AC_PREREQ([2.61])
2 AC_INIT([dnscrypt-proxy],[1.0],[https://github.com/opendns/dnscrypt-proxy/issues])
3 AC_CONFIG_MACRO_DIR([m4])
4 AC_CONFIG_SRCDIR([src/proxy/app.c])
5 AC_CONFIG_HEADER([config.h])
6 AC_CONFIG_SUBDIRS([src/libevent])
7 AC_CANONICAL_HOST
8 AM_INIT_AUTOMAKE([1.9 dist-bzip2])
9 AM_MAINTAINER_MODE
10 AM_DEP_TRACK
12 AC_SUBST(VERSION)
13 ISODATE=`date +%Y-%m-%d`
14 AC_SUBST(ISODATE)
16 LX_CFLAGS=${CFLAGS-NONE}
17 AC_PROG_CC_C99
18 AC_USE_SYSTEM_EXTENSIONS
19 CPPFLAGS="$CPPFLAGS -D_XPG4_2=1 -D_GNU_SOURCE=1"
20 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
22 AS_IF([test "$cross_compiling" != no],
23   AC_DEFINE(CROSS_COMPILING,,[define if you are cross-compiling])
26 AX_CHECK_COMPILE_FLAG([-fPIC], [
27   AX_CHECK_LINK_FLAG([-fPIC],
28     [CFLAGS="$CFLAGS -fPIC"]
29   )
31 AX_CHECK_COMPILE_FLAG([-fPIE], [
32   AX_CHECK_LINK_FLAG([-fPIE],
33     [AX_CHECK_LINK_FLAG([-pie],
34       [CFLAGS="$CFLAGS -fPIE"
35        LDFLAGS="$LDFLAGS -pie"])
36   ])
39 AX_CHECK_COMPILE_FLAG([-fcatch-undefined-c99-behavior],
40   [CFLAGS="$CFLAGS -fcatch-undefined-c99-behavior"],
41   [AX_CHECK_COMPILE_FLAG([-fwrapv], [CFLAGS="$CFLAGS -fwrapv"])]
43 AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
44 AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CFLAGS="$CFLAGS -fno-strict-overflow"])
46 case $host_os in
47   cygwin* | mingw* | pw32* | cegcc*)
48     AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
49     AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
50     AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [
51       AX_CHECK_LINK_FLAG([-fstack-protector-all],
52         [CFLAGS="$CFLAGS -fstack-protector-all"]
53       )
54     ])
55   ;;
56   dragonfly*)
57     AX_CHECK_COMPILE_FLAG([-fstack-protector], [
58       AX_CHECK_LINK_FLAG([-fstack-protector],
59         [CFLAGS="$CFLAGS -fstack-protector"]
60       )
61     ])
62   ;;
63   *)
64     AX_CHECK_COMPILE_FLAG([-fstack-protector-all], [
65       AX_CHECK_LINK_FLAG([-fstack-protector-all],
66         [CFLAGS="$CFLAGS -fstack-protector-all"]
67       )
68     ])
69   ;;
70 esac
72 AX_CHECK_COMPILE_FLAG([-Wbounded], [CFLAGS="$CFLAGS -Wbounded"])
73 AX_CHECK_COMPILE_FLAG([-Winit-self], [CFLAGS="$CFLAGS -Winit-self"])
74 AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"])
75 AX_CHECK_COMPILE_FLAG([-Wdiv-by-zero], [CFLAGS="$CFLAGS -Wdiv-by-zero"])
77 AC_ARG_VAR([CWFLAGS], [define to compilation flags for generating extra warnings])
79 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wall], [CWFLAGS="$CWFLAGS -Wall"])
80 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wextra], [CWFLAGS="$CWFLAGS -Wextra"])
82 AC_MSG_CHECKING(for clang)
83 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
84 #ifndef __clang__
85 be sad
86 #endif
87 ]])],
88   [AC_MSG_RESULT(yes)
89    AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wno-unknown-warning-option],
90   [CWFLAGS="$CWFLAGS -Wno-unknown-warning-option"])],
91   [AC_MSG_RESULT(no)
94 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wbad-function-cast], [CWFLAGS="$CWFLAGS -Wbad-function-cast"])
95 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-align], [CWFLAGS="$CWFLAGS -Wcast-align"])
96 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-qual], [CWFLAGS="$CWFLAGS -Wcast-qual"])
97 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wchar-subscripts], [CWFLAGS="$CWFLAGS -Wchar-subscripts"])
98 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcomment], [CWFLAGS="$CWFLAGS -Wcomment"])
99 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wfloat-equal], [CWFLAGS="$CWFLAGS -Wfloat-equal"])
100 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wformat=2], [CWFLAGS="$CWFLAGS -Wformat=2"])
101 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wimplicit], [CWFLAGS="$CWFLAGS -Wimplicit"])
102 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-declarations], [CWFLAGS="$CWFLAGS -Wmissing-declarations"])
103 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wmissing-prototypes], [CWFLAGS="$CWFLAGS -Wmissing-prototypes"])
104 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wnormalized=id], [CWFLAGS="$CWFLAGS -Wnormalized=id"])
105 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Woverride-init], [CWFLAGS="$CWFLAGS -Woverride-init"])
106 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wparentheses], [CWFLAGS="$CWFLAGS -Wparentheses"])
107 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wpointer-arith], [CWFLAGS="$CWFLAGS -Wpointer-arith"])
108 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wredundant-decls], [CWFLAGS="$CWFLAGS -Wredundant-decls"])
109 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wstrict-prototypes], [CWFLAGS="$CWFLAGS -Wstrict-prototypes"])
110 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wswitch-enum], [CWFLAGS="$CWFLAGS -Wswitch-enum"])
111 AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wvariable-decl], [CWFLAGS="$CWFLAGS -Wvariable-decl"])
113 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
114 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
115 AX_CHECK_LINK_FLAG([-Wl,-z,noexecstack], [LDFLAGS="$LDFLAGS -Wl,-z,noexecstack"])
117 LT_INIT
118 AC_SUBST(LIBTOOL_DEPS)
120 AC_ARG_VAR([RONN], [path to the ronn text processor])
121 AC_PATH_PROG([RONN], [ronn], [#])
123 AC_ARG_VAR([SIXJACK], [path to 6jack])
124 AC_PATH_PROG([SIXJACK], [sixjack], [#])
126 AC_ARG_VAR([AR], [path to the ar utility])
127 AC_CHECK_TOOL([AR], [ar], [ar])
129 AS_IF([test `(uname -s) 2>/dev/null` = "Darwin"], [
130   AC_ARG_VAR([DTRACE], [path to dtrace if you have it])
131   AC_PATH_PROG([DTRACE], [dtrace])
133 AS_IF([test -n "$DTRACE"],[
134   PROBES_SOURCE="probes_dnscrypt_proxy.h"
136   DTRACE="#"
137   PROBES_SOURCE="probes_no_dtrace.h"
140 AS_IF([test -d /usr/local/include], [
141   CPPFLAGS="$CPPFLAGS -I/usr/local/include"
144 AS_IF([test -d /usr/local/lib], [
145   LDFLAGS="$LDFLAGS -L/usr/local/lib"
148 dnl Checks for header files.
150 AC_SYS_LARGEFILE
151 AC_CHECK_HEADERS([sys/cdefs.h sys/feature_tests.h])
152 AC_CHECK_HEADERS([execinfo.h paths.h pwd.h uuid/uuid.h])
153 AC_CHECK_HEADERS([sandbox.h])
155 AC_CHECK_FUNCS([getpwnam sandbox_init setrlimit])
157 dnl Checks for typedefs, structures, and compiler characteristics.
159 AC_C_BIGENDIAN
160 AC_C_RESTRICT
162 AC_CHECK_TYPE([in_port_t], , [AC_DEFINE(in_port_t, uint16_t,
163 [in_port_t type])],
165 #ifdef HAVE_UNISTD_H
166 # include <unistd.h>
167 #endif
168 #include <sys/types.h>
169 #include <sys/socket.h>
170 #include <netinet/in.h>
173 AC_MSG_CHECKING([whether sin_len is defined])
174 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
175 #include <stdio.h>
176 #ifdef HAVE_UNISTD_H
177 # include <unistd.h>
178 #endif
179 #include <sys/types.h>
180 #include <sys/socket.h>
181 #include <netinet/in.h>
182 ]], [[
183 do {
184  struct sockaddr_in a;
185  (void) a.sin_len;
186 } while(0)
187 ]])],[
188   AC_MSG_RESULT(yes)
189   AC_DEFINE(HAVE_SIN_LEN,,[define if you have sin_len])
191   AC_MSG_RESULT(no)
194 AC_MSG_CHECKING([whether __ss_family is defined])
195 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
196 #include <stdio.h>
197 #ifdef HAVE_UNISTD_H
198 # include <unistd.h>
199 #endif
200 #include <sys/types.h>
201 #include <sys/socket.h>
202 ]], [[
203 do {
204  struct sockaddr_storage a;
205  (void) a.__ss_family;
206 } while(0)
207 ]])],[
208   AC_MSG_RESULT(yes)
209   AC_DEFINE(HAVE___SS_FAMILY,,[define if you have __ss_family])
211   AC_MSG_RESULT(no)
214 AC_MSG_CHECKING([whether ss_len is defined])
215 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
216 #include <stdio.h>
217 #ifdef HAVE_UNISTD_H
218 # include <unistd.h>
219 #endif
220 #include <sys/types.h>
221 #include <sys/socket.h>
222 ]], [[
223 do {
224  struct sockaddr_storage a;
225  (void) a.ss_len;
226 } while(0)
227 ]])],[
228   AC_MSG_RESULT(yes)
229   AC_DEFINE(HAVE_SS_LEN,,[define if you have ss_len])
231   AC_MSG_RESULT(no)
234 AC_MSG_CHECKING([whether __ss_len is defined])
235 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
236 #include <stdio.h>
237 #ifdef HAVE_UNISTD_H
238 # include <unistd.h>
239 #endif
240 #include <sys/types.h>
241 #include <sys/socket.h>
242 ]], [[
243 do {
244  struct sockaddr_storage a;
245  (void) a.__ss_len;
246 } while(0)
247 ]])],[
248   AC_MSG_RESULT(yes)
249   AC_DEFINE(HAVE___SS_LEN,,[define if you have __ss_len])
251   AC_MSG_RESULT(no)
254 dnl Checks for library functions.
256 AC_SEARCH_LIBS(pow, [m])
257 AC_SEARCH_LIBS(dlopen, [dl])
258 AC_SEARCH_LIBS(clock_gettime, [rt],
259   [AC_DEFINE(HAVE_CLOCK_GETTIME,,[define if you have clock_gettime()])])
261 AC_SEARCH_LIBS(backtrace, [execinfo],
262   [AC_DEFINE(HAVE_BACKTRACE,,[define if you have backtrace()])])
264 AC_SEARCH_LIBS(gethostbyname, [resolv nsl])
265 AC_SEARCH_LIBS(recvfrom, [socket])
266 AC_SEARCH_LIBS(kvm_open, [kvm])
268 case $host_os in
269   cygwin* | mingw* | pw32* | cegcc*)
270     AC_CHECK_LIB([ws2_32], [_head_libws2_32_a])
271     AC_CHECK_LIB([psapi], [_head_libpsapi_a])
272     AC_CHECK_LIB([iphlpapi], [_head_libiphlpapi_a])
273   ;;
274 esac
276 AC_CHECK_HEADER([CoreServices/CoreServices.h],
277   [LIBS="$LIBS -framework CoreFoundation -framework CoreServices"])
279 dnl Switches.
281 AC_HEADER_ASSERT
283 AC_ARG_ENABLE(blocking-random,
284 [AS_HELP_STRING(--enable-blocking-random,Use /dev/random instead of /dev/urandom)],
285 [AC_DEFINE([USE_BLOCKING_RANDOM], [], [Use blocking random])])
287 AC_ARG_ENABLE(ssp,
288 [AS_HELP_STRING(--disable-ssp,Don't compile with -fstack-protector)],
289 [AS_IF([test "x$enableval" = "xno"], [
290     nxflags=""
291     for flag in `echo $CFLAGS`; do
292       case "$flag" in
293        -fstack-protector*) ;;
294         *) AS_VAR_APPEND([nxflags], [" $flag"]) ;;
295       esac
296     done
297     CFLAGS="$nxflags"
298   ])
301 AC_ARG_ENABLE(debug,
302 [AS_HELP_STRING(--enable-debug,For maintainers only - please do not use)],
304   AS_IF([test "x$LX_CFLAGS" = "xNONE"], [
305     nxflags=""
306     for flag in `echo $CFLAGS`; do
307       case "$flag" in
308         -O*) ;;
309         -g*) ;;
310         *) AS_VAR_APPEND([nxflags], [" $flag"]) ;;
311       esac
312     done
313     CFLAGS="$nxflags -O0 -g3"
314   ])
315   CPPFLAGS="$CPPFLAGS -DDEBUG=1"
318 AC_ARG_WITH(safecode,
319 [AS_HELP_STRING(--with-safecode,For maintainers only - please do not use)],
320 [AS_IF([test "x$withval" = "xyes"], [
321     AC_ARG_VAR([SAFECODE_HOME], [set to the safecode base directory])
322     : ${SAFECODE_HOME:=/opt/safecode}
323     LDFLAGS="$LDFLAGS -L${SAFECODE_HOME}/lib"
324     LIBS="$LIBS -lsc_dbg_rt -lpoolalloc_bitmap -lstdc++"
325     CFLAGS="$CFLAGS -fmemsafety"
326   ])
329 NACL_HOSTNAME="localhost"
330 NACL_PATH=libnacl/build/${NACL_HOSTNAME}
332 AC_SUBST([MAINT])
333 AC_SUBST([NACL_PATH])
334 AC_SUBST([PROBES_SOURCE])
336 dnl Libtool.
338 LT_INIT([disable-shared])
340 dnl Subconfig.
342 nx_ac_configure_args=""
343 for flag in $ac_configure_args; do
344   case "$flag" in
345     \'--build*) AS_VAR_APPEND([nx_ac_configure_args], [" $flag"]) ;;
346     \'--host*)  AS_VAR_APPEND([nx_ac_configure_args], [" $flag"]) ;;
347     *) ;;
348   esac
349 done
350 ac_configure_args="$nx_ac_configure_args"
352 case $host_os in
353   cygwin* | mingw* | pw32* | cegcc*) ;;
354   *) ac_configure_args="$ac_configure_args --disable-thread-support" ;;
355 esac
357 ac_configure_args="$ac_configure_args --disable-dependency-tracking"
358 ac_configure_args="$ac_configure_args --disable-libevent-install"
359 ac_configure_args="$ac_configure_args --disable-openssl"
360 ac_configure_args="$ac_configure_args --disable-shared"
361 ac_configure_args="$ac_configure_args --enable-function-sections"
362 export CC
363 export CFLAGS
364 export CPP
365 export CPPFLAGS
366 export LDFLAGS
367 export LIBS
369 dnl Output.
371 AC_CONFIG_FILES([Makefile
372                  man/Makefile
373                  src/Makefile
374                  src/hostip/Makefile
375                  src/proxy/Makefile
376                  src/ext/Makefile
377                  src/libnacl/Makefile
378                  src/libnacl/tests/Makefile
379                  src/libnacl/okcompilers/c
380                  src/libnacl/okcompilers/do
381                  test/Makefile])
383 AC_OUTPUT
385 chmod +x src/libnacl/okcompilers/do