1dnl
2dnl  $Id: acsite.m4 808 2004-09-08 05:34:53Z vkurland $
3dnl
4
5
6dnl Test files
7define( [AC_TEST_FILES],
8[
9    ac_file_found=yes
10    for f in $1; do
11        if test ! -f $2/$f; then
12           ac_file_found=no
13           break;
14        fi
15    done
16
17    if test "$ac_file_found" = "yes" ; then
18        ifelse([$3], , :,[$3])
19    else
20        ifelse([$4], , :,[$4])
21    fi
22])
23
24
25
26dnl Search for headers, add path to CPPFLAGS if found
27define( [AC_SEARCH_HEADERS],
28[
29    AC_MSG_CHECKING("for $1")
30    ac_hdr_found=no
31    for p in $2; do
32        AC_TEST_FILES($1, $p,
33            [
34               ac_hdr_found=yes
35               break
36            ]
37        )
38    done
39    if test "$ac_hdr_found" = "yes" ; then
40        CPPFLAGS="$CPPFLAGS -I$p"
41        AC_MSG_RESULT( [($p) yes] )
42        ifelse([$3], , :,[$3])
43    else
44        AC_MSG_RESULT("no")
45        ifelse([$4], , :,[$4])
46    fi
47])
48
49dnl checks for ucd-snmp or netsnmp library and sets
50dnl vars LIBSNMP_LIBS and HAVE_LIBSNMP
51dnl
52dnl call like this:
53dnl   AC_CHECK_LIBSNMP ( snmp    )
54dnl   AC_CHECK_LIBSNMP ( netsnmp )
55dnl
56define( [AC_CHECK_LIBSNMP],
57[
58  ac_snmplib_name="$1"
59
60  ac_snmplib_name=`echo ${ac_snmplib_name} | tr -d " "`
61
62  AC_CHECK_LIB($ac_snmplib_name, init_snmp,
63  [
64          LIBSNMP_LIBS="-l$ac_snmplib_name"
65	  HAVE_LIBSNMP="1"
66          AC_DEFINE(HAVE_LIBSNMP)
67  ],[
68
69    if test "${ac_cv_lib_snmp_init_snmp+set}" = "set"; then
70        unset ac_cv_lib_snmp_init_snmp
71    fi
72
73    save_LIBS="$LIBS"
74    LIBS="$LIBS -lcrypto"
75    AC_CHECK_LIB($ac_snmplib_name, init_snmp,
76    [
77          LIBS="$save_LIBS"
78          LIBSNMP_LIBS="-lcrypto -l$ac_snmplib_name"
79	  HAVE_LIBSNMP="1"
80          AC_DEFINE(HAVE_LIBSNMP)
81    ],[
82	echo
83
84dnl      if test "${ac_cv_lib_snmp_init_snmp+set}" = "set"; then
85dnl        unset ac_cv_lib_snmp_init_snmp
86dnl      fi
87dnl
88dnl      save_LIBS="$LIBS"
89dnl      LIBS="$LIBS -ldes"
90dnl      AC_CHECK_LIB($ac_snmplib_name, init_snmp,
91dnl      [
92dnl          LIBS="$save_LIBS"
93dnl          LIBSNMP_LIBS="-ldes -l$ac_snmplib_name"
94dnl	  HAVE_LIBSNMP="1"
95dnl          AC_DEFINE(HAVE_LIBSNMP)
96dnl      ])
97    ])
98  ])
99
100
101dnl  if test "Z$HAVE_LIBSNMP" != "Z"; then
102dnl    AC_CHECK_LIB($ac_snmplib_name, snprint_objid, [
103dnl        AC_DEFINE(HAVE_SNPRINT_OBJID)
104dnl    ])
105dnl  fi
106])
107
108
109define( [AC_CHECK_GETHOSTBYNAME_R],
110[
111  ac_define_this="$1"
112  if test -z "$ac_define_this"; then ac_define_this="__FWB_DUMMY__"; fi
113
114AC_MSG_CHECKING(if gethostbyname_r takes 3 arguments)
115AC_TRY_COMPILE([
116#define $ac_define_this
117#include <netdb.h>
118],[
119
120        char *name;
121        struct hostent *he;
122        struct hostent_data data;
123        (void) gethostbyname_r(name, he, &data);
124
125  ],
126	AC_MSG_RESULT(yes)
127        AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3)
128        ac_cv_func_which_gethostname_r="3",
129  [
130dnl			ac_cv_func_which_gethostname_r=no
131  AC_MSG_RESULT(no)
132  AC_MSG_CHECKING(if gethostbyname_r takes 6 arguments)
133  AC_TRY_COMPILE([
134#define $ac_define_this
135#include <netdb.h>
136  ],[
137	char *name;
138	struct hostent *he, *res;
139	char buffer[2048];
140	int buflen = 2048;
141	int h_errnop;
142	(void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop)
143    ],
144	AC_MSG_RESULT(yes)
145        AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6)
146        ac_cv_func_which_gethostname_r="6",
147    [
148dnl  ac_cv_func_which_gethostname_r=no
149    AC_MSG_RESULT(no)
150    AC_MSG_CHECKING(if gethostbyname_r takes 5 arguments)
151    AC_TRY_COMPILE([
152#define $ac_define_this
153#include <netdb.h>
154    ],[
155			char *name;
156			struct hostent *he;
157			char buffer[2048];
158			int buflen = 2048;
159			int h_errnop;
160			(void) gethostbyname_r(name, he, buffer, buflen, &h_errnop)
161      ],
162	AC_MSG_RESULT(yes)
163        AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5)
164        ac_cv_func_which_gethostname_r="5",
165      [
166	AC_MSG_RESULT(no)
167        ac_cv_func_which_gethostname_r=no])
168    ])
169  ] ,ac_cv_func_which_gethostname_r=no)
170])
171
172
173
174
175
176
177dnl check for number of arguments to gethostbyaddr_r. it might take
178dnl 5, 7, or 8 arguments.
179
180define( [AC_CHECK_GETHOSTBYADDR_R],
181[
182  ac_define_this="$1"
183  if test -z "$ac_define_this"; then ac_define_this="__FWB_DUMMY__"; fi
184
185
186AC_MSG_CHECKING(if gethostbyaddr_r takes 5 arguments)
187AC_TRY_COMPILE([
188#define $ac_define_this
189#include <sys/types.h>
190#include <netdb.h>
191],[
192char * address;
193int length;
194int type;
195struct hostent h;
196struct hostent_data hdata;
197int rc;
198rc = gethostbyaddr_r(address, length, type, &h, &hdata);
199],[
200      AC_MSG_RESULT(yes)
201      AC_DEFINE(HAVE_GETHOSTBYADDR_R_5)
202      ac_cv_gethostbyaddr_args=5
203],[
204
205
206      AC_MSG_RESULT(no)
207      AC_MSG_CHECKING(if gethostbyaddr_r takes 7 arguments)
208      AC_TRY_COMPILE([
209#define $ac_define_this
210#include <sys/types.h>
211#include <netdb.h>
212],[
213char * address;
214int length;
215int type;
216struct hostent h;
217char buffer[8192];
218int h_errnop;
219struct hostent * hp;
220
221hp = gethostbyaddr_r(address, length, type, &h,
222                     buffer, 8192, &h_errnop);
223],[
224	  AC_MSG_RESULT(yes)
225	  AC_DEFINE(HAVE_GETHOSTBYADDR_R_7)
226	  ac_cv_gethostbyaddr_args=7
227],[
228
229
230	  AC_MSG_RESULT(no)
231	  AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments and first arg is (in_addr*))
232	  AC_TRY_COMPILE([
233#define $ac_define_this
234#include <sys/types.h>
235#include <netdb.h>
236],[
237struct in_addr *address;
238int length;
239int type;
240struct hostent h;
241char buffer[8192];
242int h_errnop;
243struct hostent * hp;
244int rc;
245
246rc = gethostbyaddr_r(address, length, type, &h,
247                     buffer, 8192, &hp, &h_errnop);
248],[
249	    AC_MSG_RESULT(yes)
250	    AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
251            AC_DEFINE(GETHOSTBYADDR_FIRST_ARG_VOIDPTR)
252            ac_cv_gethostbyaddr_first_arg="voidptr"
253	    ac_cv_gethostbyaddr_args=8
254],[
255	    AC_MSG_RESULT(no)
256
257	    AC_MSG_CHECKING(if gethostbyaddr_r takes 8 arguments and first arg is (char*))
258	    AC_TRY_COMPILE([
259#define $ac_define_this
260#include <sys/types.h>
261#include <netdb.h>
262],[
263char * address;
264int length;
265int type;
266struct hostent h;
267char buffer[8192];
268int h_errnop;
269struct hostent * hp;
270int rc;
271
272rc = gethostbyaddr_r(address, length, type, &h,
273                     buffer, 8192, &hp, &h_errnop);
274],[
275	    AC_MSG_RESULT(yes)
276	    AC_DEFINE(HAVE_GETHOSTBYADDR_R_8)
277            AC_DEFINE(GETHOSTBYADDR_FIRST_ARG_CHARPTR)
278            ac_cv_gethostbyaddr_first_arg="charptr"
279	    ac_cv_gethostbyaddr_args=8
280],[
281	    AC_MSG_RESULT(no)
282            have_missing_r_funcs="$have_missing_r_funcs gethostbyaddr_r"
283	    ac_cv_gethostbyaddr_args=no
284])
285])
286])
287])
288])
289])
290
291
292