1 --- /dev/null Tue May 5 22:32:27 1998
2 +++ mbrowse-0.3.0/acinclude.m4 Sun Jan 19 10:47:16 2003
4 +# Configure paths for net-snmp or ucd-snmp.
5 +# This is really messy, but should thouroughly
6 +# check everything, and be pretty foolproof.
7 +# Some of the tests seem redundant, but it seemed
8 +# the sanest way to make it fairly robust.
16 +# Various pieces were snagged from other m4 files.
19 +dnl AM_PATH_NETSNMP([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
21 +dnl Test for net-snmp and define NETSNMP_CFLAGS and NETSNMP_LIBS
23 +AC_DEFUN(AM_PATH_NETSNMP,[
24 + AC_ARG_WITH(snmp-type,
25 + [ --with-snmp-type=TYPE Which snmp version to use (net or ucd)],
26 + snmp_type="$withval",snmp_type="")
27 + AC_ARG_WITH(snmp-prefix,
28 + [ --with-snmp-prefix=PFX Prefix where net/ucd snmp is installed (optional)],
29 + snmp_prefix="$withval",snmp_prefix="")
30 + AC_ARG_WITH(snmp-include,
31 + [ --with-snmp-include=DIR Directory pointing to snmp include files (optional)],
32 + snmp_include="$withval",snmp_include="")
33 + AC_ARG_WITH(snmp-lib,
34 + [ --with-snmp-lib=LIB Directory containing the snmp library to use (optional)
35 + (Notes: -lib ignored for net-snmp, -lib and -include
37 + snmp_lib="$withval",snmp_lib="")
44 + dnl Check the user-provided include and libs first
47 + if test "x$snmp_include" != "x" ; then
48 + for trytype in ucd net ${snmp_type} ; do
49 + if test -d "$snmp_include/$trytype-snmp" ; then
50 + SNMP_CFLAGS="-I$snmp_include"
51 + guess_type="$trytype"
57 + if test "x$snmp_lib" != "x" ; then
58 + for trytype in libsnmp.sl libsnmp.so libsnmp.a libnetsnmp.sl libnetsnmp.so libnetsnmp.a ; do
59 + if test -r "$snmp_lib/$trytype" ; then
60 + SNMP_LIBS="-L$snmp_lib -lsnmp"
67 + dnl Check for --with-snmp-type and -prefix at the same time
70 + AC_MSG_CHECKING([for snmp-type])
72 + for tryprefix in /usr /usr/local /usr/pkg $snmp_prefix ; do
74 + if test "x$found_snmp_incl" = "x" ; then
75 + for trytype in ucd net ${snmp_type} ; do
76 + if test -d "$tryprefix/include/$trytype-snmp" ; then
77 + SNMP_CFLAGS="-I$tryprefix/include"
78 + guess_type="$trytype"
79 + backup_prefix="$tryprefix"
84 + if test "x$found_snmp_lib" = "x" ; then
85 + for trytype in libsnmp.sl libsnmp.so libsnmp.a libnetsnmp.sl libnetsnmp.so libnetsnmp.a ; do
86 + if test -r "$tryprefix/lib/$trytype" ; then
87 + SNMP_LIBS="-L$tryprefix/lib -lsnmp"
94 + if test "x$SNMP_LIBS" = "x" ; then
95 + if test "x$SNMP_CFLAGS" = "x" ; then
98 + echo "*** Could not locate any version of ucd-snmp or net-snmp"
100 + echo "*** Either it is not installed, or installed in a bizarre location."
102 + echo "*** Try using one of the following switches:"
103 + echo "*** --with-snmp-prefix=PFX"
104 + echo "*** --with-snmp-include=DIR"
105 + echo "*** --with-snmp-lib=DIR"
107 + ifelse([$3], ,:,[$3])
111 + echo "*** Found snmp headers, but could not locate the libraries."
113 + echo "*** Try using the following switch:"
114 + echo "*** --with-snmp-prefix=PFX"
115 + echo "*** --with-snmp-lib=DIR"
117 + ifelse([$3], ,:,[$3])
119 + elif test "x$SNMP_CFLAGS" = "x" ; then
122 + echo "*** Found snmp libraries, but could not locate headers."
124 + echo "*** If this was installed from a package, the -devel package"
125 + echo "*** was proabably not installed."
127 + echo "*** Otherwise, try one of the following switches:"
128 + echo "*** --with-snmp-prefix=PFX"
129 + echo "*** --with-snmp-include=DIR"
131 + ifelse([$3], ,:,[$3])
134 + if test "x$guess_type" = "xnet" ; then
135 + if test "x$snmp_prefix" != "x" ; then
136 + if test -x "$snmp_prefix/bin/net-snmp-config" ; then
137 + SNMP_LIBS=`$snmp_prefix/bin/net-snmp-config --libs`
138 + SNMP_CFLAGS="$SNMP_CFLAGS -DHAVE_NETSNMP"
143 + if test -x "$backup_prefix/bin/net-snmp-config" ; then
144 + SNMP_LIBS=`$backup_prefix/bin/net-snmp-config --libs`
145 + SNMP_CFLAGS="$SNMP_CFLAGS -DHAVE_NETSNMP"
152 + AC_MSG_RESULT($guess_type)
154 + if test "x$guess_type" = "xucd" ; then
155 + AC_CHECK_LIB(socket,getservbyname)
156 + AC_CHECK_FUNC(gethostbyname, [], AC_CHECK_LIB(nsl, gethostbyname))
157 + AC_CHECK_LIB(crypto,EVP_md5)
158 + AC_CHECK_LIB(kstat,kstat_lookup)
159 + elif test "x$guess_type" != "xnet" ; then
162 + echo "*** I have no clue what to do with this version of SNMP."
163 + echo "*** Net-snmp or ucd-snmp must be installed."
167 + ac_save_CFLAGS="$CFLAGS"
168 + ac_save_LIBS="$LIBS"
170 + CFLAGS="$CFLAGS $SNMP_CFLAGS"
171 + LIBS="$SNMP_LIBS $LIBS"
173 + AC_MSG_CHECKING([for $guess_type-snmp ifelse([$1], , ,[>= v$1])])
174 + dnl if no minimum version is given, just try to compile
175 + dnl else try to compile AND run
177 + if test "x$1" = "x" ; then
179 + #include <stdarg.h>
181 + #include <string.h>
182 + #include <sys/types.h>
183 + #ifdef HAVE_NETSNMP
184 + # include <net-snmp/net-snmp-config.h>
185 + # include <net-snmp/net-snmp-includes.h>
187 + # include <ucd-snmp/asn1.h>
188 + # include <ucd-snmp/snmp_api.h>
189 + # include <ucd-snmp/mib.h>
190 + # include <ucd-snmp/snmp.h>
193 + struct snmp_session s;
194 + bzero( &s, sizeof( struct snmp_session));
196 + ],[AC_MSG_RESULT(yes)
197 + CFLAGS="$ac_save_CFLAGS"
198 + LIBS="$ac_save_LIBS"
199 + ifelse([$2], ,:,[$2])
204 + snmp_min_version=$1
206 + #include <stdarg.h>
208 + #include <string.h>
210 + #include <sys/types.h>
211 + #ifdef HAVE_NETSNMP
212 + # include <net-snmp/net-snmp-config.h>
213 + # include <net-snmp/net-snmp-includes.h>
214 + # include <net-snmp/version.h>
216 + # include <ucd-snmp/asn1.h>
217 + # include <ucd-snmp/snmp_api.h>
218 + # include <ucd-snmp/mib.h>
219 + # include <ucd-snmp/snmp.h>
220 + # include <ucd-snmp/version.h>
224 + int major, minor,micro;
225 + int snmp_major, snmp_minor, snmp_micro;
226 + char *version1, *version2;
227 + struct snmp_session s;
229 + bzero(&s, sizeof( struct snmp_session));
232 + version1 = strdup( "$snmp_min_version" );
233 + if( sscanf( version1, "%d.%d.%d", &major, &minor, µ) != 2) {
234 + printf( "%s, bad supplied version string\n", "$netsnmp_min_version");
238 + #ifdef HAVE_NETSNMP
239 + version2 = strdup( NetSnmpVersionInfo );
241 + version2 = strdup( VersionInfo);
243 + if( sscanf( version2, "%d.%d.%d", &snmp_major, &snmp_minor, &snmp_micro) != 3) {
244 + /* Some people tripped on this with 4.2... check for it */
245 + if ( sscanf( version2, "%d.%d", &snmp_major, &snmp_minor) != 2) {
246 + printf( "%s, bad net-snmp version string\n", version2);
252 + if((snmp_major > major) ||
253 + ((snmp_major == major) && (snmp_minor > minor)) ||
254 + ((snmp_major == major) && (snmp_minor == minor)) ||
255 + ((snmp_major == major) && (snmp_minor == minor) && (snmp_micro >= micro))) {
257 + if ((snmp_major == 4) && (snmp_minor <= 2) && (snmp_micro <=1)) {
258 + printf("\n***\n*** You are running ucd-snmp < 4.2.2. It\n"
259 + "*** is strongly suggested that you upgrade\n"
260 + "*** for security reasons. See CERT Advisory\n"
261 + "**** CA-2002-03 for more details.\n***\n");
265 + printf("\n***\n*** An old version of net-snmp (%d.%d) was found.\n",
266 + snmp_major, snmp_minor);
267 + printf("*** You need a version of net-snmp newer than %d.%d. The latest version of\n",
269 + printf("*** net-snmp is available from ftp://net-snmp.sourceforge.net/ .\n***\n");
273 + ],[AC_MSG_RESULT(yes)
274 + CFLAGS="$ac_save_CFLAGS"
275 + LIBS="$ac_save_LIBS"
276 + ifelse([$2], ,:,[$2])
282 + if test "x$snmp_fail" != "x" ; then
285 + echo "*** Snmp test source had problems, check your config.log."
286 + echo "*** Chances are, it couldn't find the headers or libraries."
288 + echo "*** Also try one of the following switches :"
289 + echo "*** --with-snmp-prefix=PFX"
290 + echo "*** --with-snmp-include=DIR"
291 + echo "*** --with-snmp-lib=DIR"
293 + CFLAGS="$ac_save_CFLAGS"
294 + LDFLAGS="$ac_save_LDFLAGS"
295 + LIBS="$ac_save_LIBS"
296 + ifelse([$3], ,:,[$3])
299 + CFLAGS="$ac_save_CFLAGS"
300 + LDFLAGS="$ac_save_LDFLAGS"
301 + LIBS="$ac_save_LIBS"
303 + AC_SUBST(SNMP_CFLAGS)
304 + AC_SUBST(SNMP_LIBS)