automake: only pass net-snmp cflags to snmp-ups (#464)
Other than formerly assumed in the makefile cflags can be more than
includes. And some of them need to be in sync in regard to CFLAGS and
LDFLAGS - for example usage of -fPIE.
This conflicts with a current assumption in the makefile "In any case,
CFLAGS are only -I options, so there is no harm".
On a Distribution where PIE is enabled by default, but disabled for
special cases (like net-snmp) the configure detection gets them as:
LIBNETSNMP_CFLAGS = -DNETSNMP_ENABLE_IPV6 -fno-strict-aliasing -g -O2
-fdebug-prefix-map=/build/net-snmp-nlMQSZ/net-snmp-5.7.3+dfsg=.
-specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong
-Wformat -Werror=format-security -DNETSNMP_USE_INLINE -Ulinux
-Dlinux=linux -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv
-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -I/usr/lib/x86_64-linux-gnu/perl/5.26/CORE
-Wdate-time -D_FORTIFY_SOURCE=2 -I/usr/include
LIBNETSNMP_LIBS = -Wl,-Bsymbolic-functions
-specs=/usr/share/dpkg/no-pie-link.specs -Wl,-z,relro -Wl,-z,now
-L/usr/lib/x86_64-linux-gnu -lnetsnmp -lcrypto -lm
Of importance are:
-specs=/usr/share/dpkg/no-pie-compile.specs
-specs=/usr/share/dpkg/no-pie-link.specs
Now when compiling the non-snmp objects incorrectly get the
"-specs=/usr/share/dpkg/no-pie-compile.specs" due to the assumption
that it is safe to add up all CFLAGS to the global one.
LDFLAGS imported that way are only added to snmp.
snmp_ups_LDADD = $(LDADD_DRIVERS) $(LIBNETSNMP_LIBS)
[...]
snmp-ups$(EXEEXT): $(snmp_ups_OBJECTS) $(snmp_ups_DEPENDENCIES)
$(EXTRA_snmp_ups_DEPENDENCIES)
@rm -f snmp-ups$(EXEEXT) $(AM_V_CCLD)$(LINK) $(snmp_ups_OBJECTS) $(snmp_ups_LDADD)
$(LIBS)
That leads to other (all non snmp_ups) objects in drivers failing to build.
They get the no-pie-compile.specs (incorrect) spec but not the
no-pie-link.specs on the link step.
Some other parts like mge_shut and nutdrv_qx already have custom
CFLAGS/LDFLAGS that are not added to the global CFLAGS. So despite the
commend in the makefile this doesn't seem to be new in general to nut.
I don't want to mess too much with your build system for now as I don't
know many of its implications. So I chose not the full drop of that
global CFLAGS merge, but a minimal patch for now which fixes the issue
described.
Thereby closes #463
Signed-off-by: Christian Ehrhardt <email address hidden>
snmp-ups: fix the rounding / truncation of some values
The multiplier system of the snmp-ups driver resulted in some values being
rounded to the nearby integer value, thus causing a loss of the decimals and
the value precision in general. This was mainly visible on the value of
currents, but also on some voltages