summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5fabf39)
raw | patch | inline | side by side (parent: 5fabf39)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Sat, 13 Aug 2016 15:36:48 +0000 (17:36 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Sat, 13 Aug 2016 15:36:48 +0000 (17:36 +0200) |
net-snmp-config returns the settings used to compile and link
libnetsnmp, not the settings needed to compile and link code against it.
This resulted in various issues, namely overlinking, failure to compile
without compiler optimisations, and overriding of our compiler flags.
One example is the following, just noticed on RHEL5:
cc1: warnings being treated as errors
snmp.c: In function 'csnmp_config_add_host':
snmp.c:767: warning: ISO C90 forbids mixed declarations and code
make[3]: *** [snmp_la-snmp.lo] Error 1
We do compile in C99 mode, but net-snmp-config adds
-Wdeclaration-after-statement to our build command line. The GCC on
RHEL5 returns a warning, while later GCCs just ignore this.
libnetsnmp, not the settings needed to compile and link code against it.
This resulted in various issues, namely overlinking, failure to compile
without compiler optimisations, and overriding of our compiler flags.
One example is the following, just noticed on RHEL5:
cc1: warnings being treated as errors
snmp.c: In function 'csnmp_config_add_host':
snmp.c:767: warning: ISO C90 forbids mixed declarations and code
make[3]: *** [snmp_la-snmp.lo] Error 1
We do compile in C99 mode, but net-snmp-config adds
-Wdeclaration-after-statement to our build command line. The GCC on
RHEL5 returns a warning, while later GCCs just ignore this.
configure.ac | patch | blob | history | |
src/Makefile.am | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 2d4c68105ffcd59de132eafdbfe32156a976083b..251f785fa693f28bf7808a3237b4c3b4d7d1f3fd 100644 (file)
--- a/configure.ac
+++ b/configure.ac
# }}}
# --with-libnetsnmp {{{
-with_snmp_config="net-snmp-config"
-with_snmp_cflags=""
-with_snmp_libs=""
AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
[
if test "x$withval" = "xno"
@@ -3344,57 +3341,42 @@ AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Pat
then
with_libnetsnmp="yes"
else
- if test -x "$withval"
- then
- with_snmp_config="$withval"
- with_libnetsnmp="yes"
- else
- with_snmp_config="$withval/bin/net-snmp-config"
- with_libnetsnmp="yes"
- fi
+ with_libnetsnmp_cppflags="-I$withval/include"
+ with_libnetsnmp_ldflags="-I$withval/lib"
+ with_libnetsnmp="yes"
fi; fi
],
[with_libnetsnmp="yes"])
if test "x$with_libnetsnmp" = "xyes"
then
- with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
- snmp_config_status=$?
-
- if test $snmp_config_status -ne 0
- then
- with_libnetsnmp="no ($with_snmp_config failed)"
- else
- SAVE_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
+ SAVE_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
- AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
+ AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
- CPPFLAGS="$SAVE_CPPFLAGS"
- fi
+ CPPFLAGS="$SAVE_CPPFLAGS"
fi
if test "x$with_libnetsnmp" = "xyes"
then
- with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
- snmp_config_status=$?
+ SAVE_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
- if test $snmp_config_status -ne 0
- then
- with_libnetsnmp="no ($with_snmp_config failed)"
- else
- AC_CHECK_LIB(netsnmp, init_snmp,
+ AC_CHECK_LIB(netsnmp, init_snmp,
[with_libnetsnmp="yes"],
[with_libnetsnmp="no (libnetsnmp not found)"],
[$with_snmp_libs])
- fi
+
+ LDFLAGS="$SAVE_LDFLAGS"
fi
if test "x$with_libnetsnmp" = "xyes"
then
- BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
- BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
- AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
- AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
+ BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
+ BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
+ BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
fi
-AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
+AC_SUBST(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
+AC_SUBST(BUILD_WITH_LIBNETSNMP_LDFLAGS)
+AC_SUBST(BUILD_WITH_LIBNETSNMP_LIBS)
# }}}
# --with-liboconfig {{{
diff --git a/src/Makefile.am b/src/Makefile.am
index 12c7730cc95a5779a170ec9eb42de0a6b492bfe3..25d7bd40ef15643b8ff71536658db72b20dfa7c8 100644 (file)
--- a/src/Makefile.am
+++ b/src/Makefile.am
if BUILD_PLUGIN_SNMP
pkglib_LTLIBRARIES += snmp.la
snmp_la_SOURCES = snmp.c
-snmp_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-snmp_la_CFLAGS = $(AM_CFLAGS)
-snmp_la_LIBADD =
-if BUILD_WITH_LIBNETSNMP
-snmp_la_CFLAGS += $(BUILD_WITH_LIBSNMP_CFLAGS)
-snmp_la_LIBADD += $(BUILD_WITH_LIBSNMP_LIBS)
-endif
+snmp_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
+snmp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBNETSNMP_LDFLAGS)
+snmp_la_LIBADD = $(BUILD_WITH_LIBNETSNMP_LIBS)
endif
if BUILD_PLUGIN_STATSD