# get the release version of linux
#
AC_DEFUN([LB_LINUX_RELEASE], [
-LB_LINUX_UTSRELEASE
-
-# ------------ RELEASE --------------------------------
-AC_MSG_CHECKING([for Lustre release])
-AC_ARG_WITH([release],
- AC_HELP_STRING([--with-release=string],
- [set the release string (default=$kvers_YYYYMMDDhhmm)]),
- [RELEASE=$withval], [
- RELEASE="$(echo $LINUXRELEASE | tr '-' '_')"])
-AC_MSG_RESULT($RELEASE)
-AC_SUBST(RELEASE)
-
-# check if the kernel is one from RHEL or SUSE
-AC_CACHE_CHECK([for RedHat kernel release number], lb_cv_rhel_kernel_version, [
-lb_cv_rhel_kernel_version=""
-AS_IF([fgrep -q RHEL_RELEASE $LINUX_OBJ/include/$VERSION_HDIR/version.h], [
- lb_cv_rhel_kernel_version=$(awk '/ RHEL_MAJOR / { print [$]3 }' \
- $LINUX_OBJ/include/$VERSION_HDIR/version.h)$(awk \
- '/ RHEL_MINOR / { print [$]3 }' \
- $LINUX_OBJ/include/$VERSION_HDIR/version.h)
-])
-])
-AS_IF([test -n "$lb_cv_rhel_kernel_version"], [
- RHEL_KERNEL="yes"
- RHEL_RELEASE_NO=$lb_cv_rhel_kernel_version
-], [
+ LB_LINUX_UTSRELEASE
+
+ # Define default states
RHEL_KERNEL="no"
- LB_CHECK_CONFIG([SUSE_KERNEL], [SUSE_KERNEL="yes"], [SUSE_KERNEL="no"])
-])
+ SUSE_KERNEL="no"
+ UBUNTU_KERNEL="no"
+ DEBIAN_KERNEL="no"
+ # And if any of the above kernels has been detected yet
+ KERNEL_FOUND="no"
+
+ # Check for RedHat first (no need to check KERNEL_FOUND
+ AC_CACHE_CHECK([for RedHat kernel release number], lb_cv_rhel_kernel_version, [
+ lb_cv_rhel_kernel_version=""
+ AS_IF([fgrep -q RHEL_RELEASE $LINUX_OBJ/include/$VERSION_HDIR/version.h], [
+ lb_cv_rhel_kernel_version=$(awk '/ RHEL_MAJOR / { print [$]3 }' \
+ $LINUX_OBJ/include/$VERSION_HDIR/version.h)$(awk \
+ '/ RHEL_MINOR / { print [$]3 }' \
+ $LINUX_OBJ/include/$VERSION_HDIR/version.h)
+ ])
+ ])
+ AS_IF([test -n "$lb_cv_rhel_kernel_version"], [
+ RHEL_KERNEL="yes"
+ KERNEL_FOUND="yes"
+ RHEL_RELEASE_NO=$lb_cv_rhel_kernel_version
+ ])
+
+ # Check for SuSE
+ AS_IF([test "x$KERNEL_FOUND" = "xno"], [
+ LB_CHECK_CONFIG([SUSE_KERNEL], [
+ SUSE_KERNEL="yes"
+ KERNEL_FOUND="yes"
+ ], [])
+ ])
+
+ # Check for Ubuntu
+ AS_IF([test "x$KERNEL_FOUND" = "xno"], [
+ AC_CACHE_CHECK([for Ubuntu kernel signature], lb_cv_ubuntu_kernel_sig, [
+ lb_cv_ubuntu_kernel_sig="no"
+ AS_IF([fgrep -q "CONFIG_VERSION_SIGNATURE \"Ubuntu" $LINUX_OBJ/include/generated/autoconf.h], [
+ lb_cv_ubuntu_kernel_sig="yes"
+ ])
+ ])
+ AS_IF([test "x$lb_cv_ubuntu_kernel_sig" = "xyes"], [
+ UBUNTU_KERNEL="yes"
+ KERNEL_FOUND="yes"
+ ])
+ ])
-AC_MSG_CHECKING([for Linux kernel module package directory])
-AC_ARG_WITH([kmp-moddir],
- AC_HELP_STRING([--with-kmp-moddir=string],
- [set the kmod updates or extra directory]),
- [KMP_MODDIR=$withval],[
- AS_IF([test x$RHEL_KERNEL = xyes], [KMP_MODDIR="extra"],
- [test x$SUSE_KERNEL = xyes], [KMP_MODDIR="updates"])])
-AC_MSG_RESULT($KMP_MODDIR)
-AC_SUBST(KMP_MODDIR)
+ # Check for Debian
+ AS_IF([test "x$KERNEL_FOUND" = "xno"], [
+ AC_CACHE_CHECK([for Debian kernel signature], lb_cv_debian_kernel_sig, [
+ lb_cv_debian_kernel_sig="no"
+ AS_IF([grep -q "LINUX_PACKAGE_ID\s*\"\s*Debian" $LINUX_OBJ/include/generated/package.h], [
+ lb_cv_debian_kernel_sig="yes"
+ ])
+ ])
+ AS_IF([test "x$lb_cv_debian_kernel_sig" = "xyes"], [
+ DEBIAN_KERNEL="yes"
+ KERNEL_FOUND="yes"
+ ])
+ ])
-moduledir='/lib/modules/$(LINUXRELEASE)/$(KMP_MODDIR)/kernel'
-AC_SUBST(moduledir)
+ # If still no kernel was found, a warning is issued
+ AS_IF([test "x$KERNEL_FOUND" = "xno"], [
+ AC_MSG_WARN([Kernel Distro seems to be neither RedHat, SuSE, Ubuntu nor Debian])
+ ])
+
+ AC_MSG_CHECKING([for Linux kernel module package directory])
+ AC_ARG_WITH([kmp-moddir],
+ AC_HELP_STRING([--with-kmp-moddir=string],
+ [set the kmod updates or extra directory]),
+ [KMP_MODDIR=$withval
+ IN_KERNEL=''],[
+ AS_IF([test x$RHEL_KERNEL = xyes], [KMP_MODDIR="extra/kernel"],
+ [test x$SUSE_KERNEL = xyes], [KMP_MODDIR="updates/kernel"],
+ [test x$UBUNTU_KERNEL = xyes], [KMP_MODDIR="updates/kernel"],
+ [test x$DEBIAN_KERNEL = xyes], [KMP_MODDIR="updates/kernel"],
+ [AC_MSG_WARN([Kernel Distro seems to be neither RedHat, SuSE, Ubuntu nor Debian])]
+ )
+ IN_KERNEL="${PACKAGE}"])
+ AC_MSG_RESULT($KMP_MODDIR)
+
+ moduledir="/lib/modules/${LINUXRELEASE}/${KMP_MODDIR}"
-modulefsdir='$(moduledir)/fs/$(PACKAGE)'
-AC_SUBST(modulefsdir)
+ modulefsdir="${moduledir}/fs/${IN_KERNEL}"
+ AC_SUBST(modulefsdir)
-modulenetdir='$(moduledir)/net/$(PACKAGE)'
-AC_SUBST(modulenetdir)
+ modulenetdir="${moduledir}/net/${IN_KERNEL}"
+ AC_SUBST(modulenetdir)
+
+ AC_SUBST(KMP_MODDIR)
])
#
# Find paths for linux, handling kernel-source rpms
#
AC_DEFUN([LB_LINUX_PATH], [
-for DEFAULT_LINUX in /lib/modules/$(uname -r)/{source,build} /usr/src/linux; do
+for DEFAULT_LINUX in /usr/src/linux-source-* /lib/modules/$(uname -r)/{source,build} /usr/src/linux $(find /usr/src/kernels/ -maxdepth 1 -name @<:@0-9@:>@\* | xargs -r ls -d | tail -n 1); do
AS_IF([readlink -q -e $DEFAULT_LINUX >/dev/null], [break])
done
if test "$DEFAULT_LINUX" = "/lib/modules/$(uname -r)/source"; then
PATHS="/lib/modules/$(uname -r)/build"
+else
+ PATHS="/usr/src/linux-headers-$(uname -r)"
fi
PATHS+=" $DEFAULT_LINUX"
for DEFAULT_LINUX_OBJ in $PATHS; do
[AC_MSG_ERROR([
Kernel config could not be found.
-
-If you are building from a kernel-source rpm consult build/README.kernel-source
])
])
AC_SUBST(LINUX_CONFIG)
AC_ARG_WITH([kernel-source-header],
AC_HELP_STRING([--with-kernel-source-header=path],
- [Use a different kernel version header. Consult build/README.kernel-source for details.]),
+ [Use a different kernel version header.]),
[LB_ARG_CANON_PATH([kernel-source-header], [KERNEL_SOURCE_HEADER])])
# ----------- make dep run? ------------------
AC_DEFUN([LB_USES_DPKG], [
AC_CACHE_CHECK([if this distro uses dpkg], lb_cv_uses_dpkg, [
lb_cv_uses_dpkg="no"
-AS_CASE([$(lsb_release -i -s 2>/dev/null)],
- [Ubuntu | Debian], [lb_cv_uses_dpkg="yes"])
+AS_CASE([$(which dpkg 2>/dev/null)],[*/dpkg], [lb_cv_uses_dpkg="yes"])
])
uses_dpkg=$lb_cv_uses_dpkg
])
m4_define([LB_LANG_PROGRAM],
[
#include <linux/kernel.h>
+#include <linux/module.h>
$1
int
main (void)
$2
;
return 0;
-}])
+};
+MODULE_LICENSE("GPL");])
#
# LB_LINUX_COMPILE_IFELSE
AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
[m4_ifvaln([$1], [AC_LANG_CONFTEST([AC_LANG_SOURCE([$1])])])dnl
rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
-SUBARCH=$(echo $target_cpu | sed -e 's/powerpc64le/powerpc/' -e 's/powerpc64/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/' -e 's/k1om/x86/' -e 's/aarch64/arm64/')
-AS_IF([AC_TRY_COMMAND(cp conftest.c build && make -d [$2] ${LD:+"LD=$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_CHECK_INCLUDE -I$LINUX/arch/$SUBARCH/include -Iinclude -Iarch/$SUBARCH/include/generated -I$LINUX/include -Iinclude2 -I$LINUX/include/uapi -Iinclude/generated -I$LINUX/arch/$SUBARCH/include/uapi -Iarch/$SUBARCH/include/generated/uapi -I$LINUX/include/uapi -Iinclude/generated/uapi ${SPL_OBJ:+-include $SPL_OBJ/spl_config.h} ${ZFS_OBJ:+-include $ZFS_OBJ/zfs_config.h} ${SPL:+-I$SPL -I$SPL/include } ${ZFS:+-I$ZFS -I$ZFS/include} -include $CONFIG_INCLUDE" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
+SUBARCH=$(echo $target_cpu | sed -e 's/powerpc.*/powerpc/' -e 's/ppc.*/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/' -e 's/k1om/x86/' -e 's/aarch64.*/arm64/' -e 's/armv7.*/arm/')
+AS_IF([AC_TRY_COMMAND(cp conftest.c build && make -d [$2] LDFLAGS= ${LD:+LD="$LD"} CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG LINUXINCLUDE="$EXTRA_CHECK_INCLUDE -I$LINUX/arch/$SUBARCH/include -Iinclude -Iarch/$SUBARCH/include/generated -I$LINUX/include -Iinclude2 -I$LINUX/include/uapi -Iinclude/generated -I$LINUX/arch/$SUBARCH/include/uapi -Iarch/$SUBARCH/include/generated/uapi -I$LINUX/include/uapi -Iinclude/generated/uapi ${SPL_OBJ:+-include $SPL_OBJ/spl_config.h} ${ZFS_OBJ:+-include $ZFS_OBJ/zfs_config.h} ${SPL:+-I$SPL -I$SPL/include } ${ZFS:+-I$ZFS -I$ZFS/include} -include $CONFIG_INCLUDE" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
[$4],
[_AC_MSG_LOG_CONFTEST
m4_ifvaln([$5],[$5])dnl])