-
Notifications
You must be signed in to change notification settings - Fork 11
/
configure.ac
114 lines (89 loc) · 2.6 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
dnl configure.ac
AC_PREREQ([2.71])
AC_INIT([resolv],[0.0],[[email protected]])
AC_CONFIG_SRCDIR([resolv.cabal])
AC_CONFIG_HEADERS([cbits/hs_resolv_config.h])
AC_PROG_CC
AC_C_CONST
dnl ignore options --with-compiler and --with-hc passed by cabal configure
AC_ARG_WITH([compiler], [], [], [])
AC_ARG_WITH([hc], [], [], [])
AC_CHECK_HEADERS([netinet/in.h arpa/nameser.h])
AC_CHECK_HEADER([resolv.h],,AC_MSG_ERROR([required <resolv.h> header not found]),[[
#include <sys/types.h>
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
#include <resolv.h>
]])
AC_CHECK_DECLS([res_query, res_nquery], [], [], [[
#include <sys/types.h>
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
#include <resolv.h>
]])
AC_CHECK_DECLS([h_errno], [], [], [[
#include <netdb.h>
]])
dnl ----------------------------------------------------------------------------
RESOLV_SEARCH_LIBS([res_query],[res_query(0,0,0,0,0)],[resolv bind network],[EXTRA_LIBS="$EXTRA_LIBS $ac_lib"],[
AC_MSG_ERROR([could not figure out which C library contains res_query(3)])
])
AH_TEMPLATE([USE_RES_NQUERY],[Define to 1 in order to use res_nquery(3) API])
USE_RES_NQUERY=0
if test "x$ac_cv_have_decl_res_nquery" = xyes; then
AC_CHECK_SIZEOF([struct __res_state],[],[[
#include <sys/types.h>
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
#include <resolv.h>
]])
SIZEOF_RES_STATE="$ac_cv_sizeof_struct___res_state"
if test "$SIZEOF_RES_STATE" -gt 0; then
USE_RES_NQUERY=1
RESOLV_SEARCH_LIBS([res_nquery],[res_nquery(0,0,0,0,0,0)],[resolv bind],[[EXTRA_LIBS="$EXTRA_LIBS $ac_lib"]],[
USE_RES_NQUERY=0
AC_MSG_WARN([could not figure out which C library contains res_nquery(3)])
])
AC_CHECK_MEMBERS([struct __res_state.res_h_errno],[],[],[[
#include <sys/types.h>
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
#include <resolv.h>
]])
else
AC_MSG_WARN([could not determine sizeof(struct __res_state)])
fi
fi
AC_MSG_CHECKING([which DNS api to use])
case "x$USE_RES_NQUERY" in
x0) AC_MSG_RESULT([res_query(3)])
CPP_OPTIONS="-DUSE_RES_NQUERY=0 -DSIZEOF_RES_STATE=0"
;;
x1) AC_MSG_RESULT([res_nquery(3)])
CPP_OPTIONS="-DUSE_RES_NQUERY=1 -DSIZEOF_RES_STATE=$SIZEOF_RES_STATE"
;;
*) AC_MSG_ERROR([no suitable DNS API detected])
;;
esac
AC_DEFINE_UNQUOTED([USE_RES_NQUERY],[$USE_RES_NQUERY])
AC_SUBST([CPP_OPTIONS])
AC_SUBST([EXTRA_LIBS])
AC_CONFIG_FILES([resolv.buildinfo])
AC_OUTPUT
dnl EOF