])
#
+# LB_LINUX_UTSRELEASE
+#
+# Determine the Linux kernel version string from the utsrelease
+#
+AC_DEFUN([LB_LINUX_UTSRELEASE], [
+ AC_MSG_CHECKING([kernel source version])
+
+ utsrelease1=${LINUX_OBJ}/include/generated/utsrelease.h
+ utsrelease2=${LINUX_OBJ}/include/linux/utsrelease.h
+ utsrelease3=${LINUX_OBJ}/include/linux/version.h
+ AS_IF([test -r ${utsrelease1} && fgrep -q UTS_RELEASE ${utsrelease1}], [
+ utsrelease=${utsrelease1}
+ ], [test -r ${utsrelease2} && fgrep -q UTS_RELEASE ${utsrelease2}], [
+ utsrelease=${utsrelease2}
+ ], [test -r ${utsrelease3} && fgrep -q UTS_RELEASE ${utsrelease3}], [
+ utsrelease=${utsrelease3}
+ ])
+
+ AS_IF([test ! -z "${utsrelease}"], [
+ UTS_RELEASE=$(awk -F \" '/ UTS_RELEASE / { print [$]2 }' \
+ ${utsrelease})
+ AS_IF([test -z "$UTS_RELEASE"], [
+ AC_MSG_RESULT([Not found])
+ AC_MSG_ERROR([*** Cannot determine kernel version.])
+ ])
+ ], [
+ AC_MSG_RESULT([Not found])
+ AC_MSG_ERROR([
+ *** Cannot find UTS_RELEASE definition.
+ *** This is often provided by the kernel-devel package.])
+ ])
+
+ AC_MSG_RESULT([${UTS_RELEASE}])
+
+ LINUX_VERSION=${UTS_RELEASE}
+ AC_SUBST(LINUX_VERSION)
+ LINUXRELEASE=${UTS_RELEASE}
+ AC_SUBST(LINUXRELEASE)
+])
+
+
+#
# LB_LINUX_RELEASE
#
# get the release version of linux
#
AC_DEFUN([LB_LINUX_RELEASE],
-[LINUXRELEASE=
-rm -f build/conftest.i
-AC_MSG_CHECKING([for Linux release])
-if test -s $LINUX_OBJ/include/$AUTOCONF_HDIR/utsrelease.h ; then
- LINUXRELEASEHEADER=$AUTOCONF_HDIR/utsrelease.h
-else
- LINUXRELEASEHEADER=linux/version.h
-fi
-LB_LINUX_TRY_MAKE([
- #include <$LINUXRELEASEHEADER>
-],[
- char *LINUXRELEASE;
- LINUXRELEASE=UTS_RELEASE;
-],[
- $makerule LUSTRE_KERNEL_TEST=conftest.i
-],[
- test -s build/conftest.i
-],[
- # LINUXRELEASE="UTS_RELEASE"
- eval $(grep "LINUXRELEASE=" build/conftest.i)
-],[
- AC_MSG_RESULT([unknown])
- AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
-])
-rm -f build/conftest.i
-if test x$LINUXRELEASE = x ; then
- AC_MSG_RESULT([unknown])
- AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
-fi
-AC_MSG_RESULT([$LINUXRELEASE])
-AC_SUBST(LINUXRELEASE)
-
-moduledir='/lib/modules/'$LINUXRELEASE/updates/kernel
-AC_SUBST(moduledir)
-
-modulefsdir='$(moduledir)/fs/$(PACKAGE)'
-AC_SUBST(modulefsdir)
-
-modulenetdir='$(moduledir)/net/$(PACKAGE)'
-AC_SUBST(modulenetdir)
+[
+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=$withval],[
RELEASE=""
if test -n "$DOWNSTREAM_RELEASE"; then
RELEASE="${DOWNSTREAM_RELEASE}_"
fi
- RELEASE="$RELEASE`echo ${LINUXRELEASE} | tr '-' '_'`_$BUILDID")
+ RELEASE="$RELEASE`echo ${LINUXRELEASE} | tr '-' '_'`_$BUILDID"])
AC_MSG_RESULT($RELEASE)
AC_SUBST(RELEASE)
-# check is redhat/suse kernels
-AC_MSG_CHECKING([that RedHat kernel])
-LB_LINUX_TRY_COMPILE([
- #include <linux/version.h>
- ],[
- #ifndef RHEL_RELEASE_CODE
- #error "not redhat kernel"
- #endif
- ],[
+# check if the kernel is one from RHEL or SUSE
+AC_MSG_CHECKING([for RedHat kernel version])
+ AS_IF([fgrep -q RHEL_RELEASE ${LINUX_OBJ}/include/$VERSION_HDIR/version.h], [
RHEL_KERNEL="yes"
- AC_MSG_RESULT([yes])
- ],[
- AC_MSG_RESULT([no])
-])
+ RHEL_RELEASE=$(expr 0$(awk -F \" '/ RHEL_RELEASE / { print [$]2 }' \
+ ${LINUX_OBJ}/include/$VERSION_HDIR/version.h) + 1)
+ KERNEL_VERSION=$(sed -e 's/\(@<:@23@:>@\.@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/' <<< ${LINUXRELEASE})
+ RHEL_KERNEL_VERSION=${KERNEL_VERSION}-${RHEL_RELEASE}
+ AC_SUBST(RHEL_KERNEL_VERSION)
+ AC_MSG_RESULT([${RHEL_KERNEL_VERSION}])
+ ], [
+ AC_MSG_RESULT([not found])
+ LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
+ ])
+
+AC_MSG_CHECKING([for 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)
+
+moduledir='$(CROSS_PATH)/lib/modules/$(LINUXRELEASE)/$(KMP_MODDIR)/kernel'
+AC_SUBST(moduledir)
+
+modulefsdir='$(moduledir)/fs/$(PACKAGE)'
+AC_SUBST(modulefsdir)
-LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
+modulenetdir='$(moduledir)/net/$(PACKAGE)'
+AC_SUBST(modulenetdir)
])
[LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[AUTOCONF_HDIR=linux],
[AC_MSG_ERROR([Run make config in $LINUX.])])])
AC_SUBST(AUTOCONF_HDIR)
-LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h],[],
- [AC_MSG_ERROR([Run make config in $LINUX.])])
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h], [VERSION_HDIR=linux],
+ [LB_CHECK_FILE([$LINUX_OBJ/include/generated/uapi/linux/version.h],
+ [VERSION_HDIR=generated/uapi/linux],
+ [AC_MSG_ERROR([Run make config in $LINUX.])])
+ ])
+ AC_SUBST(VERSION_HDIR)
# ----------- kconfig.h exists ---------------
# kernel 3.1, $LINUX/include/linux/kconfig.h is added
# tarred up the tree and ran make dep etc. in it, then
# version.h gets overwritten with a standard linux one.
-if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
+if grep rhconfig $LINUX_OBJ/include/$VERSION_HDIR/version.h >/dev/null ; then
# This is a clean kernel-source tree, we need to
# enable extensive workarounds to get this to build
# modules
fi
# this is needed before we can build modules
+LB_LINUX_CROSS
LB_LINUX_VERSION
# --- check that we can build modules at all
AC_SUBST(SYMVERFILE)
])
+#
+# LB_LINUX_CROSS
+#
+# check for cross compilation
+#
+AC_DEFUN([LB_LINUX_CROSS],
+ [AC_MSG_CHECKING([for cross compilation])
+AS_IF([test "x$cross_compiling" = xno], [AC_MSG_RESULT([no])],
+ [case $host_vendor in
+ # The K1OM architecture is an extension of the x86 architecture
+ # and in MPSS 2.1 it's defined in $host_vendor. But in MPSS 3.x
+ # it's defined in $host_arch. So, try to support both case.
+ k1om | mpss)
+ AC_MSG_RESULT([Intel(R) Xeon Phi(TM)])
+ CC_TARGET_ARCH=`$CC -v 2>&1 | grep Target: | sed -e 's/Target: //'`
+ AC_SUBST(CC_TARGET_ARCH)
+ if test \( $CC_TARGET_ARCH != x86_64-k1om-linux \
+ -a $CC_TARGET_ARCH != k1om-mpss-linux \)
+ then
+ AC_MSG_ERROR([Cross compiler not found in PATH.])
+ fi
+ CROSS_VARS="ARCH=k1om CROSS_COMPILE=${CC_TARGET_ARCH}-"
+ CROSS_PATH="${CROSS_PATH:=/opt/lustre/${VERSION}/${CC_TARGET_ARCH}}"
+ CCAS=$CC
+ # need to produce special section for debuginfo extraction
+ LDFLAGS="${LDFLAGS} -Wl,--build-id"
+ EXTRA_KLDFLAGS="${EXTRA_KLDFLAGS} -Wl,--build-id"
+ if test x$enable_server != xno ; then
+ AC_MSG_WARN([Disabling server (not supported for k1om architecture).])
+ enable_server='no'
+ fi
+ ;;
+ *)
+ AC_MSG_RESULT([yes, but no changes])
+ ;;
+ esac
+ ])
+AC_SUBST(CROSS_VARS)
+AC_SUBST(CROSS_PATH)
+])
+
# these are like AC_TRY_COMPILE, but try to build modules against the
# kernel, inside the build directory
AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl
rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
-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_LNET_INCLUDE -I$LINUX/arch/`echo $target_cpu|sed -e 's/powerpc64/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/'`/include -I$LINUX/arch/`echo $target_cpu|sed -e 's/ppc.*/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/'`/include/generated -I$LINUX_OBJ/include -I$LINUX/include -I$LINUX_OBJ/include2 -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/powerpc64/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/' -e 's/k1om/x86/')
+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_OFED_INCLUDE -I$LINUX/arch/$SUBARCH/include -I$LINUX/arch/$SUBARCH/include/generated -Iinclude -I$LINUX/include -Iinclude2 -I$LINUX/include/uapi -I$LINUX/include/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" $CROSS_VARS $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
[$4],
[_AC_MSG_LOG_CONFTEST
m4_ifvaln([$5],[$5])dnl])
[AC_MSG_CHECKING([Linux kernel architecture])
AS_IF([rm -f $PWD/build/arch
make -s --no-print-directory echoarch -f $PWD/build/Makefile \
- LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX \
+ LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $CROSS_VARS \
ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
[AC_MSG_RESULT([$LINUX_ARCH])],
[AC_MSG_ERROR([Could not determine the kernel architecture.])])
)]
)
-#
-# LB_CONFIG_COMPAT_RDMA
-#
-AC_DEFUN([LB_CONFIG_COMPAT_RDMA],
-[AC_MSG_CHECKING([whether to use Compat RDMA])
-# set default
-AC_ARG_WITH([o2ib],
- AC_HELP_STRING([--with-o2ib=path],
- [build o2iblnd against path]),
- [
- case $with_o2ib in
- yes) O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
- ENABLEO2IB=2
- ;;
- no) ENABLEO2IB=0
- ;;
- *) O2IBPATHS=$with_o2ib
- ENABLEO2IB=3
- ;;
- esac
- ],[
- O2IBPATHS="$LINUX $LINUX/drivers/infiniband"
- ENABLEO2IB=1
- ])
-if test $ENABLEO2IB -eq 0; then
- AC_MSG_RESULT([no])
-else
- o2ib_found=false
- for O2IBPATH in $O2IBPATHS; do
- if test \( -f ${O2IBPATH}/include/rdma/rdma_cm.h -a \
- -f ${O2IBPATH}/include/rdma/ib_cm.h -a \
- -f ${O2IBPATH}/include/rdma/ib_verbs.h -a \
- -f ${O2IBPATH}/include/rdma/ib_fmr_pool.h \); then
- o2ib_found=true
- break
- fi
- done
- compatrdma_found=false
- if $o2ib_found; then
- if test \( -f ${O2IBPATH}/include/linux/compat-2.6.h \); then
- compatrdma_found=true
- AC_MSG_RESULT([yes])
- AC_DEFINE(HAVE_COMPAT_RDMA, 1, [compat rdma found])
- else
- AC_MSG_RESULT([no])
- fi
- fi
-fi
-])
-
-#
-# LB_CONFIG_OFED_BACKPORTS
-#
-# include any OFED backport headers in all compile commands
-# NOTE: this does only include the backport paths, not the OFED headers
-# adding the OFED headers is done in the lnet portion
-AC_DEFUN([LB_CONFIG_OFED_BACKPORTS],
-[AC_MSG_CHECKING([whether to use any OFED backport headers])
-if test $ENABLEO2IB -eq 0; then
- AC_MSG_RESULT([no])
-else
- if ! $o2ib_found; then
- AC_MSG_RESULT([no])
- case $ENABLEO2IB in
- 1) ;;
- 2) AC_MSG_ERROR([kernel OpenIB gen2 headers not present]);;
- 3) AC_MSG_ERROR([bad --with-o2ib path]);;
- *) AC_MSG_ERROR([internal error]);;
- esac
- else
- if ! $compatrdma_found; then
- if test -f $O2IBPATH/config.mk; then
- . $O2IBPATH/config.mk
- elif test -f $O2IBPATH/ofed_patch.mk; then
- . $O2IBPATH/ofed_patch.mk
- fi
- fi
- if test -n "$BACKPORT_INCLUDES"; then
- OFED_BACKPORT_PATH="$O2IBPATH/${BACKPORT_INCLUDES/*\/kernel_addons/kernel_addons}/"
- EXTRA_LNET_INCLUDE="-I$OFED_BACKPORT_PATH $EXTRA_LNET_INCLUDE"
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- fi
- fi
-fi
-])
-
# LC_MODULE_LOADING
# after 2.6.28 CONFIG_KMOD is removed, and only CONFIG_MODULES remains
# so we test if request_module is implemented or not
# 2.6.28
LC_MODULE_LOADING
-
-LB_CONFIG_COMPAT_RDMA
-
-# it's ugly to be doing anything with OFED outside of the lnet module, but
-# this has to be done here so that the backports path is set before all of
-# the LN_PROG_LINUX checks are done
-LB_CONFIG_OFED_BACKPORTS
])
#