Debian Codegraph @

modules/contrib/m4/atheme-contrib-libtest-res-query.m4

raw
1 # SPDX-License-Identifier: ISC
2 # SPDX-URL: https://spdx.org/licenses/ISC.html
3 #
4 # Copyright (C) 2005-2009 Atheme Project (http://atheme.org/)
5 # Copyright (C) 2018-2019 Atheme Development Group (https://atheme.github.io/)
6 #
7 # -*- Atheme IRC Services -*-
8 # Atheme Build System Component
9
10 ATHEME_CONTRIB_LIBTEST_RES_QUERY_RESULT=""
11
12 AC_DEFUN([ATHEME_CONTRIB_LIBTEST_RES_QUERY_DRIVER], [
13
14 AC_LINK_IFELSE([
15 AC_LANG_PROGRAM([[
16 #ifdef HAVE_STDDEF_H
17 # include <stddef.h>
18 #endif
19 #ifdef HAVE_SYS_TYPES_H
20 # include <sys/types.h>
21 #endif
22 #ifdef HAVE_NETINET_IN_H
23 # include <netinet/in.h>
24 #endif
25 #ifdef HAVE_ARPA_NAMESER_H
26 # include <arpa/nameser.h>
27 #endif
28 #ifdef HAVE_NETDB_H
29 # include <netdb.h>
30 #endif
31 #ifdef HAVE_RESOLV_H
32 # include <resolv.h>
33 #endif
34 #ifndef C_ANY
35 # define C_ANY ns_c_any
36 #endif
37 #ifndef T_MX
38 # define T_MX ns_t_mx
39 #endif
40 #ifndef S_AN
41 # define S_AN ns_s_an
42 #endif
43 ]], [[
44 ns_msg amsg;
45 const int ret = res_query(NULL, C_ANY, T_MX, NULL, 0);
46 (void) ns_initparse(NULL, ret, &amsg);
47 const int cnt = ns_msg_count(amsg, S_AN);
48 ]])
49 ], [
50 ATHEME_CONTRIB_LIBTEST_RES_QUERY_RESULT="yes"
51 ], [
52 ATHEME_CONTRIB_LIBTEST_RES_QUERY_RESULT="no"
53 ])
54 ])
55
56 AC_DEFUN([ATHEME_CONTRIB_LIBTEST_RES_QUERY_FAIL], [
57
58 AC_MSG_WARN([the ns_mxcheck and ns_mxcheck_async modules will not be available])
59 ])
60
61 AC_DEFUN([ATHEME_CONTRIB_LIBTEST_RES_QUERY_SUCCESS], [
62
63 AC_DEFINE([HAVE_RES_QUERY], [1], [Define to 1 if res_query(3) appears to be usable])
64 ])
65
66 AC_DEFUN([ATHEME_CONTRIB_LIBTEST_RES_QUERY], [
67
68 LIBS_SAVED="${LIBS}"
69
70 AC_SEARCH_LIBS([gethostbyname], [nsl], [
71
72 AC_HEADER_RESOLV
73 AC_MSG_CHECKING([whether compiling and linking a program using res_query(3) works])
74
75 ATHEME_CONTRIB_LIBTEST_RES_QUERY_DRIVER
76 AS_IF([test "${ATHEME_CONTRIB_LIBTEST_RES_QUERY_RESULT}" = "yes"], [
77 AC_MSG_RESULT([yes])
78 ATHEME_CONTRIB_LIBTEST_RES_QUERY_SUCCESS
79 ], [
80 LIBS="-lresolv ${LIBS}"
81 ATHEME_CONTRIB_LIBTEST_RES_QUERY_DRIVER
82 AS_IF([test "${ATHEME_CONTRIB_LIBTEST_RES_QUERY_RESULT}" = "yes"], [
83 AC_MSG_RESULT([yes])
84 ATHEME_CONTRIB_LIBTEST_RES_QUERY_SUCCESS
85 ], [
86 AC_MSG_RESULT([no])
87 ATHEME_CONTRIB_LIBTEST_RES_QUERY_FAIL
88 LIBS="${LIBS_SAVED}"
89 ])
90 ])
91 ], [
92 ATHEME_CONTRIB_LIBTEST_RES_QUERY_FAIL
93 ], [])
94
95 unset LIBS_SAVED
96 ])