Fix Linux kernel directories detection
Most modern Linux distributions have separate locations for bare
source and prebuilt ("build") files. Additionally, there are source
and build symlinks in /lib/modules/$(KERNEL_VERSION) pointing to
them. The order of directory search is now:
- configure command line values if both --with-linux and --with-linux-obj were defined
- If only --with-linux was defined, --with-linux-obj is assumed to have the same value as --with-linux
- If neither --with-linux nor --with-linux-obj were defined
autodetection is used:
- /lib/modules/$(uname -r)/{source,build} respectively, if exist
- The first directory in /lib/modules with the highest version number according to sort -V which contains source and build symlinks/directories
- The first directory matching /usr/src/kernels/* and /usr/src/linux-* with the highest version number according to sort -V. Here the source and prebuilt directories are assumed to be the same.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #9935
Closes #13096