]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
build: fix configure compatiblity with POSIX shells
authorMatthias Schiffer <jengelh@inai.de>
Sun, 3 Apr 2016 12:01:01 +0000 (14:01 +0200)
committerJan Engelhardt <jengelh@inai.de>
Tue, 5 Apr 2016 10:25:13 +0000 (12:25 +0200)
The kernel version detection code uses some bashisms, which makes the
build fail on Debian systems where /bin/sh links to dash. Replace with
POSIX-conforming commands at the cost of requiring awk.

configure.ac

index 82a1355f47f2a47d920ec682a915eed03b2e96b5..43a8158fff94e752758bf50e1e68624ee36f456b 100644 (file)
@@ -44,21 +44,15 @@ regular_CFLAGS="-Wall -Waggregate-return -Wmissing-declarations \
 
 if test -n "$kbuilddir"; then
        AC_MSG_CHECKING([kernel version that we will build against])
-       krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease)";
-       kmajor="${krel%%[[^0-9]]*}";
-       kmajor="$(($kmajor+0))";
-       krel="${krel:${#kmajor}}";
-       krel="${krel#.}";
-       kminor="${krel%%[[^0-9]]*}";
-       kminor="$(($kminor+0))";
-       krel="${krel:${#kminor}}";
-       krel="${krel#.}";
-       kmicro="${krel%%[[^0-9]]*}";
-       kmicro="$(($kmicro+0))";
-       krel="${krel:${#kmicro}}";
-       krel="${krel#.}";
-       kstable="${krel%%[[^0-9]]*}";
-       kstable="$(($kstable+0))";
+       krel="$(make -sC "$kbuilddir" M=$PWD kernelrelease | $AWK -v 'FS=[[^0-9.]]' '{print $1; exit}')"
+       save_IFS="$IFS"
+       IFS='.'
+       set x $krel
+       IFS="$save_IFS"
+       kmajor="$(($2+0))"
+       kminor="$(($3+0))"
+       kmicro="$(($4+0))"
+       kstable="$(($5+0))"
        if test -z "$kmajor" -o -z "$kminor" -o -z "$kmicro"; then
                echo "WARNING: Version detection did not succeed. Continue at own luck.";
        else