AC_MSG_RESULT([$LINUXRELEASE])
AC_SUBST(LINUXRELEASE)
-moduledir='/lib/modules/'$LINUXRELEASE/updates/kernel
+moduledir='$(CROSS_PATH)/lib/modules/$(LINUXRELEASE)/updates/kernel'
AC_SUBST(moduledir)
modulefsdir='$(moduledir)/fs/$(PACKAGE)'
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])
+CROSS_VARS=
+CROSS_PATH=
+case $target_vendor in
+ # The K1OM architecture is an extension of the x86 architecture.
+ # So, the $target_arch is x86_64.
+ k1om)
+ AC_MSG_RESULT([Intel(R) Xeon Phi(TM)])
+ CC_TARGET_ARCH=`$CC -v 2>&1 | grep Target: | sed -e 's/Target: //'`
+ if test $CC_TARGET_ARCH != x86_64-$target_vendor-linux ; then
+ AC_MSG_ERROR([Cross compiler not found in PATH.])
+ fi
+ CROSS_VARS="ARCH=$target_vendor CROSS_COMPILE=x86_64-$target_vendor-linux-"
+ CROSS_PATH=${CROSS_PATH:=/opt/intel/mic/lustre/device-k1om}
+ 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 = xyes ; then
+ AC_MSG_WARN([Disabling server (not supported for x86_64-$target_vendor-linux).])
+ enable_server='no'
+ fi
+ ;;
+ *)
+ AC_MSG_RESULT([no])
+ ;;
+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])],
+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" $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.])])