]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - examples/configure.ac
import ldns 1.6.13
[FreeBSD/FreeBSD.git] / examples / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.56)
5 AC_INIT(ldns, 1.6.13, libdns@nlnetlabs.nl,libdns)
6 AC_CONFIG_SRCDIR([ldns-read-zone.c])
7 sinclude(../acx_nlnetlabs.m4)
8
9 OURCPPFLAGS=''
10 CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
11 OURCFLAGS='-g'
12 CFLAGS=${CFLAGS:-${OURCFLAGS}}
13 AC_DEFINE(WINVER, 0x0502, [the version of the windows API enabled])
14
15 AC_AIX
16 # Checks for programs.
17 AC_PROG_CC
18 AC_PROG_MAKE_SET
19 AC_CHECK_PROGS(libtool, [glibtool libtool15 libtool], [../libtool])
20
21 ACX_CHECK_COMPILER_FLAG(std=c99, [C99FLAG="-std=c99"])
22 ACX_CHECK_COMPILER_FLAG(xc99, [C99FLAG="-xc99"])
23
24 AC_ARG_ENABLE(rpath,
25         [AC_HELP_STRING([--disable-rpath], [Disable hardcoded rpath (default=enabled)])],
26         enable_rpath=$enableval, enable_rpath=yes)
27
28 if test "x$enable_rpath" = xyes; then
29     RPATH_VAL="-Wl,-rpath=\${libdir}"
30 fi
31
32
33 AC_TYPE_SIZE_T
34 ACX_CHECK_COMPILER_FLAG(O2, [CFLAGS="$CFLAGS -O2"])
35
36 ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600,
37 [
38 #include "confdefs.h"
39 #include <stdlib.h>
40 #include <ctype.h>
41 #include <sys/time.h>
42 #ifdef HAVE_TIME_H
43 #include <time.h>
44 #endif
45 #include <unistd.h>
46 #ifdef HAVE_GETOPT_H
47 #include <getopt.h>
48 #endif
49
50 int test() {
51         int a;
52         char **opts = NULL;
53         struct timeval tv;
54         char *t;
55         time_t time = 0;
56         char *buf = NULL;
57         t = ctime_r(&time, buf);
58         tv.tv_usec = 10;
59         srandom(32);
60         a = getopt(2, opts, "a");
61         a = isascii(32);
62         return a;
63 }
64 ], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600"])
65
66
67 ACX_CHECK_COMPILER_FLAG_NEEDED($C99FLAG, [#include <stdbool.h>], [CFLAGS="$CFLAGS $C99FLAG"])
68
69 AC_C_INLINE
70 AC_CHECK_TYPE(int8_t, char)
71 AC_CHECK_TYPE(int16_t, short)
72 AC_CHECK_TYPE(int32_t, int)
73 AC_CHECK_TYPE(int64_t, long long)
74 AC_CHECK_TYPE(uint8_t, unsigned char)
75 AC_CHECK_TYPE(uint16_t, unsigned short)
76 AC_CHECK_TYPE(uint32_t, unsigned int)
77 AC_CHECK_TYPE(uint64_t, unsigned long long)
78 AC_CHECK_TYPE(ssize_t, int)
79
80 AC_CHECK_HEADERS([sys/types.h getopt.h stdlib.h stdio.h assert.h netinet/in.h ctype.h time.h pcap.h arpa/inet.h sys/time.h sys/socket.h sys/select.h netdb.h],,, [AC_INCLUDES_DEFAULT])
81 AC_CHECK_HEADERS([winsock2.h ws2tcpip.h],,, [AC_INCLUDES_DEFAULT])
82 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],,, [
83 AC_INCLUDES_DEFAULT 
84 #ifdef HAVE_NETINET_IN_SYSTM_H
85 #include <netinet/in_systm.h>
86 #endif
87 #ifdef HAVE_NETINET_IN_H
88 #include <netinet/in.h>
89 #endif
90 #ifdef HAVE_SYS_SOCKET_H
91 #include <sys/socket.h>
92 #endif
93 #ifdef HAVE_NET_IF_H
94 #include <net/if.h>
95 #endif])
96
97 ACX_TYPE_SOCKLEN_T
98 AC_CHECK_HEADERS([sys/param.h sys/mount.h],,,
99 [AC_INCLUDES_DEFAULT]
100 [
101   [
102    #if HAVE_SYS_PARAM_H
103    # include <sys/param.h>
104    #endif
105   ]
106 ])
107 AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
108 #if HAVE_SYS_TYPES_H
109 # include <sys/types.h>
110 #endif
111 #if HAVE_NETINET_IN_H
112 # include <netinet/in.h>
113 #endif])
114 AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
115 #if HAVE_SYS_TYPES_H
116 # include <sys/types.h>
117 #endif
118 #if HAVE_NETINET_IN_H
119 # include <netinet/in.h>
120 #endif])
121
122 # check to see if libraries are needed for these functions.
123 AC_SEARCH_LIBS(socket, socket)
124 tmp_LIBS="$LIBS"
125 LIBS=
126 AC_SEARCH_LIBS(inet_pton, nsl)
127 AC_SUBST(LIBNSL_LIBS,$LIBS)
128 LIBS="$tmp_LIBS"
129
130 tmp_CPPFLAGS="$CPPFLAGS"
131 tmp_LDFLAGS="$LDFLAGS"
132 tmp_LIBS="$LIBS"
133
134 ACX_WITH_SSL_OPTIONAL
135
136 AC_SUBST(LIBSSL_CPPFLAGS)
137 AC_SUBST(LIBSSL_LDFLAGS)
138 AC_SUBST(LIBSSL_LIBS)
139
140 CPPFLAGS="$tmp_CPPFLAGS"
141 LDFLAGS="$tmp_LDFLAGS"
142 LIBS="$tmp_LIBS"
143
144 # use libcrypto to check the following:
145 tmp_LDFLAGS="$LDFLAGS"
146 tmp_LIBS="$LIBS"
147 LDFLAGS="$LDFLAGS $LIBSSL_LDFLAGS"
148 LIBS="$LIBS $LIBSSL_LIBS"
149 AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
150 case "$enable_sha2" in
151     no)
152         ;;
153     *)
154         AC_MSG_CHECKING(for SHA256 and SHA512)
155         AC_CHECK_FUNC(SHA256_Init,, [
156             AC_MSG_ERROR([SHA2 enabled, but no SHA2 functions found in OpenSSL])
157         ])
158         AC_DEFINE_UNQUOTED([USE_SHA2], [1], [Define this to enable SHA256 and SHA512 support.])
159         ;;
160 esac
161
162 AC_ARG_ENABLE(gost, AC_HELP_STRING([--disable-gost], [Disable GOST support]))
163 case "$enable_gost" in
164     no)
165         ;;
166     *)
167         if test "x$HAVE_SSL" != "xyes"; then
168             AC_MSG_ERROR([GOST enabled, but no SSL support])
169         fi
170         AC_MSG_CHECKING(for GOST)
171         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])])
172         AC_CHECK_FUNC(EC_KEY_new, [], [AC_MSG_ERROR([No ECC functions found in OpenSSL: please upgrade OpenSSL or rerun with --disable-gost])])
173         AC_DEFINE_UNQUOTED([USE_GOST], [1], [Define this to enable GOST support.])
174         ;;
175 esac
176
177 AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--enable-ecdsa], [Enable ECDSA support, experimental]))
178 case "$enable_ecdsa" in
179     yes)
180         AC_CHECK_FUNC(ECDSA_sign,,[AC_MSG_ERROR([OpenSSL does not support ECDSA])])
181         AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
182         AC_WARN([
183         *****************************************************************
184         *** YOU HAVE ENABLED ECDSA WHICH IS EXPERIMENTAL AT THIS TIME ***
185         *** PLEASE DO NOT USE THIS ON THE PUBLIC INTERNET             ***
186         *****************************************************************])
187       ;;
188     no|*)
189       ;;
190 esac
191
192 LDFLAGS="$tmp_LDFLAGS"
193 LIBS="$tmp_LIBS"
194
195 #AC_CHECK_HEADER(ldns/ldns.h,,  [
196 #       AC_MSG_ERROR([Can't find ldns headers (make copy-headers in devel source.)])
197 #       ], [AC_INCLUDES_DEFAULT]
198 #)
199
200 AC_CHECK_LIB(pcap, pcap_open_offline,, [
201         AC_MSG_WARN([Can't find pcap library (needed for ldns-dpa, will not build dpa now.)])
202         ]
203 )
204
205
206 AC_DEFUN([AC_CHECK_GETADDRINFO_WITH_INCLUDES],
207 [AC_REQUIRE([AC_PROG_CC])
208 AC_MSG_CHECKING(for getaddrinfo)
209 AC_CACHE_VAL(ac_cv_func_getaddrinfo,
210 [ac_cv_func_getaddrinfo=no
211 AC_LINK_IFELSE( 
212 [
213 #ifdef __cplusplus
214 extern "C"
215 {
216 #endif
217 char* getaddrinfo();
218 char* (*f) () = getaddrinfo;
219 #ifdef __cplusplus
220 }
221 #endif
222 int main() {
223         ;
224         return 0;
225 }
226 ],
227 dnl this case on linux, solaris, bsd
228 [ac_cv_func_getaddrinfo="yes"],
229 dnl no quick getaddrinfo, try mingw32 and winsock2 library.
230 ORIGLIBS="$LIBS"
231 LIBS="$LIBS -lws2_32"
232 AC_LINK_IFELSE(
233 AC_LANG_PROGRAM(
234 [
235 #ifdef HAVE_WS2TCPIP_H
236 #include <ws2tcpip.h>
237 #endif
238 ],
239 [
240         (void)getaddrinfo(NULL, NULL, NULL, NULL);
241 ]
242 ), 
243 [ac_cv_func_getaddrinfo="yes"
244 LDFLAGS="$LDFLAGS -lws2_32"
245 ],
246 [ac_cv_func_getaddrinfo="no" 
247 LIBS="$ORIGLIBS"
248 ])
249 )
250 ])
251
252 AC_MSG_RESULT($ac_cv_func_getaddrinfo)
253 if test $ac_cv_func_getaddrinfo = yes; then
254   AC_DEFINE(HAVE_GETADDRINFO, 1, [Whether getaddrinfo is available])
255 fi
256 ])dnl
257
258 AC_CHECK_GETADDRINFO_WITH_INCLUDES
259
260 AC_FUNC_FORK
261 AC_CHECK_FUNCS(isblank srandom random sleep)
262 AC_CHECK_DECLS([in6addr_any],,,[AC_INCLUDES_DEFAULT
263 #ifdef HAVE_SYS_SOCKET_H
264 #include <sys/socket.h>
265 #endif
266 #ifdef HAVE_TIME_H
267 #include <time.h>
268 #endif
269 #ifdef HAVE_SYS_TIME_H
270 #include <sys/time.h>
271 #endif
272 #ifdef HAVE_SYS_SELECT_H
273 #include <sys/select.h>
274 #endif
275 #ifdef HAVE_ARPA_INET_H
276 #include <arpa/inet.h>
277 #endif
278 #ifdef HAVE_NETINET_IN_H
279 #include <netinet/in.h>
280 #endif
281 #ifdef HAVE_NETINET_UDP_H
282 #include <netinet/udp.h>
283 #endif
284 #ifdef HAVE_NETINET_IGMP_H
285 #include <netinet/igmp.h>
286 #endif
287 ])
288
289 # check for ldns
290 AC_ARG_WITH(ldns, 
291         AC_HELP_STRING([--with-ldns=PATH        specify prefix of path of ldns library to use])
292         ,
293         [
294                 specialldnsdir="$withval"
295                 CPPFLAGS="$CPPFLAGS -I$withval/include"
296                 LDFLAGS="-L$withval -L$withval/lib $LDFLAGS"
297                 LDNSDIR="$withval"
298         ]
299 )
300
301 # check for ldns development source tree
302 AC_MSG_CHECKING([for ldns devel source])
303 ldns_dev_dir=..
304 if test -f $ldns_dev_dir/ldns/util.h && \
305         grep LDNS_VERSION $ldns_dev_dir/ldns/util.h >/dev/null; then
306         ldns_version=`grep LDNS_VERSION $ldns_dev_dir/ldns/util.h | sed -e 's/^.*"\(.*\)".*$/\1/'`
307         AC_MSG_RESULT([using $ldns_dev_dir with $ldns_version])
308         CPPFLAGS="$CPPFLAGS -I$ldns_dev_dir/include"
309         LDFLAGS="-L$ldns_dev_dir -L$ldns_dev_dir/lib $LDFLAGS"
310         LIBS="$LIBS -lldns"
311         AC_DEFINE(HAVE_LIBLDNS, 1, [If the ldns library is available.])
312         LDNSDIR="$ldns_dev_dir"
313 else
314         AC_MSG_RESULT([no])
315         AC_CHECK_LIB(ldns, ldns_rr_new,, [
316                         AC_MSG_ERROR([Can't find ldns library])
317                 ]
318         )
319 fi
320
321 AC_SUBST(LDNSDIR)
322
323
324 AH_BOTTOM([
325
326 #include <stdio.h>
327 #include <string.h>
328 #include <unistd.h>
329 #include <assert.h>
330
331 #if STDC_HEADERS
332 #include <stdlib.h>
333 #include <stddef.h>
334 #endif
335
336 #ifdef HAVE_STDINT_H
337 #include <stdint.h>
338 #endif
339
340 #ifdef HAVE_SYS_SOCKET_H
341 #include <sys/socket.h>
342 #endif
343
344 #ifdef HAVE_NETINET_IN_H
345 #include <netinet/in.h>
346 #endif
347
348 #ifdef HAVE_ARPA_INET_H
349 #include <arpa/inet.h>
350 #endif
351
352 #ifdef HAVE_NETINET_UDP_H
353 #include <netinet/udp.h>
354 #endif
355
356 #ifdef HAVE_TIME_H
357 #include <time.h>
358 #endif
359
360 #ifdef HAVE_PCAP_H
361 #include <pcap.h>
362 #endif
363
364 #ifdef HAVE_NETINET_IN_SYSTM_H
365 #include <netinet/in_systm.h>
366 #endif
367
368 #ifdef HAVE_NETINET_IP_H
369 #include <netinet/ip.h>
370 #endif
371
372 #ifdef HAVE_NET_IF_H
373 #include <net/if.h>
374 #endif
375
376 #ifdef HAVE_NETINET_IF_ETHER_H
377 #include <netinet/if_ether.h>
378 #endif
379
380 #ifdef HAVE_WINSOCK2_H
381 #define USE_WINSOCK 1
382 #include <winsock2.h>
383 #endif
384
385 #ifdef HAVE_WS2TCPIP_H
386 #include <ws2tcpip.h>
387 #endif
388
389 #ifndef HAVE_GETADDRINFO
390 #include <fake-rfc2553.h>
391 #endif
392
393 #ifndef HAVE_RANDOM
394 /* random can be replaced by rand for ldnsexamples */
395 #define random rand
396 #endif
397
398 #ifndef HAVE_SRANDOM
399 /* srandom can be replaced by srand for ldnsexamples */
400 #define srandom srand
401 #endif
402
403 extern char *optarg;
404 extern int optind, opterr;
405
406 #ifndef EXIT_FAILURE
407 #define EXIT_FAILURE  1
408 #endif
409 #ifndef EXIT_SUCCESS
410 #define EXIT_SUCCESS  0
411 #endif
412
413 #ifdef S_SPLINT_S
414 #define FD_ZERO(a) /* a */
415 #define FD_SET(a,b) /* a, b */
416 #endif
417 ])
418
419 AC_CONFIG_FILES([Makefile])
420 AC_CONFIG_HEADER([config.h])
421 AC_OUTPUT