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