]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ldns/configure.ac
Optionally bind ktls threads to NUMA domains
[FreeBSD/FreeBSD.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],[7])
9 m4_define([VERSION_MICRO],[0])
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
17 # Library version
18 # ---------------
19 # current:revision:age
20 # (binary-api-number):(which-binary-api-version):(how-many-nrs-backwardscompat)
21 # if source code changes increment revision
22 # if any interfaces have been added/removed/changed since last update then
23 #   increment current and set revision to 0
24 # if any interfaces have been added since the last public release then increment age
25 # if any interfaces have been removed or changed since the last public release then
26 #   set age to 0
27 #
28 # ldns-1.6.17 and before had a .so with version same as VERSION_INFO
29 # ldns-1.7.0 will have libversion 2:0:0
30 #
31 AC_SUBST(VERSION_INFO, [2:0:0])
32
33 AC_AIX
34 if test "$ac_cv_header_minix_config_h" = "yes"; then
35         AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix])
36 fi
37 LT_INIT
38 AC_CONFIG_MACRO_DIR([m4])
39
40 OURCPPFLAGS=''
41 CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
42 CFLAGS="$CFLAGS"
43
44 # Checks for programs.
45 AC_PROG_CC
46 ACX_DEPFLAG
47 AC_PROG_MAKE_SET
48
49 # Extra (sp)lint flags for NetBSD
50 AC_CANONICAL_HOST
51 case "$host_os" in
52         netbsd*) LINTFLAGS="'-D__RENAME(x)=' -D_NETINET_IN_H_ $LINTFLAGS" 
53                  ;;
54         *)       LINTFLAGS="$LINTFLAGS"
55                  ;;
56 esac
57 AC_SUBST(LINTFLAGS)
58
59 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
60
61 ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
62 ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
63
64 # routine to copy files
65 # argument 1 is a list of files (relative to the source dir)
66 # argument 2 is a destination directory (relative to the current
67 # working directory
68 AC_DEFUN([COPY_FILES],
69 [
70 for file in $1; do
71         sh $srcdir/install-sh -m 644 $file $2
72 done
73 ])
74
75 # copy all .h files in the dir at argument 1
76 # (relative to source) to the dir at argument 2
77 # (relative to current dir)
78 AC_DEFUN([COPY_HEADER_FILES],
79 [
80 echo "copying header files"
81 COPY_FILES($srcdir/$1/*.h, $2)
82 ])
83
84 # Checks for typedefs, structures, and compiler characteristics.
85 AC_C_CONST
86 AC_LANG_C
87 if test "x$CFLAGS" = "x" ; then
88 ACX_CHECK_COMPILER_FLAG(g, [CFLAGS="-g"])
89 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="-O2 $CFLAGS"])
90 fi
91 ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
92 ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
93 ACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
94 ACX_CHECK_COMPILER_FLAG(Wstrict-prototypes, [CFLAGS="-Wstrict-prototypes $CFLAGS"])
95 #ACX_CHECK_COMPILER_FLAG(Wshadow, [CFLAGS="-Wshadow $CFLAGS"])
96 ACX_CHECK_COMPILER_FLAG(Wunused-function, [CFLAGS="-Wunused-function $CFLAGS"])
97 ACX_CHECK_COMPILER_FLAG(Wmissing-prototypes, [CFLAGS="-Wmissing-prototypes $CFLAGS"])
98
99 AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
100
101 # MinGW32 tests
102 AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
103 # end mingw32 tests
104
105 ACX_DETERMINE_EXT_FLAGS_UNBOUND
106
107 AC_C_INLINE
108 AC_CHECK_TYPE(int8_t, char)
109 AC_CHECK_TYPE(int16_t, short)
110 AC_CHECK_TYPE(int32_t, int)
111 AC_CHECK_TYPE(int64_t, long long)
112 AC_CHECK_TYPE(uint8_t, unsigned char)
113 AC_CHECK_TYPE(uint16_t, unsigned short)
114 AC_CHECK_TYPE(uint32_t, unsigned int)
115 AC_CHECK_TYPE(uint64_t, unsigned long long)
116
117 # my own checks
118 AC_CHECK_PROG(doxygen, doxygen, doxygen)
119
120 # check to see if libraries are needed for these functions.
121 AC_SEARCH_LIBS([socket], [socket])
122 AC_SEARCH_LIBS([inet_pton], [nsl])
123
124
125 AC_ARG_WITH(drill, AC_HELP_STRING([--with-drill], 
126  [Also build drill.]), 
127  [],[with_drill="no"])
128 if test x_$with_drill != x_no ; then
129         AC_SUBST(DRILL,[drill])
130         AC_SUBST(INSTALL_DRILL,[install-drill])
131         AC_SUBST(UNINSTALL_DRILL,[uninstall-drill])
132         AC_SUBST(CLEAN_DRILL,[clean-drill])
133         AC_SUBST(LINT_DRILL,[lint-drill])
134         if test -e $srcdir/drill/config.h -o -e drill/config.h ; then
135                 AC_MSG_ERROR([
136 A config.h was detected in the drill subdirectory.
137 This does not work with the --with-drill option.
138 Please remove the config.h from the drill subdirectory 
139 or do not use the --with-drill option.])
140         fi
141 else
142         AC_SUBST(DRILL,[""])
143         AC_SUBST(INSTALL_DRILL,[""])
144         AC_SUBST(UNINSTALL_DRILL,[""])
145         AC_SUBST(CLEAN_DRILL,[""])
146         AC_SUBST(LINT_DRILL,[""])
147 fi
148
149
150 AC_ARG_WITH(examples, AC_HELP_STRING([--with-examples], 
151  [Also build examples.]), 
152  [],[with_examples="no"])
153 if test x_$with_examples != x_no ; then
154         AC_SUBST(EXAMPLES,[examples])
155         AC_SUBST(INSTALL_EXAMPLES,[install-examples])
156         AC_SUBST(UNINSTALL_EXAMPLES,[uninstall-examples])
157         AC_SUBST(CLEAN_EXAMPLES,[clean-examples])
158         AC_SUBST(LINT_EXAMPLES,[lint-examples])
159         if test -e $srcdir/examples/config.h -o -e examples/config.h ; then
160                 AC_MSG_ERROR([
161 A config.h was detected in the examples subdirectory.
162 This does not work with the --with-examples option.
163 Please remove the config.h from the examples subdirectory 
164 or do not use the --with-examples option.])
165         fi
166 else
167         AC_SUBST(EXAMPLES,[""])
168         AC_SUBST(INSTALL_EXAMPLES,[""])
169         AC_SUBST(UNINSTALL_EXAMPLES,[""])
170         AC_SUBST(CLEAN_EXAMPLES,[""])
171         AC_SUBST(LINT_EXAMPLES,[""])
172 fi
173
174 # add option to disable installation of ldns-config script
175 AC_ARG_ENABLE(ldns-config, AC_HELP_STRING([--disable-ldns-config], [disable installation of ldns-config (default=enabled)]),
176         enable_ldns_config=$enableval, enable_ldns_config=yes)
177 if test "x$enable_ldns_config" = xyes; then
178         AC_SUBST(INSTALL_CONFIG, [install-config])
179         AC_SUBST(INSTALL_CONFIG_MANPAGE, [install-config-manpage])
180         AC_SUBST(UNINSTALL_CONFIG, [uninstall-config])
181         AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [uninstall-config-manpage])
182 else
183         AC_SUBST(INSTALL_CONFIG, [""])
184         AC_SUBST(INSTALL_CONFIG_MANPAGE, [""])
185         AC_SUBST(UNINSTALL_CONFIG, [""])
186         AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [""])
187 fi
188
189 # add option to disable library printing to stderr
190 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)
191 case "$enable_stderr_msgs" in
192     no) dnl default
193         ;;
194     *)  
195         AC_DEFINE_UNQUOTED([STDERR_MSGS], [1], [Define this to enable messages to stderr.])
196         ;;
197 esac
198
199 AX_HAVE_POLL(
200   [AX_CONFIG_FEATURE_ENABLE(poll)],
201   [AX_CONFIG_FEATURE_DISABLE(poll)])
202 AX_CONFIG_FEATURE(
203   [poll], [This platform supports poll(7)],
204   [HAVE_POLL], [This platform supports poll(7).])
205
206 # check for python
207 PYTHON_X_CFLAGS=""
208 ldns_with_pyldns=no
209 ldns_with_pyldnsx=no
210 AC_ARG_WITH(pyldns, AC_HELP_STRING([--with-pyldns], 
211  [generate python library, or --without-pyldns to disable Python support.]), 
212  [],[ withval="no" ])
213 ldns_have_python=no
214 if test x_$withval != x_no; then
215    sinclude(ax_python_devel.m4)
216    ac_save_LIBS="$LIBS" dnl otherwise AC_PYTHON_DEVEL thrashes $LIBS
217
218    AX_PYTHON_DEVEL([>= '2.4.0'])
219    if test ! -z "$ac_python_version"; then
220         ldns_have_python=yes
221    fi
222
223    # pass additional Python 3 option to SWIG
224    if test `$PYTHON -c "import sys; \
225        ver = sys.version.split()[[0]]; \
226        print(ver >= '3')"` = "True"; then
227        AC_SUBST(SWIGPY3, ["-py3 -DPY3"])
228    fi
229
230    # check for SWIG
231    if test x_$ldns_have_python != x_no; then
232         sinclude(ax_pkg_swig.m4)
233
234         # check for >=SWIG-2.0.4 if Python 3.2 used
235         if test `$PYTHON -c "import sys; \
236             ver = sys.version.split()[[0]]; \
237             print(ver >= '3.2')"` = "True"; then
238             AX_PKG_SWIG(2.0.4, [], [AC_MSG_ERROR([SWIG-2.0.4 is required to build pyldns for Python 3.2 and greater.])])
239         else
240             AX_PKG_SWIG
241         fi
242
243         if test ! -x "$SWIG"; then
244                 AC_MSG_ERROR([failed to find SWIG tool, install it, or do not build pyldns])
245         else
246                 AC_DEFINE(HAVE_SWIG,1,[Define if you have SWIG libraries and header files.])
247                 AC_SUBST(PYLDNS, "pyldns")
248                 AC_SUBST(swig, "$SWIG")
249                 ldns_with_pyldns=yes
250         fi
251    else
252         AC_MSG_RESULT([*** don't have Python, skipping SWIG, no pyldns ***]) # '
253    fi
254
255    # xtra cflags for pyldns
256    if test x_$ldns_have_python != x_no; then
257         ACX_CHECK_COMPILER_FLAG(fno-strict-aliasing, [PYTHON_X_CFLAGS="-fno-strict-aliasing"])
258         ACX_CHECK_COMPILER_FLAG(Wno-missing-field-initializers, [PYTHON_X_CFLAGS="-Wno-missing-field-initializers $PYTHON_X_CFLAGS"])
259         ACX_CHECK_COMPILER_FLAG(Wno-unused-parameter, [PYTHON_X_CFLAGS="-Wno-unused-parameter $PYTHON_X_CFLAGS"])
260         ACX_CHECK_COMPILER_FLAG(Wno-unused-variable, [PYTHON_X_CFLAGS="-Wno-unused-variable $PYTHON_X_CFLAGS"])
261    fi
262 fi
263 AC_SUBST(PYTHON_X_CFLAGS)
264
265 # Check for pyldnsx
266 AC_ARG_WITH(pyldnsx, AC_HELP_STRING([--without-pyldnsx], 
267   [Do not install the ldnsx python module, or --with-pyldnsx to install it.]), 
268   [],[ withval="with_pyldns" ])
269 if test x_$withval != x_no; then
270   if test x_$ldns_with_pyldns != x_no; then
271     AC_SUBST(PYLDNSX, "pyldnsx")
272     ldns_with_pyldnsx=yes
273   else
274     if test x_$withval != x_with_pyldns; then
275       AC_MSG_ERROR([--with-pyldns is needed for the ldnsx python module])
276     fi
277   fi
278 fi
279
280 if test x_$ldns_with_pyldns != x_no; then
281   AC_SUBST(PYLDNSINST, "install-pyldns")dnl
282   AC_SUBST(PYLDNSUNINST, "uninstall-pyldns")
283 else
284   AC_SUBST(PYLDNSINST, "")dnl
285   AC_SUBST(PYLDNSUNINST, "")
286 fi
287 if test x_$ldns_with_pyldnsx != x_no; then
288   AC_SUBST(PYLDNSXINST, "install-pyldnsx")dnl
289   AC_SUBST(PYLDNSXUNINST, "uninstall-pyldnsx")
290 else
291   AC_SUBST(PYLDNSXINST, "")dnl
292   AC_SUBST(PYLDNSXUNINST, "")
293 fi
294
295 # check for perl
296 ldns_with_p5_dns_ldns=no
297 AC_ARG_WITH(p5-dns-ldns, AC_HELP_STRING([--with-p5-dns-ldns], 
298  [generate DNS::LDNS perl bindings]), 
299  [],[ withval="no" ])
300 ldns_have_perl=no
301 if test x_$withval != x_no; then
302    AC_PATH_PROG([PERL], [perl])
303    if test -z "$PERL"; then
304       AC_MSG_ERROR([Cannot find perl in your system path])
305    fi
306    AC_SUBST(P5_DNS_LDNS, "p5-dns-ldns")dnl
307    AC_SUBST(TEST_P5_DNS_LDNS, "test-p5-dns-ldns")dnl
308    AC_SUBST(INSTALL_P5_DNS_LDNS, "install-p5-dns-ldns")dnl
309    AC_SUBST(UNINSTALL_P5_DNS_LDNS, "uninstall-p5-dns-ldns")dnl
310    AC_SUBST(CLEAN_P5_DNS_LDNS, "clean-p5-dns-ldns")
311 else
312    AC_SUBST(P5_DNS_LDNS, "")dnl
313    AC_SUBST(TEST_P5_DNS_LDNS, "")dnl
314    AC_SUBST(INSTALL_P5_DNS_LDNS, "")dnl
315    AC_SUBST(UNINSTALL_P5_DNS_LDNS, "")dnl
316    AC_SUBST(CLEAN_P5_DNS_LDNS, "")
317 fi
318
319 # Use libtool
320 ACX_LIBTOOL_C_ONLY
321
322 tmp_CPPFLAGS=$CPPFLAGS
323 tmp_LDFLAGS=$LDFLAGS
324 tmp_LIBS=$LIBS
325
326 ACX_WITH_SSL_OPTIONAL
327 AC_MSG_CHECKING([for LibreSSL])
328 if grep VERSION_TEXT $ssldir/include/openssl/opensslv.h | grep "LibreSSL" >/dev/null; then
329         AC_MSG_RESULT([yes])
330         AC_DEFINE([HAVE_LIBRESSL], [1], [Define if we have LibreSSL])
331 else
332         AC_MSG_RESULT([no])
333 fi
334 AC_CHECK_FUNCS([EVP_sha256 EVP_sha384 EVP_sha512 ENGINE_load_cryptodev EVP_PKEY_keygen ECDSA_SIG_get0 EVP_MD_CTX_new EVP_PKEY_base_id DSA_SIG_set0 DSA_SIG_get0 EVP_dss1 DSA_get0_pqg DSA_get0_key])
335
336 # for macosx, see if glibtool exists and use that
337 # BSD's need to know the version...
338 #AC_CHECK_PROG(glibtool, glibtool, [glibtool], )
339 #AC_CHECK_PROGS(libtool, [libtool15 libtool], [./libtool])
340
341 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
342 case "$enable_sha2" in
343     no)
344         ;;
345     yes|*)
346         if test "x$HAVE_SSL" != "xyes"; then
347             AC_MSG_ERROR([SHA2 enabled, but no SSL support])
348         fi
349         AC_MSG_CHECKING(for SHA256 and SHA512)
350         AC_CHECK_FUNC(SHA256_Init, [], [
351                 AC_MSG_ERROR([No SHA2 functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-sha2])
352                 ])
353         AC_DEFINE_UNQUOTED([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
354         ;;
355 esac
356
357 # check wether gost also works
358 AC_DEFUN([AC_CHECK_GOST_WORKS],
359 [AC_REQUIRE([AC_PROG_CC])
360 AC_MSG_CHECKING([if GOST works])
361 if test c${cross_compiling} = cno; then
362 BAKCFLAGS="$CFLAGS"
363 if test -n "$ssldir"; then
364         CFLAGS="$CFLAGS -Wl,-rpath,$ssldir/lib"
365 fi
366 AC_RUN_IFELSE([AC_LANG_SOURCE([[
367 #include <string.h>
368 #include <openssl/ssl.h>
369 #include <openssl/evp.h>
370 #include <openssl/engine.h>
371 #include <openssl/conf.h>
372 /* routine to load gost (from sldns) */
373 int load_gost_id(void)
374 {
375         static int gost_id = 0;
376         const EVP_PKEY_ASN1_METHOD* meth;
377         ENGINE* e;
378
379         if(gost_id) return gost_id;
380
381         /* see if configuration loaded gost implementation from other engine*/
382         meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
383         if(meth) {
384                 EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
385                 return gost_id;
386         }
387
388         /* see if engine can be loaded already */
389         e = ENGINE_by_id("gost");
390         if(!e) {
391                 /* load it ourself, in case statically linked */
392                 ENGINE_load_builtin_engines();
393                 ENGINE_load_dynamic();
394                 e = ENGINE_by_id("gost");
395         }
396         if(!e) {
397                 /* no gost engine in openssl */
398                 return 0;
399         }
400         if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
401                 ENGINE_finish(e);
402                 ENGINE_free(e);
403                 return 0;
404         }
405
406         meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
407         if(!meth) {
408                 /* algo not found */
409                 ENGINE_finish(e);
410                 ENGINE_free(e);
411                 return 0;
412         }
413         EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
414         return gost_id;
415 }
416 int main(void) { 
417         EVP_MD_CTX* ctx;
418         const EVP_MD* md;
419         unsigned char digest[64]; /* its a 256-bit digest, so uses 32 bytes */
420         const char* str = "Hello world";
421         const unsigned char check[] = {
422                 0x40 , 0xed , 0xf8 , 0x56 , 0x5a , 0xc5 , 0x36 , 0xe1 ,
423                 0x33 , 0x7c , 0x7e , 0x87 , 0x62 , 0x1c , 0x42 , 0xe0 ,
424                 0x17 , 0x1b , 0x5e , 0xce , 0xa8 , 0x46 , 0x65 , 0x4d ,
425                 0x8d , 0x3e , 0x22 , 0x9b , 0xe1 , 0x30 , 0x19 , 0x9d
426         };
427         OPENSSL_config(NULL);
428         (void)load_gost_id();
429         md = EVP_get_digestbyname("md_gost94");
430         if(!md) return 1;
431         memset(digest, 0, sizeof(digest));
432         ctx = EVP_MD_CTX_create();
433         if(!ctx) return 2;
434         if(!EVP_DigestInit_ex(ctx, md, NULL)) return 3;
435         if(!EVP_DigestUpdate(ctx, str, 10)) return 4;
436         if(!EVP_DigestFinal_ex(ctx, digest, NULL)) return 5;
437         /* uncomment to see the hash calculated.
438                 {int i;
439                 for(i=0; i<32; i++)
440                         printf(" %2.2x", (int)digest[i]);
441                 printf("\n");}
442         */
443         if(memcmp(digest, check, sizeof(check)) != 0)
444                 return 6;
445         return 0;
446 }
447 ]])] , [eval "ac_cv_c_gost_works=yes"], [eval "ac_cv_c_gost_works=no"])
448 CFLAGS="$BAKCFLAGS"
449 else
450 eval "ac_cv_c_gost_works=maybe"
451 fi
452 ])dnl
453
454 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
455 case "$enable_gost" in
456     no)
457         ;;
458     *)  dnl default
459         if test "x$HAVE_SSL" != "xyes"; then
460             AC_MSG_ERROR([GOST enabled, but no SSL support])
461         fi
462         AC_MSG_CHECKING(for GOST)
463         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])])
464         AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([No ECC functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-gost])])
465         AC_CHECK_GOST_WORKS
466         AC_ARG_ENABLE(gost-anyway, AC_HELP_STRING([--enable-gost-anyway], [Enable GOST even whithout a GOST engine installed]))
467         if test "$ac_cv_c_gost_works" != "no" -o "$enable_gost_anyway" = "yes"; then
468                 if test "$ac_cv_c_gost_works" = "no"; then
469                         AC_MSG_RESULT([no, but compiling with GOST support anyway])
470                 else
471                         AC_MSG_RESULT([yes])
472                 fi
473                 use_gost="yes"
474                 AC_DEFINE([USE_GOST], [1], [Define this to enable GOST support.])
475         else
476                 AC_MSG_RESULT([no])
477                 AC_MSG_WARN([Gost support does not work because the engine is missing.])
478                 AC_MSG_WARN([Install gost-engine first or use the --enable-gost-anyway to compile with GOST support anyway])
479                 AC_MSG_WARN([See also https://github.com/gost-engine/engine/wiki for information about gost-engine])
480         fi
481         ;;
482 esac
483
484 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
485 case "$enable_ecdsa" in
486     no)
487       ;;
488     *) dnl default
489       if test "x$HAVE_SSL" != "xyes"; then
490         AC_MSG_ERROR([ECDSA enabled, but no SSL support])
491       fi
492       AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade OpenSSL or rerun with --disable-ecdsa])])
493       AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade OpenSSL or rerun with --disable-ecdsa])])
494       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
495 #include <openssl/evp.h>
496       ])
497       # we now know we have ECDSA and the required curves.
498       AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
499       ;;
500 esac
501
502 AC_ARG_ENABLE(dsa, AC_HELP_STRING([--disable-dsa], [Disable DSA support]))
503 case "$enable_dsa" in
504     no)
505       ;;
506     *) dnl default
507       # detect if DSA is supported, and turn it off if not.
508       AC_CHECK_FUNC(DSA_SIG_new, [
509         AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.])
510       ], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.])
511           fi ])
512       ;;
513 esac
514
515 AC_ARG_ENABLE(ed25519, AC_HELP_STRING([--enable-ed25519], [Enable ED25519 support (experimental)]))
516 case "$enable_ed25519" in
517     yes)
518       if test "x$HAVE_SSL" != "xyes"; then
519         AC_MSG_ERROR([ED25519 enabled, but no SSL support])
520       fi
521       AC_CHECK_DECLS([NID_X25519], [], [AC_MSG_ERROR([OpenSSL does not support the EDDSA curve: please upgrade OpenSSL or rerun with --disable-ed25519])], [AC_INCLUDES_DEFAULT
522 #include <openssl/evp.h>
523       ])
524       AC_DEFINE_UNQUOTED([USE_ED25519], [1], [Define this to enable ED25519 support.])
525       ;;
526     *|no) dnl default
527       ;;
528 esac
529
530 AC_ARG_ENABLE(ed448, AC_HELP_STRING([--enable-ed448], [Enable ED448 support (experimental)]))
531 case "$enable_ed448" in
532     yes)
533       if test "x$HAVE_SSL" != "xyes"; then
534         AC_MSG_ERROR([ED448 enabled, but no SSL support])
535       fi
536       AC_CHECK_DECLS([NID_X448], [], [AC_MSG_ERROR([OpenSSL does not support the EDDSA curve: please upgrade OpenSSL or rerun with --disable-ed448])], [AC_INCLUDES_DEFAULT
537 #include <openssl/evp.h>
538       ])
539       AC_DEFINE_UNQUOTED([USE_ED448], [1], [Define this to enable ED448 support.])
540       ;;
541     *|no) dnl default
542       ;;
543 esac
544
545 AC_ARG_ENABLE(dane, AC_HELP_STRING([--disable-dane], [Disable DANE support]))
546 AC_ARG_ENABLE(dane-verify, AC_HELP_STRING([--disable-dane-verify], [Disable DANE verify support]))
547 AC_ARG_ENABLE(dane-ta-usage, AC_HELP_STRING([--disable-dane-ta-usage], [Disable DANE-TA usage type support]))
548
549 AC_ARG_ENABLE(full-dane,, [
550         enable_dane_ta_usage=yes
551         enable_dane_verify=yes
552         enable_dane=yes
553 ])
554 AC_ARG_ENABLE(no-dane-ta-usage,, [
555         enable_dane_ta_usage=no
556         enable_dane_verify=yes
557         enable_dane=yes
558 ])
559 AC_ARG_ENABLE(no-dane-verify,, [
560         enable_dane_ta_usage=no
561         enable_dane_verify=no
562         enable_dane=yes
563 ])
564 case "$enable_dane" in
565     no)
566       AC_SUBST(ldns_build_config_use_dane, 0)
567       AC_SUBST(ldns_build_config_use_dane_verify, 0)
568       AC_SUBST(ldns_build_config_use_dane_ta_usage, 0)
569       ;;
570     *) dnl default
571       if test "x$HAVE_SSL" != "xyes"; then
572         AC_MSG_ERROR([DANE enabled, but no SSL support])
573       fi
574       AC_CHECK_FUNC(X509_check_ca, [], [AC_MSG_ERROR([OpenSSL does not support DANE: please upgrade OpenSSL or rerun with --disable-dane])])
575       AC_SUBST(ldns_build_config_use_dane, 1)
576       AC_DEFINE_UNQUOTED([USE_DANE], [1], [Define this to enable DANE support.])
577       case "$enable_dane_verify" in
578           no)
579             AC_SUBST(ldns_build_config_use_dane_verify, 0)
580             AC_SUBST(ldns_build_config_use_dane_ta_usage, 0)
581             ;;
582           *)
583             AC_SUBST(ldns_build_config_use_dane_verify, 1)
584             AC_DEFINE_UNQUOTED([USE_DANE_VERIFY], [1], [Define this to enable DANE verify support.])
585             case "$enable_dane_ta_usage" in
586                 no)
587                   AC_SUBST(ldns_build_config_use_dane_ta_usage, 0)
588                   ;;
589                 *) dnl default
590             LIBS="-lssl $LIBS"
591                   AC_CHECK_FUNC(SSL_get0_dane, [], [AC_MSG_ERROR([OpenSSL does not support offline DANE verification (Needed for the DANE-TA usage type).  Please upgrade OpenSSL to version >= 1.1.0 or rerun with --disable-dane-verify or --disable-dane-ta-usage])])
592                   LIBSSL_LIBS="$LIBSSL_LIBS -lssl"
593                   AC_SUBST(ldns_build_config_use_dane_ta_usage, 1)
594                   AC_DEFINE_UNQUOTED([USE_DANE_TA_USAGE], [1], [Define this to enable DANE-TA usage type support.])
595                   ;;
596             esac
597       esac
598       ;;
599 esac
600
601 AC_ARG_ENABLE(rrtype-ninfo, AC_HELP_STRING([--enable-rrtype-ninfo], [Enable draft RR type ninfo.]))
602 case "$enable_rrtype_ninfo" in
603         yes)
604                 AC_DEFINE_UNQUOTED([RRTYPE_NINFO], [], [Define this to enable RR type NINFO.])
605                 ;;
606         no|*)
607                 ;;
608 esac
609 AC_ARG_ENABLE(rrtype-rkey, AC_HELP_STRING([--enable-rrtype-rkey], [Enable draft RR type rkey.]))
610 case "$enable_rrtype_rkey" in
611         yes)
612                 AC_DEFINE_UNQUOTED([RRTYPE_RKEY], [], [Define this to enable RR type RKEY.])
613                 ;;
614         no|*)
615                 ;;
616 esac
617 AC_ARG_ENABLE(rrtype-openpgpkey, AC_HELP_STRING([--disable-rrtype-openpgpkey], [Disable openpgpkey RR type.]))
618 case "$enable_rrtype_openpgpkey" in
619         no)
620                 ;;
621         yes|*)
622                 AC_DEFINE_UNQUOTED([RRTYPE_OPENPGPKEY], [], [Define this to enable RR type OPENPGPKEY.])
623                 ;;
624 esac
625 AC_ARG_ENABLE(rrtype-ta, AC_HELP_STRING([--enable-rrtype-ta], [Enable draft RR type ta.]))
626 case "$enable_rrtype_ta" in
627         yes)
628                 AC_DEFINE_UNQUOTED([RRTYPE_TA], [], [Define this to enable RR type TA.])
629                 ;;
630         no|*)
631                 ;;
632 esac
633 AC_ARG_ENABLE(rrtype-avc, AC_HELP_STRING([--enable-rrtype-avc], [Enable draft RR type avc.]))
634 case "$enable_rrtype_avc" in
635         yes)
636                 AC_DEFINE_UNQUOTED([RRTYPE_AVC], [], [Define this to enable RR type AVC.])
637                 ;;
638         no|*)
639                 ;;
640 esac
641
642 AC_SUBST(LIBSSL_CPPFLAGS)
643 AC_SUBST(LIBSSL_LDFLAGS)
644 AC_SUBST(LIBSSL_LIBS)
645 if test "x$HAVE_SSL" = "xyes"; then
646 AC_SUBST(LIBSSL_SSL_LIBS, ["-lssl $LIBSSL_LIBS"])
647 fi
648 CPPFLAGS=$tmp_CPPFLAGS
649 LDFLAGS=$tmp_LDFLAGS
650 LIBS=$tmp_LIBS
651
652
653 # add option to disable the evil rpath
654 ACX_ARG_RPATH
655
656 #AC_RUN_IFELSE([AC_LANG_SOURCE(
657 #[
658 #int main()
659 #{
660 #short one = 1;
661 #char *cp = (char*)&one;
662 #if ( *cp == 0 )
663 #return(0);
664 #else
665 #return(1);
666 #}
667 #])], [],[
668 #AC_DEFINE(CONFCHECK_LITTLE_ENDIAN, 1, [system appears to be little-endian])
669 #],[])
670
671 # should define WORDS_BIGENDIAN if the system is big-endian
672 AC_C_BIGENDIAN
673
674 # Checks for header files.
675 AC_HEADER_STDC
676 AC_HEADER_STDBOOL
677 #AC_HEADER_SYS_WAIT
678 #AC_CHECK_HEADERS([getopt.h fcntl.h stdlib.h string.h strings.h unistd.h])
679 # do the very minimum - we can always extend this
680 AC_CHECK_HEADERS([getopt.h stdarg.h openssl/ssl.h netinet/in.h time.h arpa/inet.h netdb.h],,, [AC_INCLUDES_DEFAULT])
681 AC_CHECK_HEADERS(sys/param.h sys/mount.h,,,
682 [AC_INCLUDES_DEFAULT
683   [
684    #if HAVE_SYS_PARAM_H
685    # include <sys/param.h>
686    #endif
687   ]
688 ])
689 AC_CHECK_HEADER(sys/socket.h,
690 [
691 include_sys_socket_h='#include <sys/socket.h>'
692 AC_DEFINE(HAVE_SYS_SOCKET_H, 1, [define if you have sys/socket.h])
693 ],[
694 include_sys_socket_h=''
695 ],[AC_INCLUDES_DEFAULT
696   [
697    #if HAVE_SYS_PARAM_H
698    # include <sys/param.h>
699    #endif
700   ]
701 ])
702 AC_SUBST(include_sys_socket_h)
703 AC_CHECK_HEADER(inttypes.h,
704 [
705 include_inttypes_h='#include <inttypes.h>'
706 AC_DEFINE(HAVE_INTTYPES_H, 1, [define if you have inttypes.h])
707 AC_SUBST(ldns_build_config_have_inttypes_h, 1)
708 ],[
709 include_inttypes_h=''
710 AC_SUBST(ldns_build_config_have_inttypes_h, 0)
711 ],[AC_INCLUDES_DEFAULT
712 ])
713 AC_SUBST(include_inttypes_h)
714 AC_CHECK_HEADER(sys/types.h,
715 [
716 include_systypes_h='#include <sys/types.h>'
717 AC_DEFINE(HAVE_SYS_TYPES_H, 1, [define if you have sys/types.h])
718 ],[
719 include_systypes_h=''
720 ],[AC_INCLUDES_DEFAULT
721 ])
722 AC_SUBST(include_systypes_h)
723 AC_CHECK_HEADER(unistd.h,
724 [
725 include_unistd_h='#include <unistd.h>'
726 AC_DEFINE(HAVE_UNISTD_H, 1, [define if you have unistd.h])
727 ],[
728 include_unistd_h=''
729 ],[AC_INCLUDES_DEFAULT
730 ])
731 AC_SUBST(include_unistd_h)
732
733 AC_CHECK_SIZEOF(time_t,,[
734 AC_INCLUDES_DEFAULT
735 #ifdef TIME_WITH_SYS_TIME
736 # include <sys/time.h>
737 # include <time.h>
738 #else
739 # ifdef HAVE_SYS_TIME_H
740 #  include <sys/time.h>
741 # else
742 #  include <time.h>
743 # endif
744 #endif
745 ])
746
747 if test x_$with_examples != x_no; then
748 AC_CHECK_HEADERS([pcap.h],,, [AC_INCLUDES_DEFAULT])
749 AC_CHECK_LIB(pcap, pcap_open_offline, [
750         AC_DEFINE([HAVE_LIBPCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap).])dnl`
751         AC_SUBST([LIBPCAP_LIBS], [-lpcap])
752     ], [
753         AC_MSG_WARN([Can't find pcap library (needed for ldns-dpa, will not build dpa now.)])dnl'
754         AC_SUBST([LIBPCAP_LIBS], [])
755     ]
756 )
757 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],,, [
758 AC_INCLUDES_DEFAULT 
759 #ifdef HAVE_NETINET_IN_SYSTM_H
760 #include <netinet/in_systm.h>
761 #endif
762 #ifdef HAVE_NETINET_IN_H
763 #include <netinet/in.h>
764 #endif
765 #ifdef HAVE_SYS_SOCKET_H
766 #include <sys/socket.h>
767 #endif
768 #ifdef HAVE_NET_IF_H
769 #include <net/if.h>
770 #endif])
771 fi
772
773 ACX_TYPE_SOCKLEN_T
774 if test "x$ac_cv_type_socklen_t" = xyes; then
775   AC_SUBST(ldns_build_config_have_socklen_t, 1)
776 else
777   AC_SUBST(ldns_build_config_have_socklen_t, 0)
778 fi
779 AC_TYPE_SIZE_T
780 AC_CHECK_TYPE(ssize_t, int)
781 dnl AC_TYPE_INTPTR_T does not work on all platforms (autoconf)
782 AC_CHECK_TYPE(intptr_t, size_t)
783 AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
784 #if HAVE_SYS_TYPES_H
785 # include <sys/types.h>
786 #endif
787 #if HAVE_NETINET_IN_H
788 # include <netinet/in.h>
789 #endif])
790 AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
791 #if HAVE_SYS_TYPES_H
792 # include <sys/types.h>
793 #endif
794 #if HAVE_NETINET_IN_H
795 # include <netinet/in.h>
796 #endif])
797 ACX_CHECK_SS_FAMILY
798
799 AC_FUNC_MALLOC
800 AC_FUNC_REALLOC
801
802 AC_REPLACE_FUNCS(b64_pton)
803 AC_REPLACE_FUNCS(b64_ntop)
804 AC_REPLACE_FUNCS(calloc)
805 AC_REPLACE_FUNCS(timegm)
806 AC_REPLACE_FUNCS(gmtime_r)
807 AC_REPLACE_FUNCS(ctime_r)
808 AC_REPLACE_FUNCS(localtime_r)
809 AC_REPLACE_FUNCS(isblank)
810 AC_REPLACE_FUNCS(isascii)
811 AC_REPLACE_FUNCS(inet_aton)
812 AC_REPLACE_FUNCS(inet_pton)
813 AC_REPLACE_FUNCS(inet_ntop)
814 AC_REPLACE_FUNCS(snprintf)
815 AC_REPLACE_FUNCS(strlcpy)
816 AC_REPLACE_FUNCS(memmove)
817 AC_FUNC_FORK
818 AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset b32_ntop b32_pton])
819 if test "x$HAVE_B32_NTOP" = "xyes"; then
820         AC_SUBST(ldns_build_config_have_b32_ntop, 1)
821 else
822         AC_SUBST(ldns_build_config_have_b32_ntop, 0)
823 fi
824 if test "x$HAVE_B32_PTON" = "xyes"; then
825         AC_SUBST(ldns_build_config_have_b32_pton, 1)
826 else
827         AC_SUBST(ldns_build_config_have_b32_pton, 0)
828 fi
829
830 ACX_CHECK_GETADDRINFO_WITH_INCLUDES
831 if test $ac_cv_func_getaddrinfo = no; then
832         AC_LIBOBJ([fake-rfc2553])
833 fi
834 if test "$USE_WINSOCK" = 1; then
835         AC_CHECK_TOOL(WINDRES, windres)
836 fi
837 ACX_FUNC_IOCTLSOCKET
838
839 #AC_SEARCH_LIBS(RSA_new, [crypto])
840
841 ACX_CHECK_FORMAT_ATTRIBUTE
842 ACX_CHECK_UNUSED_ATTRIBUTE
843
844 # check OSX deployment target, if needed
845 if echo $build_os | grep darwin > /dev/null; then
846   sdk_p=`xcode-select -print-path`;
847   sdk_v="$( /usr/bin/xcrun --show-sdk-version )";
848   case $sdk_v in
849        10.9|10.8)   sdk_c="10.7";;
850        10.11|10.10|*) sdk_c="10.10";;
851   esac
852   export MACOSX_DEPLOYMENT_TARGET="${sdk_c}";
853   export CFLAGS="$CFLAGS -mmacosx-version-min=${sdk_c} -isysroot ${sdk_p}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${sdk_v}.sdk";
854 fi
855
856 AC_DEFINE([SYSCONFDIR], [sysconfdir], [System configuration dir])
857
858 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]]), [
859  AC_SUBST([LDNS_TRUST_ANCHOR_FILE], ["$withval"])
860  AC_MSG_NOTICE([Default trust anchor: $withval])
861 ],[
862  AC_SUBST([LDNS_TRUST_ANCHOR_FILE], ["\$(sysconfdir)/unbound/root.key"])
863 ])
864
865 AC_ARG_WITH(ca-file, AC_HELP_STRING([--with-ca-file=CAFILE], [File containing CA certificates for ldns-dane]), [
866  AC_DEFINE([HAVE_DANE_CA_FILE], [1], [Is a CAFILE given at configure time])
867  AC_DEFINE_UNQUOTED([LDNS_DANE_CA_FILE], ["$withval"], [Is a CAFILE given at configure time])
868  AC_MSG_NOTICE([Using CAfile: $withval])
869  AC_SUBST(DEFAULT_CAFILE, ["Default is $withval"])
870 ],[
871  AC_DEFINE([HAVE_DANE_CA_FILE], [0], [Is a CAFILE given at configure time])
872  AC_SUBST(DEFAULT_CAFILE, [])
873 ])
874
875 AC_ARG_WITH(ca-path, AC_HELP_STRING([--with-ca-path=CAPATH], [Directory containing CA certificate files for ldns-dane]), [
876  AC_DEFINE([HAVE_DANE_CA_PATH], [1], [Is a CAPATH given at configure time])
877  AC_DEFINE_UNQUOTED([LDNS_DANE_CA_PATH], ["$withval"], [Is a CAPATH given at configure time])
878  AC_MSG_NOTICE([Using CApath: $withval])
879  AC_SUBST(DEFAULT_CAPATH, ["Default is $withval"])
880 ],[
881  AC_DEFINE([HAVE_DANE_CA_PATH], [0], [Is a CAPATH given at configure time])
882  AC_SUBST(DEFAULT_CAPATH, [])
883 ])
884
885 AH_BOTTOM([
886 #include <stdio.h>
887 #include <string.h>
888 #include <unistd.h>
889 #include <assert.h>
890
891 #ifndef LITTLE_ENDIAN
892 #define LITTLE_ENDIAN 1234
893 #endif
894
895 #ifndef BIG_ENDIAN
896 #define BIG_ENDIAN 4321
897 #endif
898
899 #ifndef BYTE_ORDER
900 #ifdef WORDS_BIGENDIAN
901 #define BYTE_ORDER BIG_ENDIAN
902 #else
903 #define BYTE_ORDER LITTLE_ENDIAN
904 #endif /* WORDS_BIGENDIAN */
905 #endif /* BYTE_ORDER */
906
907 #if STDC_HEADERS
908 #include <stdlib.h>
909 #include <stddef.h>
910 #endif
911
912 #ifdef HAVE_STDINT_H
913 #include <stdint.h>
914 #endif
915
916 #ifdef HAVE_SYS_SOCKET_H
917 #include <sys/socket.h>
918 #endif
919
920 #ifdef HAVE_NETINET_IN_H
921 #include <netinet/in.h>
922 #endif
923
924 #ifdef HAVE_ARPA_INET_H
925 #include <arpa/inet.h>
926 #endif
927
928 #ifdef HAVE_WINSOCK2_H
929 #include <winsock2.h>
930 #endif
931
932 #ifdef HAVE_WS2TCPIP_H
933 #include <ws2tcpip.h>
934 #endif
935 ]
936 AHX_CONFIG_W32_FD_SET_T
937 )
938
939 AH_BOTTOM([
940 #ifdef __cplusplus
941 extern "C" {
942 #endif
943
944 int ldns_b64_ntop(uint8_t const *src, size_t srclength,
945                   char *target, size_t targsize);
946 /**
947  * calculates the size needed to store the result of b64_ntop
948  */
949 /*@unused@*/
950 static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
951 {
952         return ((((srcsize + 2) / 3) * 4) + 1);
953 }
954 int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
955 /**
956  * calculates the size needed to store the result of ldns_b64_pton
957  */
958 /*@unused@*/
959 static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
960 {
961         return (((((srcsize + 3) / 4) * 3)) + 1);
962 }
963
964 /**
965  * Given in dnssec_zone.c, also used in dnssec_sign.c:w
966
967  */
968 int ldns_dname_compare_v(const void *a, const void *b);
969
970 #ifndef HAVE_SLEEP
971 /* use windows sleep, in millisecs, instead */
972 #define sleep(x) Sleep((x)*1000)
973 #endif
974
975 #ifndef HAVE_RANDOM
976 #define srandom(x) srand(x)
977 #define random(x) rand(x)
978 #endif
979
980 #ifndef HAVE_TIMEGM
981 #include <time.h>
982 time_t timegm (struct tm *tm);
983 #endif /* !TIMEGM */
984 #ifndef HAVE_GMTIME_R
985 struct tm *gmtime_r(const time_t *timep, struct tm *result);
986 #endif
987 #ifndef HAVE_LOCALTIME_R
988 struct tm *localtime_r(const time_t *timep, struct tm *result);
989 #endif
990 #ifndef HAVE_ISBLANK
991 int isblank(int c);
992 #endif /* !HAVE_ISBLANK */
993 #ifndef HAVE_ISASCII
994 int isascii(int c);
995 #endif /* !HAVE_ISASCII */
996 #ifndef HAVE_SNPRINTF
997 #include <stdarg.h>
998 int snprintf (char *str, size_t count, const char *fmt, ...);
999 int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
1000 #endif /* HAVE_SNPRINTF */
1001 #ifndef HAVE_INET_PTON
1002 int inet_pton(int af, const char* src, void* dst);
1003 #endif /* HAVE_INET_PTON */
1004 #ifndef HAVE_INET_NTOP
1005 const char *inet_ntop(int af, const void *src, char *dst, size_t size);
1006 #endif
1007 #ifndef HAVE_INET_ATON
1008 int inet_aton(const char *cp, struct in_addr *addr);
1009 #endif
1010 #ifndef HAVE_MEMMOVE
1011 void *memmove(void *dest, const void *src, size_t n);
1012 #endif
1013 #ifndef HAVE_STRLCPY
1014 size_t strlcpy(char *dst, const char *src, size_t siz);
1015 #endif
1016
1017 #ifdef USE_WINSOCK
1018 #define SOCK_INVALID INVALID_SOCKET
1019 #define close_socket(_s) do { if (_s > SOCK_INVALID) {closesocket(_s); _s = SOCK_INVALID;} } while(0)
1020 #else
1021 #define SOCK_INVALID -1
1022 #define close_socket(_s) do { if (_s > SOCK_INVALID) {close(_s); _s = SOCK_INVALID;} } while(0)
1023 #endif
1024
1025 #ifdef __cplusplus
1026 }
1027 #endif
1028 #ifndef HAVE_GETADDRINFO
1029 #include "compat/fake-rfc2553.h"
1030 #endif
1031 #ifndef HAVE_STRTOUL
1032 #define strtoul (unsigned long)strtol
1033 #endif
1034 ])
1035
1036 if test "x$HAVE_SSL" = "xyes"; then
1037         AC_SUBST(ldns_build_config_have_ssl, 1)
1038 else
1039         AC_SUBST(ldns_build_config_have_ssl, 0)
1040 fi
1041 if test "x$ac_cv_c_format_attribute" = "xyes"; then
1042   AC_SUBST(ldns_build_config_have_attr_format, 1)
1043 else
1044   AC_SUBST(ldns_build_config_have_attr_format, 0)
1045 fi
1046 if test "x$ac_cv_c_unused_attribute" = "xyes"; then
1047   AC_SUBST(ldns_build_config_have_attr_unused, 1)
1048 else
1049   AC_SUBST(ldns_build_config_have_attr_unused, 0)
1050 fi
1051
1052 CONFIG_FILES="Makefile ldns/common.h ldns/net.h ldns/util.h packaging/libldns.pc packaging/ldns-config"
1053 AC_SUBST(CONFIG_FILES)
1054 AC_CONFIG_FILES([$CONFIG_FILES])
1055
1056 AC_CONFIG_HEADER([ldns/config.h])
1057 AC_OUTPUT
1058 COPY_HEADER_FILES(ldns/, ldns/)
1059
1060 dnl AC_CONFIG_SUBDIRS([drill])
1061
1062