[RFCv4,3/3] compat: disable multicast optimizations for old kernels
Commit Message
With this patch, the Makefile searches for the symbols needed
for the multicast optimizations in the kernel's .config and
Module.symvers. If they are not there, a warning is issued during "make"
and the multicast.c is excluded from the build process.
The advantage of this is that there's no need for hackish substitutions
in the original code base. Also, this approach is independant of the
actual kernel version, so it's easily possible to backport the upstream
functions to your own, older kernel if you desire.
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
Makefile | 6 ++++++
check-dependencies.sh | 29 +++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
create mode 100755 check-dependencies.sh
@@ -50,6 +50,12 @@ ifneq ($(REVISION),)
NOSTDINC_FLAGS += -DBATADV_SOURCE_VERSION=\"$(REVISION)\"
endif
+ifeq ($(CONFIG_BATMAN_ADV_MCAST),y)
+ifneq ($(shell $(PWD)/check-dependencies.sh $(KERNELPATH); echo $$?),0)
+ override CONFIG_BATMAN_ADV_MCAST=n
+endif
+endif
+
BUILD_FLAGS := \
M=$(PWD)/net/batman-adv \
CONFIG_BATMAN_ADV=m \
new file mode 100755
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+DEPS_CONFIG_BATMAN_ADV_MCAST="CONFIG_IPV6:ipv6_mc_check_mld ip_mc_check_igmp"
+
+KERNELPATH="$1"
+RET=0
+
+for s in $DEPS_CONFIG_BATMAN_ADV_MCAST; do
+ if [ -n "${s##*:*}" ]; then
+ conf=""
+ dep="$s"
+ else
+ conf="${s%%:*}"
+ dep="${s#*:}"
+ fi
+
+ [ -n "$conf" ] && ! egrep -q "$conf=(m|y)" ${KERNELPATH}/.config && \
+ continue
+
+ grep -q "$dep" ${KERNELPATH}/Module.symvers && continue
+
+ echo "WARNING: Missing built-in symbol \"$dep\" -" \
+ "disabling CONFIG_BATMAN_ADV_MCAST (Kernel too old?)" \
+ >&2
+
+ RET=1
+done
+
+exit $RET