]> git.ipfire.org Git - thirdparty/lldpd.git/blame - m4/snmp.m4
osx: sync homebrew formula
[thirdparty/lldpd.git] / m4 / snmp.m4
CommitLineData
d38eae28
VB
1#
2# lldp_CHECK_SNMP
3#
d38eae28 4AC_DEFUN([lldp_CHECK_SNMP], [
fa9b12c5 5 if test x"$with_snmp" != x"no"; then
d38eae28
VB
6 AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], [no])
7 if test x"$NETSNMP_CONFIG" = x"no"; then
fa9b12c5
VB
8 dnl No luck
9 if test x"$with_snmp" = x"yes"; then
10 AC_MSG_FAILURE([*** no NetSNMP support found])
11 fi
12 with_snmp=no
13 else
14 dnl Check it is working as expected
15 NETSNMP_LIBS=`${NETSNMP_CONFIG} --agent-libs`
16 NETSNMP_CFLAGS="`${NETSNMP_CONFIG} --base-cflags` -DNETSNMP_NO_INLINE"
d38eae28 17
fa9b12c5
VB
18 _save_flags="$CFLAGS"
19 _save_libs="$LIBS"
20 CFLAGS="$CFLAGS ${NETSNMP_CFLAGS}"
21 LIBS="$LIBS ${NETSNMP_LIBS}"
22 AC_MSG_CHECKING([whether C compiler supports flag "${NETSNMP_CFLAGS} ${NETSNMP_LIBS}" from Net-SNMP])
23 AC_LINK_IFELSE([AC_LANG_PROGRAM([
d38eae28
VB
24int main(void);
25],
26[
27{
28 return 0;
29}
fa9b12c5
VB
30])],[
31 AC_MSG_RESULT(yes)
32 dnl Is Net-SNMP usable?
33 AC_CHECK_LIB([netsnmp], [snmp_register_callback], [
34 dnl Do we have subagent support?
35 AC_CHECK_FUNCS([netsnmp_enable_subagent], [
36 dnl Yes, we need to check a few more things
37 AC_SUBST([NETSNMP_LIBS])
38 AC_SUBST([NETSNMP_CFLAGS])
39 AC_DEFINE_UNQUOTED([USE_SNMP], 1, [Define to indicate to enable SNMP support])
40 with_snmp=yes
ab2d1c1f 41
fa9b12c5
VB
42 dnl Should we use f_create_from_tstring_new or f_create_from_tstring?
43 AC_CHECK_MEMBERS([netsnmp_tdomain.f_create_from_tstring_new],,,[
d38eae28
VB
44@%:@include <net-snmp/net-snmp-config.h>
45@%:@include <net-snmp/net-snmp-includes.h>
46@%:@include <net-snmp/library/snmp_transport.h>
fa9b12c5
VB
47 ])
48 dnl Do we have a usable <net-snmp/agent/util_funcs.h> header?
49 AC_CHECK_HEADERS([net-snmp/agent/util_funcs.h],,,[
ab2d1c1f
VB
50@%:@include <net-snmp/net-snmp-config.h>
51@%:@include <net-snmp/net-snmp-includes.h>
52@%:@include <net-snmp/library/snmp_transport.h>
53@%:@include <net-snmp/agent/net-snmp-agent-includes.h>
54@%:@include <net-snmp/agent/snmp_vars.h>
fa9b12c5 55 ])
59c32cf0
VB
56 dnl Can we use snmp_select_info2?
57 AC_CHECK_FUNCS([snmp_select_info2])
fa9b12c5
VB
58 ],[
59 if test x"$with_snmp" = x"yes"; then
60 AC_MSG_ERROR([*** no subagent support in net-snmp])
61 fi
62 with_snmp=no
63 ])
64 ],[
65 if test x"$with_snmp" = x"yes"; then
66 AC_MSG_ERROR([*** unable to use net-snmp])
67 fi
68 with_snmp=no
69 ])
70 ],[
71 AC_MSG_RESULT(no)
72 if test x"$with_snmp" = x"yes"; then
73 AC_MSG_ERROR([*** incorrect CFLAGS from net-snmp-config])
74 fi
75 with_snmp=no
76 ])
d38eae28 77
fa9b12c5
VB
78 CFLAGS="$_save_flags"
79 LIBS="$_save_libs"
80 fi
81 fi
d38eae28 82])