configure.ac revision 238104
1238104Sdes#                                               -*- Autoconf -*-
2238104Sdes# Process this file with autoconf to produce a configure script.
3238104SdesAC_PREREQ(2.56)
4238104Sdessinclude(acx_nlnetlabs.m4)
5238104Sdes
6238104Sdes# must be numbers. ac_defun because of later processing.
7238104Sdesm4_define([VERSION_MAJOR],[1])
8238104Sdesm4_define([VERSION_MINOR],[6])
9238104Sdesm4_define([VERSION_MICRO],[13])
10238104SdesAC_INIT(ldns, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), libdns@nlnetlabs.nl, libdns)
11238104SdesAC_CONFIG_SRCDIR([packet.c])
12238104Sdes# needed to build correct soname
13238104SdesAC_SUBST(LIBTOOL_VERSION_INFO, VERSION_MAJOR:VERSION_MINOR:VERSION_MICRO)
14238104SdesAC_SUBST(LDNS_VERSION_MAJOR, [VERSION_MAJOR])
15238104SdesAC_SUBST(LDNS_VERSION_MINOR, [VERSION_MINOR])
16238104SdesAC_SUBST(LDNS_VERSION_MICRO, [VERSION_MICRO])
17238104Sdes
18238104SdesOURCPPFLAGS=''
19238104SdesCPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
20238104SdesCFLAGS="$CFLAGS"
21238104Sdes
22238104SdesAC_AIX
23238104Sdes# Checks for programs.
24238104SdesAC_PROG_CC
25238104SdesACX_DEPFLAG
26238104SdesAC_PROG_MAKE_SET
27238104Sdes
28238104Sdes# Extra (sp)lint flags for NetBSD
29238104SdesAC_CANONICAL_HOST
30238104Sdescase "$host_os" in
31238104Sdes	netbsd*) LINTFLAGS="'-D__RENAME(x)=' -D_NETINET_IN_H_ $LINTFLAGS" 
32238104Sdes		 ;;
33238104Sdes	*)       LINTFLAGS="$LINTFLAGS"
34238104Sdes		 ;;
35238104Sdesesac
36238104SdesAC_SUBST(LINTFLAGS)
37238104Sdes
38238104SdesAC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
39238104Sdes
40238104SdesACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
41238104SdesACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
42238104Sdes
43238104Sdes# routine to copy files
44238104Sdes# argument 1 is a list of files (relative to the source dir)
45238104Sdes# argument 2 is a destination directory (relative to the current
46238104Sdes# working directory
47238104SdesAC_DEFUN([COPY_FILES],
48238104Sdes[
49238104Sdesfor file in $1; do
50238104Sdes	sh $srcdir/install-sh -m 644 $file $2
51238104Sdesdone
52238104Sdes])
53238104Sdes
54238104Sdes# copy all .h files in the dir at argument 1
55238104Sdes# (relative to source) to the dir at argument 2
56238104Sdes# (relative to current dir)
57238104SdesAC_DEFUN([COPY_HEADER_FILES],
58238104Sdes[
59238104Sdesecho "copying header files"
60238104SdesCOPY_FILES($srcdir/$1/*.h, $2)
61238104Sdes])
62238104Sdes
63238104Sdes# Checks for typedefs, structures, and compiler characteristics.
64238104SdesAC_C_CONST
65238104SdesAC_LANG_C
66238104SdesACX_CHECK_COMPILER_FLAG(g, [CFLAGS="-g $CFLAGS"])
67238104SdesACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="-O2 $CFLAGS"])
68238104SdesACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
69238104SdesACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
70238104SdesACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
71238104Sdes
72238104Sdes
73238104SdesAC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
74238104Sdes
75238104Sdes# MinGW32 tests
76238104SdesAC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
77238104Sdes# end mingw32 tests
78238104Sdes
79238104SdesACX_DETERMINE_EXT_FLAGS_UNBOUND
80238104Sdes
81238104SdesAC_C_INLINE
82238104SdesAC_CHECK_TYPE(int8_t, char)
83238104SdesAC_CHECK_TYPE(int16_t, short)
84238104SdesAC_CHECK_TYPE(int32_t, int)
85238104SdesAC_CHECK_TYPE(int64_t, long long)
86238104SdesAC_CHECK_TYPE(uint8_t, unsigned char)
87238104SdesAC_CHECK_TYPE(uint16_t, unsigned short)
88238104SdesAC_CHECK_TYPE(uint32_t, unsigned int)
89238104SdesAC_CHECK_TYPE(uint64_t, unsigned long long)
90238104Sdes
91238104Sdes# my own checks
92238104SdesAC_CHECK_PROG(doxygen, doxygen, doxygen)
93238104Sdes
94238104Sdes# check to see if libraries are needed for these functions.
95238104SdesAC_SEARCH_LIBS([socket], [socket])
96238104SdesAC_SEARCH_LIBS([inet_pton], [nsl])
97238104Sdes
98238104Sdes
99238104SdesAC_ARG_WITH(drill, AC_HELP_STRING([--with-drill], 
100238104Sdes [Also build drill.]), 
101238104Sdes [],[with_drill="no"])
102238104Sdesif test x_$with_drill != x_no ; then
103238104Sdes	AC_SUBST(DRILL,[drill])
104238104Sdes	AC_SUBST(INSTALL_DRILL,[install-drill])
105238104Sdes	AC_SUBST(UNINSTALL_DRILL,[uninstall-drill])
106238104Sdes	AC_SUBST(CLEAN_DRILL,[clean-drill])
107238104Sdes	AC_SUBST(LINT_DRILL,[lint-drill])
108238104Sdes	if test -e $srcdir/drill/config.h -o -e drill/config.h ; then
109238104Sdes		AC_MSG_ERROR([
110238104SdesA config.h was detected in the drill subdirectory.
111238104SdesThis does not work with the --with-drill option.
112238104SdesPlease remove the config.h from the drill subdirectory 
113238104Sdesor do not use the --with-drill option.])
114238104Sdes	fi
115238104Sdeselse
116238104Sdes	AC_SUBST(DRILL,[""])
117238104Sdes	AC_SUBST(INSTALL_DRILL,[""])
118238104Sdes	AC_SUBST(UNINSTALL_DRILL,[""])
119238104Sdes	AC_SUBST(CLEAN_DRILL,[""])
120238104Sdes	AC_SUBST(LINT_DRILL,[""])
121238104Sdesfi
122238104Sdes
123238104Sdes
124238104SdesAC_ARG_WITH(examples, AC_HELP_STRING([--with-examples], 
125238104Sdes [Also build examples.]), 
126238104Sdes [],[with_examples="no"])
127238104Sdesif test x_$with_examples != x_no ; then
128238104Sdes	AC_SUBST(EXAMPLES,[examples])
129238104Sdes	AC_SUBST(INSTALL_EXAMPLES,[install-examples])
130238104Sdes	AC_SUBST(UNINSTALL_EXAMPLES,[uninstall-examples])
131238104Sdes	AC_SUBST(CLEAN_EXAMPLES,[clean-examples])
132238104Sdes	AC_SUBST(LINT_EXAMPLES,[lint-examples])
133238104Sdes	if test -e $srcdir/examples/config.h -o -e examples/config.h ; then
134238104Sdes		AC_MSG_ERROR([
135238104SdesA config.h was detected in the examples subdirectory.
136238104SdesThis does not work with the --with-examples option.
137238104SdesPlease remove the config.h from the examples subdirectory 
138238104Sdesor do not use the --with-examples option.])
139238104Sdes	fi
140238104Sdeselse
141238104Sdes	AC_SUBST(EXAMPLES,[""])
142238104Sdes	AC_SUBST(INSTALL_EXAMPLES,[""])
143238104Sdes	AC_SUBST(UNINSTALL_EXAMPLES,[""])
144238104Sdes	AC_SUBST(CLEAN_EXAMPLES,[""])
145238104Sdes	AC_SUBST(LINT_EXAMPLES,[""])
146238104Sdesfi
147238104Sdes
148238104Sdes# add option to disable installation of ldns-config script
149238104SdesAC_ARG_ENABLE(ldns-config, [ --disable-ldns-config	disable installation of ldns-config (default=enabled)],
150238104Sdes	enable_ldns_config=$enableval, enable_ldns_config=yes)
151238104Sdesif test "x$enable_ldns_config" = xyes; then
152238104Sdes	AC_SUBST(INSTALL_CONFIG, [install-config])
153238104Sdes	AC_SUBST(INSTALL_CONFIG_MANPAGE, [install-config-manpage])
154238104Sdes	AC_SUBST(UNINSTALL_CONFIG, [uninstall-config])
155238104Sdes	AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [uninstall-config-manpage])
156238104Sdeselse
157238104Sdes	AC_SUBST(INSTALL_CONFIG, [""])
158238104Sdes	AC_SUBST(INSTALL_CONFIG_MANPAGE, [""])
159238104Sdes	AC_SUBST(UNINSTALL_CONFIG, [""])
160238104Sdes	AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [""])
161238104Sdesfi
162238104Sdes
163238104Sdes# check for python
164238104SdesPYTHON_X_CFLAGS=""
165238104Sdesldns_with_pyldns=no
166238104Sdesldns_with_pyldnsx=no
167238104SdesAC_ARG_WITH(pyldns, AC_HELP_STRING([--with-pyldns], 
168238104Sdes [generate python library, or --without-pyldns to disable Python support.]), 
169238104Sdes [],[ withval="no" ])
170238104Sdesldns_have_python=no
171238104Sdesif test x_$withval != x_no; then
172238104Sdes   sinclude(ax_python_devel.m4)
173238104Sdes   ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
174238104Sdes
175238104Sdes   AX_PYTHON_DEVEL([>= '2.4.0'])
176238104Sdes   if test ! -z "$ac_python_version"; then
177238104Sdes	ldns_have_python=yes
178238104Sdes   fi
179238104Sdes
180238104Sdes   # pass additional Python 3 option to SWIG
181238104Sdes   if test `$PYTHON -c "import sys; \
182238104Sdes       ver = sys.version.split()[[0]]; \
183238104Sdes       print(ver >= '3')"` = "True"; then
184238104Sdes       AC_SUBST(SWIGPY3, ["-py3 -DPY3"])
185238104Sdes   fi
186238104Sdes
187238104Sdes   # check for SWIG
188238104Sdes   if test x_$ldns_have_python != x_no; then
189238104Sdes        sinclude(ax_pkg_swig.m4)
190238104Sdes
191238104Sdes        # check for >=SWIG-2.0.4 if Python 3.2 used
192238104Sdes        if test `$PYTHON -c "import sys; \
193238104Sdes            ver = sys.version.split()[[0]]; \
194238104Sdes            print(ver >= '3.2')"` = "True"; then
195238104Sdes            AX_PKG_SWIG(2.0.4, [], [AC_MSG_ERROR([SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater.])])
196238104Sdes        else
197238104Sdes            AX_PKG_SWIG
198238104Sdes        fi
199238104Sdes
200238104Sdes	if test ! -x "$SWIG"; then
201238104Sdes		AC_MSG_ERROR([failed to find SWIG tool, install it, or do not build pyldns])
202238104Sdes	else
203238104Sdes		AC_DEFINE(HAVE_SWIG,1,[Define if you have SWIG libraries and header files.])
204238104Sdes		AC_SUBST(PYLDNS, "pyldns")
205238104Sdes		AC_SUBST(swig, "$SWIG")
206238104Sdes		ldns_with_pyldns=yes
207238104Sdes	fi
208238104Sdes   else
209238104Sdes	AC_MSG_RESULT([*** don't have Python, skipping SWIG, no pyldns ***]) # '
210238104Sdes   fi
211238104Sdes
212238104Sdes   # xtra cflags for pyldns
213238104Sdes   if test x_$ldns_have_python != x_no; then
214238104Sdes	ACX_CHECK_COMPILER_FLAG(fno-strict-aliasing, [PYTHON_X_CFLAGS="-fno-strict-aliasing"])
215238104Sdes	ACX_CHECK_COMPILER_FLAG(Wno-missing-field-initializers, [PYTHON_X_CFLAGS="-Wno-missing-field-initializers $PYTHON_X_CFLAGS"])
216238104Sdes	ACX_CHECK_COMPILER_FLAG(Wno-unused-parameter, [PYTHON_X_CFLAGS="-Wno-unused-parameter $PYTHON_X_CFLAGS"])
217238104Sdes	ACX_CHECK_COMPILER_FLAG(Wno-unused-variable, [PYTHON_X_CFLAGS="-Wno-unused-variable $PYTHON_X_CFLAGS"])
218238104Sdes   fi
219238104Sdesfi
220238104SdesAC_SUBST(PYTHON_X_CFLAGS)
221238104Sdes
222238104Sdes# Check for pyldnsx
223238104SdesAC_ARG_WITH(pyldnsx, AC_HELP_STRING([--without-pyldnsx], 
224238104Sdes  [Do not install the ldnsx python module, or --with-pyldnsx to install it.]), 
225238104Sdes  [],[ withval="with_pyldns" ])
226238104Sdesif test x_$withval != x_no; then
227238104Sdes  if test x_$ldns_with_pyldns != x_no; then
228238104Sdes    AC_SUBST(PYLDNSX, "pyldnsx")
229238104Sdes    ldns_with_pyldnsx=yes
230238104Sdes  else
231238104Sdes    if test x_$withval != x_with_pyldns; then
232238104Sdes      AC_MSG_ERROR([--with-pyldns is needed for the ldnsx python module])
233238104Sdes    fi
234238104Sdes  fi
235238104Sdesfi
236238104Sdes
237238104Sdesif test x_$ldns_with_pyldns != x_no; then
238238104Sdes  AC_SUBST(PYLDNSINST, "install-pyldns")dnl
239238104Sdes  AC_SUBST(PYLDNSUNINST, "uninstall-pyldns")
240238104Sdeselse
241238104Sdes  AC_SUBST(PYLDNSINST, "")dnl
242238104Sdes  AC_SUBST(PYLDNSUNINST, "")
243238104Sdesfi
244238104Sdesif test x_$ldns_with_pyldnsx != x_no; then
245238104Sdes  AC_SUBST(PYLDNSXINST, "install-pyldnsx")dnl
246238104Sdes  AC_SUBST(PYLDNSXUNINST, "uninstall-pyldnsx")
247238104Sdeselse
248238104Sdes  AC_SUBST(PYLDNSXINST, "")dnl
249238104Sdes  AC_SUBST(PYLDNSXUNINST, "")
250238104Sdesfi
251238104Sdes
252238104Sdes
253238104Sdes# Use libtool
254238104SdesACX_LIBTOOL_C_ONLY
255238104Sdes
256238104Sdestmp_CPPFLAGS=$CPPFLAGS
257238104Sdestmp_LDFLAGS=$LDFLAGS
258238104Sdestmp_LIBS=$LIBS
259238104Sdes
260238104SdesACX_WITH_SSL_OPTIONAL
261238104Sdes
262238104SdesAC_CHECK_FUNCS([EVP_sha256])
263238104Sdes
264238104Sdes# for macosx, see if glibtool exists and use that
265238104Sdes# BSD's need to know the version...
266238104Sdes#AC_CHECK_PROG(glibtool, glibtool, [glibtool], )
267238104Sdes#AC_CHECK_PROGS(libtool, [libtool15 libtool], [./libtool])
268238104Sdes
269238104SdesAC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
270238104Sdescase "$enable_sha2" in
271238104Sdes    no)
272238104Sdes        ;;
273238104Sdes    yes|*)
274238104Sdes        if test "x$HAVE_SSL" != "xyes"; then
275238104Sdes            AC_MSG_ERROR([SHA2 enabled, but no SSL support])
276238104Sdes        fi
277238104Sdes	AC_MSG_CHECKING(for SHA256 and SHA512)
278238104Sdes	AC_CHECK_FUNC(SHA256_Init, [], [
279238104Sdes		AC_MSG_ERROR([No SHA2 functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-sha2])
280238104Sdes		])
281238104Sdes	AC_DEFINE_UNQUOTED([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
282238104Sdes        ;;
283238104Sdesesac
284238104Sdes
285238104SdesAC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
286238104Sdescase "$enable_gost" in
287238104Sdes    no)
288238104Sdes        ;;
289238104Sdes    *)  dnl default
290238104Sdes        if test "x$HAVE_SSL" != "xyes"; then
291238104Sdes            AC_MSG_ERROR([GOST enabled, but no SSL support])
292238104Sdes        fi
293238104Sdes        AC_MSG_CHECKING(for GOST)
294238104Sdes        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])])
295238104Sdes        AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([No ECC functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-gost])])
296238104Sdes        AC_DEFINE_UNQUOTED([USE_GOST], [1], [Define this to enable GOST support.])
297238104Sdes        ;;
298238104Sdesesac
299238104Sdes
300238104SdesAC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
301238104Sdescase "$enable_ecdsa" in
302238104Sdes    no)
303238104Sdes      ;;
304238104Sdes    *) dnl default
305238104Sdes      if test "x$HAVE_SSL" != "xyes"; then
306238104Sdes        AC_MSG_ERROR([ECDSA enabled, but no SSL support])
307238104Sdes      fi
308238104Sdes      AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade OpenSSL or rerun with --disable-ecdsa])])
309238104Sdes      AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade OpenSSL or rerun with --disable-ecdsa])])
310238104Sdes      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
311238104Sdes#include <openssl/evp.h>
312238104Sdes      ])
313238104Sdes      # we now know we have ECDSA and the required curves.
314238104Sdes      AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
315238104Sdes      ;;
316238104Sdesesac
317238104Sdes
318238104SdesAC_SUBST(LIBSSL_CPPFLAGS)
319238104SdesAC_SUBST(LIBSSL_LDFLAGS)
320238104SdesAC_SUBST(LIBSSL_LIBS)
321238104SdesCPPFLAGS=$tmp_CPPFLAGS
322238104SdesLDFLAGS=$tmp_LDFLAGS
323238104SdesLIBS=$tmp_LIBS
324238104Sdes
325238104Sdes
326238104Sdes# add option to disable the evil rpath
327238104SdesACX_ARG_RPATH
328238104Sdes
329238104Sdes#AC_RUN_IFELSE([AC_LANG_SOURCE(
330238104Sdes#[
331238104Sdes#int main()
332238104Sdes#{
333238104Sdes#short one = 1;
334238104Sdes#char *cp = (char*)&one;
335238104Sdes#if ( *cp == 0 )
336238104Sdes#return(0);
337238104Sdes#else
338238104Sdes#return(1);
339238104Sdes#}
340238104Sdes#])], [],[
341238104Sdes#AC_DEFINE(CONFCHECK_LITTLE_ENDIAN, 1, [system appears to be little-endian])
342238104Sdes#],[])
343238104Sdes
344238104Sdes# should define WORDS_BIGENDIAN if the system is big-endian
345238104SdesAC_C_BIGENDIAN
346238104Sdes
347238104Sdes# Checks for header files.
348238104SdesAC_HEADER_STDC
349238104SdesAC_HEADER_STDBOOL
350238104Sdes#AC_HEADER_SYS_WAIT
351238104Sdes#AC_CHECK_HEADERS([getopt.h fcntl.h stdlib.h string.h strings.h unistd.h])
352238104Sdes# do the very minimum - we can always extend this
353238104SdesAC_CHECK_HEADERS([getopt.h stdarg.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
354238104SdesAC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
355238104Sdes[AC_INCLUDES_DEFAULT
356238104Sdes  [
357238104Sdes   #if HAVE_SYS_PARAM_H
358238104Sdes   # include <sys/param.h>
359238104Sdes   #endif
360238104Sdes  ]
361238104Sdes])
362238104SdesAC_CHECK_HEADER(sys/socket.h,
363238104Sdes[
364238104Sdesinclude_sys_socket_h='#include <sys/socket.h>'
365238104SdesAC_DEFINE(HAVE_SYS_SOCKET_H, 1, [define if you have sys/socket.h])
366238104Sdes],[
367238104Sdesinclude_sys_socket_h=''
368238104Sdes],[AC_INCLUDES_DEFAULT
369238104Sdes  [
370238104Sdes   #if HAVE_SYS_PARAM_H
371238104Sdes   # include <sys/param.h>
372238104Sdes   #endif
373238104Sdes  ]
374238104Sdes])
375238104SdesAC_SUBST(include_sys_socket_h)
376238104SdesAC_CHECK_HEADER(inttypes.h,
377238104Sdes[
378238104Sdesinclude_inttypes_h='#include <inttypes.h>'
379238104SdesAC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
380238104SdesAC_SUBST(ldns_build_config_have_inttypes_h, 1)
381238104Sdes],[
382238104Sdesinclude_inttypes_h=''
383238104SdesAC_SUBST(ldns_build_config_have_inttypes_h, 0)
384238104Sdes],[AC_INCLUDES_DEFAULT
385238104Sdes])
386238104SdesAC_SUBST(include_inttypes_h)
387238104SdesAC_CHECK_HEADER(sys/types.h,
388238104Sdes[
389238104Sdesinclude_systypes_h='#include <sys/types.h>'
390238104SdesAC_DEFINE(HAVE_SYS_TYPES_H, 1, [define if you have sys/types.h])
391238104Sdes],[
392238104Sdesinclude_systypes_h=''
393238104Sdes],[AC_INCLUDES_DEFAULT
394238104Sdes])
395238104SdesAC_SUBST(include_systypes_h)
396238104SdesAC_CHECK_HEADER(unistd.h,
397238104Sdes[
398238104Sdesinclude_unistd_h='#include <unistd.h>'
399238104SdesAC_DEFINE(HAVE_UNISTD_H, 1, [define if you have unistd.h])
400238104Sdes],[
401238104Sdesinclude_unistd_h=''
402238104Sdes],[AC_INCLUDES_DEFAULT
403238104Sdes])
404238104SdesAC_SUBST(include_unistd_h)
405238104Sdes
406238104SdesAC_CHECK_SIZEOF(time_t,,[
407238104SdesAC_INCLUDES_DEFAULT
408238104Sdes#ifdef TIME_WITH_SYS_TIME
409238104Sdes# include <sys/time.h>
410238104Sdes# include <time.h>
411238104Sdes#else
412238104Sdes# ifdef HAVE_SYS_TIME_H
413238104Sdes#  include <sys/time.h>
414238104Sdes# else
415238104Sdes#  include <time.h>
416238104Sdes# endif
417238104Sdes#endif
418238104Sdes])
419238104Sdes
420238104Sdesif test x_$with_examples != x_no; then
421238104SdesAC_CHECK_HEADERS([pcap.h],, [AC_INCLUDES_DEFAULT])
422238104SdesAC_CHECK_LIB(pcap, pcap_open_offline, [
423238104Sdes	AC_DEFINE([HAVE_LIBPCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap).])dnl`
424238104Sdes	AC_SUBST([LIBPCAP_LIBS], [-lpcap])
425238104Sdes    ], [
426238104Sdes	AC_MSG_WARN([Can't find pcap library (needed for ldns-dpa, will not build dpa now.)])dnl'
427238104Sdes	AC_SUBST([LIBPCAP_LIBS], [])
428238104Sdes    ]
429238104Sdes)
430238104SdesAC_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],,, [
431238104SdesAC_INCLUDES_DEFAULT 
432238104Sdes#ifdef HAVE_NETINET_IN_SYSTM_H
433238104Sdes#include <netinet/in_systm.h>
434238104Sdes#endif
435238104Sdes#ifdef HAVE_NETINET_IN_H
436238104Sdes#include <netinet/in.h>
437238104Sdes#endif
438238104Sdes#ifdef HAVE_SYS_SOCKET_H
439238104Sdes#include <sys/socket.h>
440238104Sdes#endif
441238104Sdes#ifdef HAVE_NET_IF_H
442238104Sdes#include <net/if.h>
443238104Sdes#endif])
444238104Sdesfi
445238104Sdes
446238104SdesACX_TYPE_SOCKLEN_T
447238104SdesAC_TYPE_SIZE_T
448238104SdesAC_TYPE_SSIZE_T
449238104SdesAC_TYPE_INTPTR_T
450238104SdesAC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
451238104Sdes#if HAVE_SYS_TYPES_H
452238104Sdes# include <sys/types.h>
453238104Sdes#endif
454238104Sdes#if HAVE_NETINET_IN_H
455238104Sdes# include <netinet/in.h>
456238104Sdes#endif])
457238104SdesAC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
458238104Sdes#if HAVE_SYS_TYPES_H
459238104Sdes# include <sys/types.h>
460238104Sdes#endif
461238104Sdes#if HAVE_NETINET_IN_H
462238104Sdes# include <netinet/in.h>
463238104Sdes#endif])
464238104SdesACX_CHECK_SS_FAMILY
465238104Sdes
466238104SdesAC_FUNC_MALLOC
467238104SdesAC_FUNC_REALLOC
468238104Sdes
469238104SdesAC_REPLACE_FUNCS(b64_pton)
470238104SdesAC_REPLACE_FUNCS(b64_ntop)
471238104SdesAC_REPLACE_FUNCS(b32_pton)
472238104SdesAC_REPLACE_FUNCS(b32_ntop)
473238104SdesAC_REPLACE_FUNCS(calloc)
474238104SdesAC_REPLACE_FUNCS(timegm)
475238104SdesAC_REPLACE_FUNCS(gmtime_r)
476238104SdesAC_REPLACE_FUNCS(ctime_r)
477238104SdesAC_REPLACE_FUNCS(localtime_r)
478238104SdesAC_REPLACE_FUNCS(isblank)
479238104SdesAC_REPLACE_FUNCS(isascii)
480238104SdesAC_REPLACE_FUNCS(inet_aton)
481238104SdesAC_REPLACE_FUNCS(inet_pton)
482238104SdesAC_REPLACE_FUNCS(inet_ntop)
483238104SdesAC_REPLACE_FUNCS(snprintf)
484238104SdesAC_REPLACE_FUNCS(strlcpy)
485238104SdesAC_REPLACE_FUNCS(memmove)
486238104SdesAC_FUNC_FORK
487238104SdesAC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset])
488238104Sdes
489238104SdesACX_CHECK_GETADDRINFO_WITH_INCLUDES
490238104Sdesif test $ac_cv_func_getaddrinfo = no; then
491238104Sdes	AC_LIBOBJ([fake-rfc2553])
492238104Sdesfi
493238104Sdesif test "$USE_WINSOCK" = 1; then
494238104Sdes	AC_CHECK_TOOL(WINDRES, windres)
495238104Sdesfi
496238104SdesACX_FUNC_IOCTLSOCKET
497238104Sdes
498238104Sdes#AC_SEARCH_LIBS(RSA_new, [crypto])
499238104Sdes
500238104SdesACX_CHECK_FORMAT_ATTRIBUTE
501238104SdesACX_CHECK_UNUSED_ATTRIBUTE
502238104Sdes
503238104Sdes# check OSX deployment target which is needed
504238104Sdesif echo $build_os | grep darwin > /dev/null; then
505238104Sdes 	export MACOSX_DEPLOYMENT_TARGET="10.4"
506238104Sdesfi
507238104Sdes
508238104SdesAC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
509238104Sdes
510238104SdesAH_BOTTOM([
511238104Sdes#include <stdio.h>
512238104Sdes#include <string.h>
513238104Sdes#include <unistd.h>
514238104Sdes#include <assert.h>
515238104Sdes
516238104Sdes#ifndef LITTLE_ENDIAN
517238104Sdes#define LITTLE_ENDIAN 1234
518238104Sdes#endif
519238104Sdes
520238104Sdes#ifndef BIG_ENDIAN
521238104Sdes#define BIG_ENDIAN 4321
522238104Sdes#endif
523238104Sdes
524238104Sdes#ifndef BYTE_ORDER
525238104Sdes#ifdef WORDS_BIGENDIAN
526238104Sdes#define BYTE_ORDER BIG_ENDIAN
527238104Sdes#else
528238104Sdes#define BYTE_ORDER LITTLE_ENDIAN
529238104Sdes#endif /* WORDS_BIGENDIAN */
530238104Sdes#endif /* BYTE_ORDER */
531238104Sdes
532238104Sdes#if STDC_HEADERS
533238104Sdes#include <stdlib.h>
534238104Sdes#include <stddef.h>
535238104Sdes#endif
536238104Sdes
537238104Sdes#ifdef HAVE_STDINT_H
538238104Sdes#include <stdint.h>
539238104Sdes#endif
540238104Sdes
541238104Sdes#ifdef HAVE_SYS_SOCKET_H
542238104Sdes#include <sys/socket.h>
543238104Sdes#endif
544238104Sdes
545238104Sdes#ifdef HAVE_NETINET_IN_H
546238104Sdes#include <netinet/in.h>
547238104Sdes#endif
548238104Sdes
549238104Sdes#ifdef HAVE_ARPA_INET_H
550238104Sdes#include <arpa/inet.h>
551238104Sdes#endif
552238104Sdes
553238104Sdes#ifdef HAVE_WINSOCK2_H
554238104Sdes#include <winsock2.h>
555238104Sdes#endif
556238104Sdes
557238104Sdes#ifdef HAVE_WS2TCPIP_H
558238104Sdes#include <ws2tcpip.h>
559238104Sdes#endif
560238104Sdes]
561238104SdesAHX_CONFIG_W32_FD_SET_T
562238104Sdes)
563238104Sdes
564238104SdesAH_BOTTOM([
565238104Sdes#ifdef __cplusplus
566238104Sdesextern "C" {
567238104Sdes#endif
568238104Sdes
569238104Sdes#ifndef B64_PTON
570238104Sdesint ldns_b64_ntop(uint8_t const *src, size_t srclength,
571238104Sdes	 	  char *target, size_t targsize);
572238104Sdes/**
573238104Sdes * calculates the size needed to store the result of b64_ntop
574238104Sdes */
575238104Sdes/*@unused@*/
576238104Sdesstatic inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
577238104Sdes{
578238104Sdes	return ((((srcsize + 2) / 3) * 4) + 1);
579238104Sdes}
580238104Sdes#endif /* !B64_PTON */
581238104Sdes#ifndef B64_NTOP
582238104Sdesint ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
583238104Sdes/**
584238104Sdes * calculates the size needed to store the result of ldns_b64_pton
585238104Sdes */
586238104Sdes/*@unused@*/
587238104Sdesstatic inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
588238104Sdes{
589238104Sdes	return (((((srcsize + 3) / 4) * 3)) + 1);
590238104Sdes}
591238104Sdes#endif /* !B64_NTOP */
592238104Sdes
593238104Sdes#ifndef HAVE_SLEEP
594238104Sdes/* use windows sleep, in millisecs, instead */
595238104Sdes#define sleep(x) Sleep((x)*1000)
596238104Sdes#endif
597238104Sdes
598238104Sdes#ifndef HAVE_RANDOM
599238104Sdes#define srandom(x) srand(x)
600238104Sdes#define random(x) rand(x)
601238104Sdes#endif
602238104Sdes
603238104Sdes#ifndef HAVE_TIMEGM
604238104Sdes#include <time.h>
605238104Sdestime_t timegm (struct tm *tm);
606238104Sdes#endif /* !TIMEGM */
607238104Sdes#ifndef HAVE_GMTIME_R
608238104Sdesstruct tm *gmtime_r(const time_t *timep, struct tm *result);
609238104Sdes#endif
610238104Sdes#ifndef HAVE_LOCALTIME_R
611238104Sdesstruct tm *localtime_r(const time_t *timep, struct tm *result);
612238104Sdes#endif
613238104Sdes#ifndef HAVE_ISBLANK
614238104Sdesint isblank(int c);
615238104Sdes#endif /* !HAVE_ISBLANK */
616238104Sdes#ifndef HAVE_ISASCII
617238104Sdesint isascii(int c);
618238104Sdes#endif /* !HAVE_ISASCII */
619238104Sdes#ifndef HAVE_SNPRINTF
620238104Sdes#include <stdarg.h>
621238104Sdesint snprintf (char *str, size_t count, const char *fmt, ...);
622238104Sdesint vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
623238104Sdes#endif /* HAVE_SNPRINTF */
624238104Sdes#ifndef HAVE_INET_PTON
625238104Sdesint inet_pton(int af, const char* src, void* dst);
626238104Sdes#endif /* HAVE_INET_PTON */
627238104Sdes#ifndef HAVE_INET_NTOP
628238104Sdesconst char *inet_ntop(int af, const void *src, char *dst, size_t size);
629238104Sdes#endif
630238104Sdes#ifndef HAVE_INET_ATON
631238104Sdesint inet_aton(const char *cp, struct in_addr *addr);
632238104Sdes#endif
633238104Sdes#ifndef HAVE_MEMMOVE
634238104Sdesvoid *memmove(void *dest, const void *src, size_t n);
635238104Sdes#endif
636238104Sdes#ifndef HAVE_STRLCPY
637238104Sdessize_t strlcpy(char *dst, const char *src, size_t siz);
638238104Sdes#endif
639238104Sdes#ifdef __cplusplus
640238104Sdes}
641238104Sdes#endif
642238104Sdes#ifndef HAVE_GETADDRINFO
643238104Sdes#include "compat/fake-rfc2553.h"
644238104Sdes#endif
645238104Sdes#ifndef HAVE_STRTOUL
646238104Sdes#define strtoul (unsigned long)strtol
647238104Sdes#endif
648238104Sdes])
649238104Sdes
650238104Sdesif test "x$HAVE_SSL" = "xyes"; then
651238104Sdes	AC_SUBST(ldns_build_config_have_ssl, 1)
652238104Sdeselse
653238104Sdes	AC_SUBST(ldns_build_config_have_ssl, 0)
654238104Sdesfi
655238104Sdesif test "x$ac_cv_c_format_attribute" = "xyes"; then
656238104Sdes  AC_SUBST(ldns_build_config_have_attr_format, 1)
657238104Sdeselse
658238104Sdes  AC_SUBST(ldns_build_config_have_attr_format, 0)
659238104Sdesfi
660238104Sdesif test "x$ac_cv_c_unused_attribute" = "xyes"; then
661238104Sdes  AC_SUBST(ldns_build_config_have_attr_unused, 1)
662238104Sdeselse
663238104Sdes  AC_SUBST(ldns_build_config_have_attr_unused, 0)
664238104Sdesfi
665238104Sdes
666238104SdesAC_CONFIG_FILES([Makefile ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config])
667238104Sdes
668238104SdesAC_CONFIG_HEADER([ldns/config.h])
669238104SdesAC_OUTPUT
670238104SdesCOPY_HEADER_FILES(ldns/, ldns/)
671238104Sdes
672238104Sdesdnl AC_CONFIG_SUBDIRS([drill])
673238104Sdes
674238104Sdes
675