]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ldns/configure.ac
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ldns / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3 AC_PREREQ(2.56)
4 sinclude(acx_nlnetlabs.m4)
5
6 # must be numbers. ac_defun because of later processing.
7 m4_define([VERSION_MAJOR],[1])
8 m4_define([VERSION_MINOR],[6])
9 m4_define([VERSION_MICRO],[16])
10 AC_INIT(ldns, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), libdns@nlnetlabs.nl, libdns)
11 AC_CONFIG_SRCDIR([packet.c])
12 # needed to build correct soname
13 AC_SUBST(LIBTOOL_VERSION_INFO, VERSION_MAJOR:VERSION_MINOR:VERSION_MICRO)
14 AC_SUBST(LDNS_VERSION_MAJOR, [VERSION_MAJOR])
15 AC_SUBST(LDNS_VERSION_MINOR, [VERSION_MINOR])
16 AC_SUBST(LDNS_VERSION_MICRO, [VERSION_MICRO])
17
18 OURCPPFLAGS=''
19 CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
20 CFLAGS="$CFLAGS"
21
22 AC_AIX
23 # Checks for programs.
24 AC_PROG_CC
25 ACX_DEPFLAG
26 AC_PROG_MAKE_SET
27
28 # Extra (sp)lint flags for NetBSD
29 AC_CANONICAL_HOST
30 case "$host_os" in
31         netbsd*) LINTFLAGS="'-D__RENAME(x)=' -D_NETINET_IN_H_ $LINTFLAGS" 
32                  ;;
33         *)       LINTFLAGS="$LINTFLAGS"
34                  ;;
35 esac
36 AC_SUBST(LINTFLAGS)
37
38 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
39
40 ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
41 ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
42
43 # routine to copy files
44 # argument 1 is a list of files (relative to the source dir)
45 # argument 2 is a destination directory (relative to the current
46 # working directory
47 AC_DEFUN([COPY_FILES],
48 [
49 for file in $1; do
50         sh $srcdir/install-sh -m 644 $file $2
51 done
52 ])
53
54 # copy all .h files in the dir at argument 1
55 # (relative to source) to the dir at argument 2
56 # (relative to current dir)
57 AC_DEFUN([COPY_HEADER_FILES],
58 [
59 echo "copying header files"
60 COPY_FILES($srcdir/$1/*.h, $2)
61 ])
62
63 # Checks for typedefs, structures, and compiler characteristics.
64 AC_C_CONST
65 AC_LANG_C
66 if test "x$CFLAGS" = "x" ; then
67 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="-g"])
68 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="-O2 $CFLAGS"])
69 fi
70 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
71 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
72 ACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
73
74
75 AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
76
77 # MinGW32 tests
78 AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
79 # end mingw32 tests
80
81 ACX_DETERMINE_EXT_FLAGS_UNBOUND
82
83 AC_C_INLINE
84 AC_CHECK_TYPE(int8_t, char)
85 AC_CHECK_TYPE(int16_t, short)
86 AC_CHECK_TYPE(int32_t, int)
87 AC_CHECK_TYPE(int64_t, long long)
88 AC_CHECK_TYPE(uint8_t, unsigned char)
89 AC_CHECK_TYPE(uint16_t, unsigned short)
90 AC_CHECK_TYPE(uint32_t, unsigned int)
91 AC_CHECK_TYPE(uint64_t, unsigned long long)
92
93 # my own checks
94 AC_CHECK_PROG(doxygen, doxygen, doxygen)
95
96 # check to see if libraries are needed for these functions.
97 AC_SEARCH_LIBS([socket], [socket])
98 AC_SEARCH_LIBS([inet_pton], [nsl])
99
100
101 AC_ARG_WITH(drill, AC_HELP_STRING([--with-drill], 
102  [Also build drill.]), 
103  [],[with_drill="no"])
104 if test x_$with_drill != x_no ; then
105         AC_SUBST(DRILL,[drill])
106         AC_SUBST(INSTALL_DRILL,[install-drill])
107         AC_SUBST(UNINSTALL_DRILL,[uninstall-drill])
108         AC_SUBST(CLEAN_DRILL,[clean-drill])
109         AC_SUBST(LINT_DRILL,[lint-drill])
110         if test -e $srcdir/drill/config.h -o -e drill/config.h ; then
111                 AC_MSG_ERROR([
112 A config.h was detected in the drill subdirectory.
113 This does not work with the --with-drill option.
114 Please remove the config.h from the drill subdirectory 
115 or do not use the --with-drill option.])
116         fi
117         DRILL_CONFIG=" drill/drill.1"
118 else
119         AC_SUBST(DRILL,[""])
120         AC_SUBST(INSTALL_DRILL,[""])
121         AC_SUBST(UNINSTALL_DRILL,[""])
122         AC_SUBST(CLEAN_DRILL,[""])
123         AC_SUBST(LINT_DRILL,[""])
124         DRILL_CONFIG=""
125 fi
126
127
128 AC_ARG_WITH(examples, AC_HELP_STRING([--with-examples], 
129  [Also build examples.]), 
130  [],[with_examples="no"])
131 if test x_$with_examples != x_no ; then
132         AC_SUBST(EXAMPLES,[examples])
133         AC_SUBST(INSTALL_EXAMPLES,[install-examples])
134         AC_SUBST(UNINSTALL_EXAMPLES,[uninstall-examples])
135         AC_SUBST(CLEAN_EXAMPLES,[clean-examples])
136         AC_SUBST(LINT_EXAMPLES,[lint-examples])
137         if test -e $srcdir/examples/config.h -o -e examples/config.h ; then
138                 AC_MSG_ERROR([
139 A config.h was detected in the examples subdirectory.
140 This does not work with the --with-examples option.
141 Please remove the config.h from the examples subdirectory 
142 or do not use the --with-examples option.])
143         fi
144         EXAMPLES_CONFIG=" examples/ldns-dane.1 examples/ldns-verify-zone.1"
145 else
146         AC_SUBST(EXAMPLES,[""])
147         AC_SUBST(INSTALL_EXAMPLES,[""])
148         AC_SUBST(UNINSTALL_EXAMPLES,[""])
149         AC_SUBST(CLEAN_EXAMPLES,[""])
150         AC_SUBST(LINT_EXAMPLES,[""])
151         EXAMPLES_CONFIG=""
152 fi
153
154 # add option to disable installation of ldns-config script
155 AC_ARG_ENABLE(ldns-config, [ --disable-ldns-config      disable installation of ldns-config (default=enabled)],
156         enable_ldns_config=$enableval, enable_ldns_config=yes)
157 if test "x$enable_ldns_config" = xyes; then
158         AC_SUBST(INSTALL_CONFIG, [install-config])
159         AC_SUBST(INSTALL_CONFIG_MANPAGE, [install-config-manpage])
160         AC_SUBST(UNINSTALL_CONFIG, [uninstall-config])
161         AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [uninstall-config-manpage])
162 else
163         AC_SUBST(INSTALL_CONFIG, [""])
164         AC_SUBST(INSTALL_CONFIG_MANPAGE, [""])
165         AC_SUBST(UNINSTALL_CONFIG, [""])
166         AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [""])
167 fi
168
169 # check for python
170 PYTHON_X_CFLAGS=""
171 ldns_with_pyldns=no
172 ldns_with_pyldnsx=no
173 AC_ARG_WITH(pyldns, AC_HELP_STRING([--with-pyldns], 
174  [generate python library, or --without-pyldns to disable Python support.]), 
175  [],[ withval="no" ])
176 ldns_have_python=no
177 if test x_$withval != x_no; then
178    sinclude(ax_python_devel.m4)
179    ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
180
181    AX_PYTHON_DEVEL([>= '2.4.0'])
182    if test ! -z "$ac_python_version"; then
183         ldns_have_python=yes
184    fi
185
186    # pass additional Python 3 option to SWIG
187    if test `$PYTHON -c "import sys; \
188        ver = sys.version.split()[[0]]; \
189        print(ver >= '3')"` = "True"; then
190        AC_SUBST(SWIGPY3, ["-py3 -DPY3"])
191    fi
192
193    # check for SWIG
194    if test x_$ldns_have_python != x_no; then
195         sinclude(ax_pkg_swig.m4)
196
197         # check for >=SWIG-2.0.4 if Python 3.2 used
198         if test `$PYTHON -c "import sys; \
199             ver = sys.version.split()[[0]]; \
200             print(ver >= '3.2')"` = "True"; then
201             AX_PKG_SWIG(2.0.4, [], [AC_MSG_ERROR([SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater.])])
202         else
203             AX_PKG_SWIG
204         fi
205
206         if test ! -x "$SWIG"; then
207                 AC_MSG_ERROR([failed to find SWIG tool, install it, or do not build pyldns])
208         else
209                 AC_DEFINE(HAVE_SWIG,1,[Define if you have SWIG libraries and header files.])
210                 AC_SUBST(PYLDNS, "pyldns")
211                 AC_SUBST(swig, "$SWIG")
212                 ldns_with_pyldns=yes
213         fi
214    else
215         AC_MSG_RESULT([*** don't have Python, skipping SWIG, no pyldns ***]) # '
216    fi
217
218    # xtra cflags for pyldns
219    if test x_$ldns_have_python != x_no; then
220         ACX_CHECK_COMPILER_FLAG(fno-strict-aliasing, [PYTHON_X_CFLAGS="-fno-strict-aliasing"])
221         ACX_CHECK_COMPILER_FLAG(Wno-missing-field-initializers, [PYTHON_X_CFLAGS="-Wno-missing-field-initializers $PYTHON_X_CFLAGS"])
222         ACX_CHECK_COMPILER_FLAG(Wno-unused-parameter, [PYTHON_X_CFLAGS="-Wno-unused-parameter $PYTHON_X_CFLAGS"])
223         ACX_CHECK_COMPILER_FLAG(Wno-unused-variable, [PYTHON_X_CFLAGS="-Wno-unused-variable $PYTHON_X_CFLAGS"])
224    fi
225 fi
226 AC_SUBST(PYTHON_X_CFLAGS)
227
228 # Check for pyldnsx
229 AC_ARG_WITH(pyldnsx, AC_HELP_STRING([--without-pyldnsx], 
230   [Do not install the ldnsx python module, or --with-pyldnsx to install it.]), 
231   [],[ withval="with_pyldns" ])
232 if test x_$withval != x_no; then
233   if test x_$ldns_with_pyldns != x_no; then
234     AC_SUBST(PYLDNSX, "pyldnsx")
235     ldns_with_pyldnsx=yes
236   else
237     if test x_$withval != x_with_pyldns; then
238       AC_MSG_ERROR([--with-pyldns is needed for the ldnsx python module])
239     fi
240   fi
241 fi
242
243 if test x_$ldns_with_pyldns != x_no; then
244   AC_SUBST(PYLDNSINST, "install-pyldns")dnl
245   AC_SUBST(PYLDNSUNINST, "uninstall-pyldns")
246 else
247   AC_SUBST(PYLDNSINST, "")dnl
248   AC_SUBST(PYLDNSUNINST, "")
249 fi
250 if test x_$ldns_with_pyldnsx != x_no; then
251   AC_SUBST(PYLDNSXINST, "install-pyldnsx")dnl
252   AC_SUBST(PYLDNSXUNINST, "uninstall-pyldnsx")
253 else
254   AC_SUBST(PYLDNSXINST, "")dnl
255   AC_SUBST(PYLDNSXUNINST, "")
256 fi
257
258 # Use libtool
259 ACX_LIBTOOL_C_ONLY
260
261 tmp_CPPFLAGS=$CPPFLAGS
262 tmp_LDFLAGS=$LDFLAGS
263 tmp_LIBS=$LIBS
264
265 ACX_WITH_SSL_OPTIONAL
266
267 AC_CHECK_FUNCS([EVP_sha256])
268
269 # for macosx, see if glibtool exists and use that
270 # BSD's need to know the version...
271 #AC_CHECK_PROG(glibtool, glibtool, [glibtool], )
272 #AC_CHECK_PROGS(libtool, [libtool15 libtool], [./libtool])
273
274 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
275 case "$enable_sha2" in
276     no)
277         ;;
278     yes|*)
279         if test "x$HAVE_SSL" != "xyes"; then
280             AC_MSG_ERROR([SHA2 enabled, but no SSL support])
281         fi
282         AC_MSG_CHECKING(for SHA256 and SHA512)
283         AC_CHECK_FUNC(SHA256_Init, [], [
284                 AC_MSG_ERROR([No SHA2 functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-sha2])
285                 ])
286         AC_DEFINE_UNQUOTED([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
287         ;;
288 esac
289
290 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
291 case "$enable_gost" in
292     no)
293         ;;
294     *)  dnl default
295         if test "x$HAVE_SSL" != "xyes"; then
296             AC_MSG_ERROR([GOST enabled, but no SSL support])
297         fi
298         AC_MSG_CHECKING(for GOST)
299         AC_CHECK_FUNC(EVP_PKEY_set_type_str, [],[AC_MSG_ERROR([OpenSSL >= 1.0.0 is needed for GOST support or rerun with --disable-gost])])
300         AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([No ECC functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-gost])])
301         AC_DEFINE_UNQUOTED([USE_GOST], [1], [Define this to enable GOST support.])
302         ;;
303 esac
304
305 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
306 case "$enable_ecdsa" in
307     no)
308       ;;
309     *) dnl default
310       if test "x$HAVE_SSL" != "xyes"; then
311         AC_MSG_ERROR([ECDSA enabled, but no SSL support])
312       fi
313       AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade OpenSSL or rerun with --disable-ecdsa])])
314       AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade OpenSSL or rerun with --disable-ecdsa])])
315       AC_CHECK_DECLS([NID_X9_62_prime256v1, NID_secp384r1], [], [AC_MSG_ERROR([OpenSSL does not support the ECDSA curves: please upgrade OpenSSL or rerun with --disable-ecdsa])], [AC_INCLUDES_DEFAULT
316 #include <openssl/evp.h>
317       ])
318       # we now know we have ECDSA and the required curves.
319       AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
320       ;;
321 esac
322
323 AC_SUBST(LIBSSL_CPPFLAGS)
324 AC_SUBST(LIBSSL_LDFLAGS)
325 AC_SUBST(LIBSSL_LIBS)
326 if test "x$HAVE_SSL" = "xyes"; then
327 AC_SUBST(LIBSSL_SSL_LIBS, ["$LIBSSL_LIBS -lssl"])
328 fi
329 CPPFLAGS=$tmp_CPPFLAGS
330 LDFLAGS=$tmp_LDFLAGS
331 LIBS=$tmp_LIBS
332
333
334 # add option to disable the evil rpath
335 ACX_ARG_RPATH
336
337 #AC_RUN_IFELSE([AC_LANG_SOURCE(
338 #[
339 #int main()
340 #{
341 #short one = 1;
342 #char *cp = (char*)&one;
343 #if ( *cp == 0 )
344 #return(0);
345 #else
346 #return(1);
347 #}
348 #])], [],[
349 #AC_DEFINE(CONFCHECK_LITTLE_ENDIAN, 1, [system appears to be little-endian])
350 #],[])
351
352 # should define WORDS_BIGENDIAN if the system is big-endian
353 AC_C_BIGENDIAN
354
355 # Checks for header files.
356 AC_HEADER_STDC
357 AC_HEADER_STDBOOL
358 #AC_HEADER_SYS_WAIT
359 #AC_CHECK_HEADERS([getopt.h fcntl.h stdlib.h string.h strings.h unistd.h])
360 # do the very minimum - we can always extend this
361 AC_CHECK_HEADERS([getopt.h stdarg.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
362 AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
363 [AC_INCLUDES_DEFAULT
364   [
365    #if HAVE_SYS_PARAM_H
366    # include <sys/param.h>
367    #endif
368   ]
369 ])
370 AC_CHECK_HEADER(sys/socket.h,
371 [
372 include_sys_socket_h='#include <sys/socket.h>'
373 AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [define if you have sys/socket.h])
374 ],[
375 include_sys_socket_h=''
376 ],[AC_INCLUDES_DEFAULT
377   [
378    #if HAVE_SYS_PARAM_H
379    # include <sys/param.h>
380    #endif
381   ]
382 ])
383 AC_SUBST(include_sys_socket_h)
384 AC_CHECK_HEADER(inttypes.h,
385 [
386 include_inttypes_h='#include <inttypes.h>'
387 AC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
388 AC_SUBST(ldns_build_config_have_inttypes_h, 1)
389 ],[
390 include_inttypes_h=''
391 AC_SUBST(ldns_build_config_have_inttypes_h, 0)
392 ],[AC_INCLUDES_DEFAULT
393 ])
394 AC_SUBST(include_inttypes_h)
395 AC_CHECK_HEADER(sys/types.h,
396 [
397 include_systypes_h='#include <sys/types.h>'
398 AC_DEFINE(HAVE_SYS_TYPES_H, 1, [define if you have sys/types.h])
399 ],[
400 include_systypes_h=''
401 ],[AC_INCLUDES_DEFAULT
402 ])
403 AC_SUBST(include_systypes_h)
404 AC_CHECK_HEADER(unistd.h,
405 [
406 include_unistd_h='#include <unistd.h>'
407 AC_DEFINE(HAVE_UNISTD_H, 1, [define if you have unistd.h])
408 ],[
409 include_unistd_h=''
410 ],[AC_INCLUDES_DEFAULT
411 ])
412 AC_SUBST(include_unistd_h)
413
414 AC_CHECK_SIZEOF(time_t,,[
415 AC_INCLUDES_DEFAULT
416 #ifdef TIME_WITH_SYS_TIME
417 # include <sys/time.h>
418 # include <time.h>
419 #else
420 # ifdef HAVE_SYS_TIME_H
421 #  include <sys/time.h>
422 # else
423 #  include <time.h>
424 # endif
425 #endif
426 ])
427
428 if test x_$with_examples != x_no; then
429 AC_CHECK_HEADERS([pcap.h],, [AC_INCLUDES_DEFAULT])
430 AC_CHECK_LIB(pcap, pcap_open_offline, [
431         AC_DEFINE([HAVE_LIBPCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap).])dnl`
432         AC_SUBST([LIBPCAP_LIBS], [-lpcap])
433     ], [
434         AC_MSG_WARN([Can't find pcap library (needed for ldns-dpa, will not build dpa now.)])dnl'
435         AC_SUBST([LIBPCAP_LIBS], [])
436     ]
437 )
438 AC_CHECK_HEADERS([netinet/in_systm.h net/if.h netinet/ip.h netinet/udp.h netinet/igmp.h netinet/if_ether.h netinet/ip6.h net/ethernet.h netinet/ip_compat.h],,, [
439 AC_INCLUDES_DEFAULT 
440 #ifdef HAVE_NETINET_IN_SYSTM_H
441 #include <netinet/in_systm.h>
442 #endif
443 #ifdef HAVE_NETINET_IN_H
444 #include <netinet/in.h>
445 #endif
446 #ifdef HAVE_SYS_SOCKET_H
447 #include <sys/socket.h>
448 #endif
449 #ifdef HAVE_NET_IF_H
450 #include <net/if.h>
451 #endif])
452 fi
453
454 ACX_TYPE_SOCKLEN_T
455 if test "x$ac_cv_type_socklen_t" = xyes; then
456   AC_SUBST(ldns_build_config_have_socklen_t, 1)
457 else
458   AC_SUBST(ldns_build_config_have_socklen_t, 0)
459 fi
460 AC_TYPE_SIZE_T
461 AC_TYPE_SSIZE_T
462 AC_TYPE_INTPTR_T
463 AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
464 #if HAVE_SYS_TYPES_H
465 # include <sys/types.h>
466 #endif
467 #if HAVE_NETINET_IN_H
468 # include <netinet/in.h>
469 #endif])
470 AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
471 #if HAVE_SYS_TYPES_H
472 # include <sys/types.h>
473 #endif
474 #if HAVE_NETINET_IN_H
475 # include <netinet/in.h>
476 #endif])
477 ACX_CHECK_SS_FAMILY
478
479 AC_FUNC_MALLOC
480 AC_FUNC_REALLOC
481
482 AC_REPLACE_FUNCS(b64_pton)
483 AC_REPLACE_FUNCS(b64_ntop)
484 AC_REPLACE_FUNCS(b32_pton)
485 AC_REPLACE_FUNCS(b32_ntop)
486 AC_REPLACE_FUNCS(calloc)
487 AC_REPLACE_FUNCS(timegm)
488 AC_REPLACE_FUNCS(gmtime_r)
489 AC_REPLACE_FUNCS(ctime_r)
490 AC_REPLACE_FUNCS(localtime_r)
491 AC_REPLACE_FUNCS(isblank)
492 AC_REPLACE_FUNCS(isascii)
493 AC_REPLACE_FUNCS(inet_aton)
494 AC_REPLACE_FUNCS(inet_pton)
495 AC_REPLACE_FUNCS(inet_ntop)
496 AC_REPLACE_FUNCS(snprintf)
497 AC_REPLACE_FUNCS(strlcpy)
498 AC_REPLACE_FUNCS(memmove)
499 AC_FUNC_FORK
500 AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset])
501
502 ACX_CHECK_GETADDRINFO_WITH_INCLUDES
503 if test $ac_cv_func_getaddrinfo = no; then
504         AC_LIBOBJ([fake-rfc2553])
505 fi
506 if test "$USE_WINSOCK" = 1; then
507         AC_CHECK_TOOL(WINDRES, windres)
508 fi
509 ACX_FUNC_IOCTLSOCKET
510
511 #AC_SEARCH_LIBS(RSA_new, [crypto])
512
513 ACX_CHECK_FORMAT_ATTRIBUTE
514 ACX_CHECK_UNUSED_ATTRIBUTE
515
516 # check OSX deployment target which is needed
517 if echo $build_os | grep darwin > /dev/null; then
518         export MACOSX_DEPLOYMENT_TARGET="10.4"
519 fi
520
521 AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
522
523 AC_ARG_WITH(trust-anchor, AC_HELP_STRING([--with-trust-anchor=KEYFILE], [Default location of the trust anchor file for drill and ldns-dane. [default=SYSCONFDIR/unbound/root.key]]), [
524  LDNS_TRUST_ANCHOR_FILE="$withval"
525 ],[
526  if test "x$LDNS_TRUST_ANCHOR_FILE" = "x"; then
527   if test "x$sysconfdir" = 'x${prefix}/etc' ; then
528    if test "x$prefix" = 'xNONE' ; then
529     LDNS_TRUST_ANCHOR_FILE="/etc/unbound/root.key"
530    else
531     LDNS_TRUST_ANCHOR_FILE="${prefix}/etc/unbound/root.key"
532    fi
533   else
534     LDNS_TRUST_ANCHOR_FILE="${sysconfdir}/unbound/root.key"
535   fi
536  fi
537 ])
538 AC_DEFINE_UNQUOTED([LDNS_TRUST_ANCHOR_FILE], ["$LDNS_TRUST_ANCHOR_FILE"], [Default trust anchor file])
539 AC_SUBST(LDNS_TRUST_ANCHOR_FILE)
540 AC_MSG_NOTICE([Default trust anchor: $LDNS_TRUST_ANCHOR_FILE])
541
542 AC_ARG_WITH(ca-file, AC_HELP_STRING([--with-ca-file=CAFILE], [File containing CA certificates for ldns-dane]), [
543  AC_DEFINE([HAVE_DANE_CA_FILE], [1], [Is a CAFILE given at configure time])
544  AC_DEFINE_UNQUOTED([LDNS_DANE_CA_FILE], ["$withval"], [Is a CAFILE given at configure time])
545  AC_MSG_NOTICE([Using CAfile: $withval])
546  AC_SUBST(DEFAULT_CAFILE, ["Default is $withval"])
547 ],[
548  AC_DEFINE([HAVE_DANE_CA_FILE], [0], [Is a CAFILE given at configure time])
549  AC_SUBST(DEFAULT_CAFILE, [])
550 ])
551
552 AC_ARG_WITH(ca-path, AC_HELP_STRING([--with-ca-path=CAPATH], [Directory containing CA certificate files for ldns-dane]), [
553  AC_DEFINE([HAVE_DANE_CA_PATH], [1], [Is a CAPATH given at configure time])
554  AC_DEFINE_UNQUOTED([LDNS_DANE_CA_PATH], ["$withval"], [Is a CAPATH given at configure time])
555  AC_MSG_NOTICE([Using CApath: $withval])
556  AC_SUBST(DEFAULT_CAPATH, ["Default is $withval"])
557 ],[
558  AC_DEFINE([HAVE_DANE_CA_PATH], [0], [Is a CAPATH given at configure time])
559  AC_SUBST(DEFAULT_CAPATH, [])
560 ])
561
562 AH_BOTTOM([
563 #include <stdio.h>
564 #include <string.h>
565 #include <unistd.h>
566 #include <assert.h>
567
568 #ifndef LITTLE_ENDIAN
569 #define LITTLE_ENDIAN 1234
570 #endif
571
572 #ifndef BIG_ENDIAN
573 #define BIG_ENDIAN 4321
574 #endif
575
576 #ifndef BYTE_ORDER
577 #ifdef WORDS_BIGENDIAN
578 #define BYTE_ORDER BIG_ENDIAN
579 #else
580 #define BYTE_ORDER LITTLE_ENDIAN
581 #endif /* WORDS_BIGENDIAN */
582 #endif /* BYTE_ORDER */
583
584 #if STDC_HEADERS
585 #include <stdlib.h>
586 #include <stddef.h>
587 #endif
588
589 #ifdef HAVE_STDINT_H
590 #include <stdint.h>
591 #endif
592
593 #ifdef HAVE_SYS_SOCKET_H
594 #include <sys/socket.h>
595 #endif
596
597 #ifdef HAVE_NETINET_IN_H
598 #include <netinet/in.h>
599 #endif
600
601 #ifdef HAVE_ARPA_INET_H
602 #include <arpa/inet.h>
603 #endif
604
605 #ifdef HAVE_WINSOCK2_H
606 #include <winsock2.h>
607 #endif
608
609 #ifdef HAVE_WS2TCPIP_H
610 #include <ws2tcpip.h>
611 #endif
612 ]
613 AHX_CONFIG_W32_FD_SET_T
614 )
615
616 AH_BOTTOM([
617 #ifdef __cplusplus
618 extern "C" {
619 #endif
620
621 #ifndef B64_PTON
622 int ldns_b64_ntop(uint8_t const *src, size_t srclength,
623                   char *target, size_t targsize);
624 /**
625  * calculates the size needed to store the result of b64_ntop
626  */
627 /*@unused@*/
628 static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
629 {
630         return ((((srcsize + 2) / 3) * 4) + 1);
631 }
632 #endif /* !B64_PTON */
633 #ifndef B64_NTOP
634 int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
635 /**
636  * calculates the size needed to store the result of ldns_b64_pton
637  */
638 /*@unused@*/
639 static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
640 {
641         return (((((srcsize + 3) / 4) * 3)) + 1);
642 }
643 #endif /* !B64_NTOP */
644
645 #ifndef HAVE_SLEEP
646 /* use windows sleep, in millisecs, instead */
647 #define sleep(x) Sleep((x)*1000)
648 #endif
649
650 #ifndef HAVE_RANDOM
651 #define srandom(x) srand(x)
652 #define random(x) rand(x)
653 #endif
654
655 #ifndef HAVE_TIMEGM
656 #include <time.h>
657 time_t timegm (struct tm *tm);
658 #endif /* !TIMEGM */
659 #ifndef HAVE_GMTIME_R
660 struct tm *gmtime_r(const time_t *timep, struct tm *result);
661 #endif
662 #ifndef HAVE_LOCALTIME_R
663 struct tm *localtime_r(const time_t *timep, struct tm *result);
664 #endif
665 #ifndef HAVE_ISBLANK
666 int isblank(int c);
667 #endif /* !HAVE_ISBLANK */
668 #ifndef HAVE_ISASCII
669 int isascii(int c);
670 #endif /* !HAVE_ISASCII */
671 #ifndef HAVE_SNPRINTF
672 #include <stdarg.h>
673 int snprintf (char *str, size_t count, const char *fmt, ...);
674 int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
675 #endif /* HAVE_SNPRINTF */
676 #ifndef HAVE_INET_PTON
677 int inet_pton(int af, const char* src, void* dst);
678 #endif /* HAVE_INET_PTON */
679 #ifndef HAVE_INET_NTOP
680 const char *inet_ntop(int af, const void *src, char *dst, size_t size);
681 #endif
682 #ifndef HAVE_INET_ATON
683 int inet_aton(const char *cp, struct in_addr *addr);
684 #endif
685 #ifndef HAVE_MEMMOVE
686 void *memmove(void *dest, const void *src, size_t n);
687 #endif
688 #ifndef HAVE_STRLCPY
689 size_t strlcpy(char *dst, const char *src, size_t siz);
690 #endif
691 #ifdef __cplusplus
692 }
693 #endif
694 #ifndef HAVE_GETADDRINFO
695 #include "compat/fake-rfc2553.h"
696 #endif
697 #ifndef HAVE_STRTOUL
698 #define strtoul (unsigned long)strtol
699 #endif
700 ])
701
702 if test "x$HAVE_SSL" = "xyes"; then
703         AC_SUBST(ldns_build_config_have_ssl, 1)
704 else
705         AC_SUBST(ldns_build_config_have_ssl, 0)
706 fi
707 if test "x$ac_cv_c_format_attribute" = "xyes"; then
708   AC_SUBST(ldns_build_config_have_attr_format, 1)
709 else
710   AC_SUBST(ldns_build_config_have_attr_format, 0)
711 fi
712 if test "x$ac_cv_c_unused_attribute" = "xyes"; then
713   AC_SUBST(ldns_build_config_have_attr_unused, 1)
714 else
715   AC_SUBST(ldns_build_config_have_attr_unused, 0)
716 fi
717
718 CONFIG_FILES="Makefile ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config $DRILL_CONFIG $EXAMPLES_CONFIG"
719 AC_SUBST(CONFIG_FILES)
720 AC_CONFIG_FILES([$CONFIG_FILES])
721
722 AC_CONFIG_HEADER([ldns/config.h])
723 AC_OUTPUT
724 COPY_HEADER_FILES(ldns/, ldns/)
725
726 dnl AC_CONFIG_SUBDIRS([drill])
727
728