1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.60)
5AC_INIT([surblhost], [0.8.0], [csl@sublevel3.org])
6AM_INIT_AUTOMAKE(dist-bzip2)
7AC_CONFIG_SRCDIR([src/surblhost.c])
8AC_CONFIG_HEADER([config.h])
9AC_REVISION([$Id: configure.ac 152 2007-04-09 15:06:55Z cslsublevel3org $])
10AC_CONFIG_FILES([Makefile src/Makefile])
11
12AC_PROG_CC
13AC_HEADER_STDC
14AC_C_CONST
15AC_C_INLINE
16AC_TYPE_SIZE_T
17
18AC_ARG_ENABLE([resolv],
19	[  --enable-resolv to use libresolv for DNS TXT queries (default: enable)],
20	[enable_resolv=$enableval],
21	[enable_resolv="yes"])
22
23AC_MSG_CHECKING([--enable-resolv])
24AC_MSG_RESULT([$enable_resolv])
25if test "x$enable_resolv" != "xno" ; then
26	AC_DEFINE([ENABLE_DNSTXT], [1], [Define to 1 if dns txt lookups should be supported])
27fi
28
29AC_CHECK_HEADERS([arpa/inet.h])
30AC_CHECK_HEADERS([netdb.h])
31AC_CHECK_HEADERS([arpa/nameser.h netinet/in.h sys/socket.h sys/types.h])
32AC_HEADER_RESOLV
33
34AC_CHECK_HEADERS([resolv.h], [], [],
35      [[#if HAVE_SYS_TYPES_H
36        #  include <sys/types.h>
37        #endif
38        #ifdef HAVE_NETINET_IN_H
39        #  include <netinet/in.h>   /* inet_ functions / structs */
40        #endif
41        #ifdef HAVE_ARPA_NAMESER_H
42        #  include <arpa/nameser.h> /* DNS HEADER struct */
43        #endif
44        #ifdef HAVE_SYS_SOCKET_H
45        #  include <sys/socket.h> /* DNS HEADER struct */
46        #endif
47     ]])
48
49AC_CHECK_HEADERS([nameser8_compat.h])
50
51AC_FUNC_MALLOC
52AC_FUNC_REALLOC
53
54AC_CHECK_LIB(nsl,main)
55AC_CHECK_LIB(socket,main)
56
57RESOLV_LIBS=""
58RESOLV_VARIANTS="resolv c"
59for resolv in ${RESOLV_VARIANTS}; do
60	AC_CHECK_LIB(${resolv}, [res_init], [RESOLV_LIBS="$RESOLV_LIBS -l${resolv}"; break])
61done
62if test -z "${RESOLV_LIBS}" ; then
63	AC_MSG_WARN([DNS TXT queries will be disabled (or use --disable-resolv)])
64else
65	LIBS="$LIBS $RESOLV_LIBS"
66	AC_DEFINE([HAS_WORKING_RESOLV], [1], [Define to 1 if DNS has res_init])
67fi
68
69AC_CHECK_FUNCS([gethostbyname])
70AC_CHECK_FUNCS([memset])
71AC_CHECK_FUNCS([inet_ntoa])
72
73AC_OUTPUT
74