xref: /freebsd/contrib/ldns/configure.ac (revision b2d48be1bc7df45ddd13b143a160d0acb5a383c5)
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3AC_PREREQ(2.56)
4sinclude(acx_nlnetlabs.m4)
5
6# must be numbers. ac_defun because of later processing.
7m4_define([VERSION_MAJOR],[1])
8m4_define([VERSION_MINOR],[6])
9m4_define([VERSION_MICRO],[17])
10AC_INIT(ldns, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), libdns@nlnetlabs.nl, libdns)
11AC_CONFIG_SRCDIR([packet.c])
12# needed to build correct soname
13AC_SUBST(LDNS_VERSION_MAJOR, [VERSION_MAJOR])
14AC_SUBST(LDNS_VERSION_MINOR, [VERSION_MINOR])
15AC_SUBST(LDNS_VERSION_MICRO, [VERSION_MICRO])
16AC_SUBST(VERSION_INFO, [VERSION_MAJOR:VERSION_MINOR:VERSION_MICRO])
17
18AC_AIX
19LT_INIT
20AC_CONFIG_MACRO_DIR([m4])
21
22OURCPPFLAGS=''
23CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
24CFLAGS="$CFLAGS"
25
26# Checks for programs.
27AC_PROG_CC
28ACX_DEPFLAG
29AC_PROG_MAKE_SET
30
31# Extra (sp)lint flags for NetBSD
32AC_CANONICAL_HOST
33case "$host_os" in
34	netbsd*) LINTFLAGS="'-D__RENAME(x)=' -D_NETINET_IN_H_ $LINTFLAGS"
35		 ;;
36	*)       LINTFLAGS="$LINTFLAGS"
37		 ;;
38esac
39AC_SUBST(LINTFLAGS)
40
41AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
42
43ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
44ACX_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
50AC_DEFUN([COPY_FILES],
51[
52for file in $1; do
53	sh $srcdir/install-sh -m 644 $file $2
54done
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)
60AC_DEFUN([COPY_HEADER_FILES],
61[
62echo "copying header files"
63COPY_FILES($srcdir/$1/*.h, $2)
64])
65
66# Checks for typedefs, structures, and compiler characteristics.
67AC_C_CONST
68AC_LANG_C
69if test "x$CFLAGS" = "x" ; then
70ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="-g"])
71ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="-O2 $CFLAGS"])
72fi
73ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
74ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
75ACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
76ACX_CHECK_COMPILER_FLAG(Wstrict-prototypes, [CFLAGS="-Wstrict-prototypes $CFLAGS"])
77
78
79AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
80
81# MinGW32 tests
82AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
83# end mingw32 tests
84
85ACX_DETERMINE_EXT_FLAGS_UNBOUND
86
87AC_C_INLINE
88AC_CHECK_TYPE(int8_t, char)
89AC_CHECK_TYPE(int16_t, short)
90AC_CHECK_TYPE(int32_t, int)
91AC_CHECK_TYPE(int64_t, long long)
92AC_CHECK_TYPE(uint8_t, unsigned char)
93AC_CHECK_TYPE(uint16_t, unsigned short)
94AC_CHECK_TYPE(uint32_t, unsigned int)
95AC_CHECK_TYPE(uint64_t, unsigned long long)
96
97# my own checks
98AC_CHECK_PROG(doxygen, doxygen, doxygen)
99
100# check to see if libraries are needed for these functions.
101AC_SEARCH_LIBS([socket], [socket])
102AC_SEARCH_LIBS([inet_pton], [nsl])
103
104
105AC_ARG_WITH(drill, AC_HELP_STRING([--with-drill],
106 [Also build drill.]),
107 [],[with_drill="no"])
108if 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([
116A config.h was detected in the drill subdirectory.
117This does not work with the --with-drill option.
118Please remove the config.h from the drill subdirectory
119or do not use the --with-drill option.])
120	fi
121	DRILL_CONFIG=" drill/drill.1"
122else
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=""
129fi
130
131
132AC_ARG_WITH(examples, AC_HELP_STRING([--with-examples],
133 [Also build examples.]),
134 [],[with_examples="no"])
135if 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([
143A config.h was detected in the examples subdirectory.
144This does not work with the --with-examples option.
145Please remove the config.h from the examples subdirectory
146or do not use the --with-examples option.])
147	fi
148	EXAMPLES_CONFIG=" examples/ldns-dane.1 examples/ldns-verify-zone.1"
149else
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=""
156fi
157
158# add option to disable installation of ldns-config script
159AC_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)
161if 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])
166else
167	AC_SUBST(INSTALL_CONFIG, [""])
168	AC_SUBST(INSTALL_CONFIG_MANPAGE, [""])
169	AC_SUBST(UNINSTALL_CONFIG, [""])
170	AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [""])
171fi
172
173# add option to disable library printing to stderr
174AC_ARG_ENABLE(stderr-msgs, AC_HELP_STRING([--enable-stderr-msgs], [Enable printing to stderr (default=disabled)]), enable_stderr_msgs=$enableval, enable_stderr_msgs=no)
175case "$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        ;;
181esac
182
183# check for python
184PYTHON_X_CFLAGS=""
185ldns_with_pyldns=no
186ldns_with_pyldnsx=no
187AC_ARG_WITH(pyldns, AC_HELP_STRING([--with-pyldns],
188 [generate python library, or --without-pyldns to disable Python support.]),
189 [],[ withval="no" ])
190ldns_have_python=no
191if 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
239fi
240AC_SUBST(PYTHON_X_CFLAGS)
241
242# Check for pyldnsx
243AC_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" ])
246if 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
255fi
256
257if test x_$ldns_with_pyldns != x_no; then
258  AC_SUBST(PYLDNSINST, "install-pyldns")dnl
259  AC_SUBST(PYLDNSUNINST, "uninstall-pyldns")
260else
261  AC_SUBST(PYLDNSINST, "")dnl
262  AC_SUBST(PYLDNSUNINST, "")
263fi
264if test x_$ldns_with_pyldnsx != x_no; then
265  AC_SUBST(PYLDNSXINST, "install-pyldnsx")dnl
266  AC_SUBST(PYLDNSXUNINST, "uninstall-pyldnsx")
267else
268  AC_SUBST(PYLDNSXINST, "")dnl
269  AC_SUBST(PYLDNSXUNINST, "")
270fi
271
272# check for perl
273ldns_with_p5_dns_ldns=no
274AC_ARG_WITH(p5-dns-ldns, AC_HELP_STRING([--with-p5-dns-ldns],
275 [generate DNS::LDNS perl bindings]),
276 [],[ withval="no" ])
277ldns_have_perl=no
278if 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")
288else
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, "")
294fi
295
296# Use libtool
297ACX_LIBTOOL_C_ONLY
298
299tmp_CPPFLAGS=$CPPFLAGS
300tmp_LDFLAGS=$LDFLAGS
301tmp_LIBS=$LIBS
302
303ACX_WITH_SSL_OPTIONAL
304
305AC_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
312AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
313case "$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        ;;
326esac
327
328AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
329case "$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        ;;
341esac
342
343AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
344case "$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      ;;
359esac
360
361AC_ARG_ENABLE(dane, AC_HELP_STRING([--disable-dane], [Disable DANE support]))
362case "$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      ;;
374esac
375
376AC_ARG_ENABLE(rrtype-ninfo, AC_HELP_STRING([--enable-rrtype-ninfo], [Enable draft RR type ninfo.]))
377case "$enable_rrtype_ninfo" in
378	yes)
379		AC_DEFINE_UNQUOTED([RRTYPE_NINFO], [], [Define this to enable RR type NINFO.])
380		;;
381	no|*)
382		;;
383esac
384AC_ARG_ENABLE(rrtype-rkey, AC_HELP_STRING([--enable-rrtype-rkey], [Enable draft RR type rkey.]))
385case "$enable_rrtype_rkey" in
386	yes)
387		AC_DEFINE_UNQUOTED([RRTYPE_RKEY], [], [Define this to enable RR type RKEY.])
388		;;
389	no|*)
390		;;
391esac
392AC_ARG_ENABLE(rrtype-cds, AC_HELP_STRING([--enable-rrtype-cds], [Enable draft RR type cds.]))
393case "$enable_rrtype_cds" in
394	yes)
395		AC_DEFINE_UNQUOTED([RRTYPE_CDS], [], [Define this to enable RR type CDS.])
396		;;
397	no|*)
398		;;
399esac
400AC_ARG_ENABLE(rrtype-uri, AC_HELP_STRING([--enable-rrtype-uri], [Enable draft RR type uri.]))
401case "$enable_rrtype_uri" in
402	yes)
403		AC_DEFINE_UNQUOTED([RRTYPE_URI], [], [Define this to enable RR type URI.])
404		;;
405	no|*)
406		;;
407esac
408AC_ARG_ENABLE(rrtype-ta, AC_HELP_STRING([--enable-rrtype-ta], [Enable draft RR type ta.]))
409case "$enable_rrtype_ta" in
410	yes)
411		AC_DEFINE_UNQUOTED([RRTYPE_TA], [], [Define this to enable RR type TA.])
412		;;
413	no|*)
414		;;
415esac
416
417AC_SUBST(LIBSSL_CPPFLAGS)
418AC_SUBST(LIBSSL_LDFLAGS)
419AC_SUBST(LIBSSL_LIBS)
420if test "x$HAVE_SSL" = "xyes"; then
421AC_SUBST(LIBSSL_SSL_LIBS, ["-lssl $LIBSSL_LIBS"])
422fi
423CPPFLAGS=$tmp_CPPFLAGS
424LDFLAGS=$tmp_LDFLAGS
425LIBS=$tmp_LIBS
426
427
428# add option to disable the evil rpath
429ACX_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
447AC_C_BIGENDIAN
448
449# Checks for header files.
450AC_HEADER_STDC
451AC_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
455AC_CHECK_HEADERS([getopt.h stdarg.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
456AC_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])
464AC_CHECK_HEADER(sys/socket.h,
465[
466include_sys_socket_h='#include <sys/socket.h>'
467AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [define if you have sys/socket.h])
468],[
469include_sys_socket_h=''
470],[AC_INCLUDES_DEFAULT
471  [
472   #if HAVE_SYS_PARAM_H
473   # include <sys/param.h>
474   #endif
475  ]
476])
477AC_SUBST(include_sys_socket_h)
478AC_CHECK_HEADER(inttypes.h,
479[
480include_inttypes_h='#include <inttypes.h>'
481AC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
482AC_SUBST(ldns_build_config_have_inttypes_h, 1)
483],[
484include_inttypes_h=''
485AC_SUBST(ldns_build_config_have_inttypes_h, 0)
486],[AC_INCLUDES_DEFAULT
487])
488AC_SUBST(include_inttypes_h)
489AC_CHECK_HEADER(sys/types.h,
490[
491include_systypes_h='#include <sys/types.h>'
492AC_DEFINE(HAVE_SYS_TYPES_H, 1, [define if you have sys/types.h])
493],[
494include_systypes_h=''
495],[AC_INCLUDES_DEFAULT
496])
497AC_SUBST(include_systypes_h)
498AC_CHECK_HEADER(unistd.h,
499[
500include_unistd_h='#include <unistd.h>'
501AC_DEFINE(HAVE_UNISTD_H, 1, [define if you have unistd.h])
502],[
503include_unistd_h=''
504],[AC_INCLUDES_DEFAULT
505])
506AC_SUBST(include_unistd_h)
507
508AC_CHECK_SIZEOF(time_t,,[
509AC_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
522if test x_$with_examples != x_no; then
523AC_CHECK_HEADERS([pcap.h],,, [AC_INCLUDES_DEFAULT])
524AC_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)
532AC_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],,, [
533AC_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])
546fi
547
548ACX_TYPE_SOCKLEN_T
549if test "x$ac_cv_type_socklen_t" = xyes; then
550  AC_SUBST(ldns_build_config_have_socklen_t, 1)
551else
552  AC_SUBST(ldns_build_config_have_socklen_t, 0)
553fi
554AC_TYPE_SIZE_T
555AC_CHECK_TYPE(ssize_t, int)
556dnl AC_TYPE_INTPTR_T does not work on all platforms (autoconf)
557AC_CHECK_TYPE(intptr_t, size_t)
558AC_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])
565AC_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])
572ACX_CHECK_SS_FAMILY
573
574AC_FUNC_MALLOC
575AC_FUNC_REALLOC
576
577AC_REPLACE_FUNCS(b64_pton)
578AC_REPLACE_FUNCS(b64_ntop)
579AC_REPLACE_FUNCS(calloc)
580AC_REPLACE_FUNCS(timegm)
581AC_REPLACE_FUNCS(gmtime_r)
582AC_REPLACE_FUNCS(ctime_r)
583AC_REPLACE_FUNCS(localtime_r)
584AC_REPLACE_FUNCS(isblank)
585AC_REPLACE_FUNCS(isascii)
586AC_REPLACE_FUNCS(inet_aton)
587AC_REPLACE_FUNCS(inet_pton)
588AC_REPLACE_FUNCS(inet_ntop)
589AC_REPLACE_FUNCS(snprintf)
590AC_REPLACE_FUNCS(strlcpy)
591AC_REPLACE_FUNCS(memmove)
592AC_FUNC_FORK
593AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset b32_ntop b32_pton])
594if test "x$HAVE_B32_NTOP" = "xyes"; then
595	AC_SUBST(ldns_build_config_have_b32_ntop, 1)
596else
597	AC_SUBST(ldns_build_config_have_b32_ntop, 0)
598fi
599if test "x$HAVE_B32_PTON" = "xyes"; then
600	AC_SUBST(ldns_build_config_have_b32_pton, 1)
601else
602	AC_SUBST(ldns_build_config_have_b32_pton, 0)
603fi
604
605ACX_CHECK_GETADDRINFO_WITH_INCLUDES
606if test $ac_cv_func_getaddrinfo = no; then
607	AC_LIBOBJ([fake-rfc2553])
608fi
609if test "$USE_WINSOCK" = 1; then
610	AC_CHECK_TOOL(WINDRES, windres)
611fi
612ACX_FUNC_IOCTLSOCKET
613
614#AC_SEARCH_LIBS(RSA_new, [crypto])
615
616ACX_CHECK_FORMAT_ATTRIBUTE
617ACX_CHECK_UNUSED_ATTRIBUTE
618
619# check OSX deployment target which is needed
620if echo $build_os | grep darwin > /dev/null; then
621 	export MACOSX_DEPLOYMENT_TARGET="10.4"
622fi
623
624AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
625
626AC_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])
641AC_DEFINE_UNQUOTED([LDNS_TRUST_ANCHOR_FILE], ["$LDNS_TRUST_ANCHOR_FILE"], [Default trust anchor file])
642AC_SUBST(LDNS_TRUST_ANCHOR_FILE)
643AC_MSG_NOTICE([Default trust anchor: $LDNS_TRUST_ANCHOR_FILE])
644
645AC_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
655AC_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
665AH_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]
716AHX_CONFIG_W32_FD_SET_T
717)
718
719AH_BOTTOM([
720#ifdef __cplusplus
721extern "C" {
722#endif
723
724int 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@*/
730static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
731{
732	return ((((srcsize + 2) / 3) * 4) + 1);
733}
734int 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@*/
739static 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 */
748int 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>
762time_t timegm (struct tm *tm);
763#endif /* !TIMEGM */
764#ifndef HAVE_GMTIME_R
765struct tm *gmtime_r(const time_t *timep, struct tm *result);
766#endif
767#ifndef HAVE_LOCALTIME_R
768struct tm *localtime_r(const time_t *timep, struct tm *result);
769#endif
770#ifndef HAVE_ISBLANK
771int isblank(int c);
772#endif /* !HAVE_ISBLANK */
773#ifndef HAVE_ISASCII
774int isascii(int c);
775#endif /* !HAVE_ISASCII */
776#ifndef HAVE_SNPRINTF
777#include <stdarg.h>
778int snprintf (char *str, size_t count, const char *fmt, ...);
779int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
780#endif /* HAVE_SNPRINTF */
781#ifndef HAVE_INET_PTON
782int inet_pton(int af, const char* src, void* dst);
783#endif /* HAVE_INET_PTON */
784#ifndef HAVE_INET_NTOP
785const char *inet_ntop(int af, const void *src, char *dst, size_t size);
786#endif
787#ifndef HAVE_INET_ATON
788int inet_aton(const char *cp, struct in_addr *addr);
789#endif
790#ifndef HAVE_MEMMOVE
791void *memmove(void *dest, const void *src, size_t n);
792#endif
793#ifndef HAVE_STRLCPY
794size_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
807if test "x$HAVE_SSL" = "xyes"; then
808	AC_SUBST(ldns_build_config_have_ssl, 1)
809else
810	AC_SUBST(ldns_build_config_have_ssl, 0)
811fi
812if test "x$ac_cv_c_format_attribute" = "xyes"; then
813  AC_SUBST(ldns_build_config_have_attr_format, 1)
814else
815  AC_SUBST(ldns_build_config_have_attr_format, 0)
816fi
817if test "x$ac_cv_c_unused_attribute" = "xyes"; then
818  AC_SUBST(ldns_build_config_have_attr_unused, 1)
819else
820  AC_SUBST(ldns_build_config_have_attr_unused, 0)
821fi
822
823CONFIG_FILES="Makefile ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config $DRILL_CONFIG $EXAMPLES_CONFIG"
824AC_SUBST(CONFIG_FILES)
825AC_CONFIG_FILES([$CONFIG_FILES])
826
827AC_CONFIG_HEADER([ldns/config.h])
828AC_OUTPUT
829COPY_HEADER_FILES(ldns/, ldns/)
830
831dnl AC_CONFIG_SUBDIRS([drill])
832
833
834