-if test $host_cpu != "lib" ; then
- KINCFLAGS="-I\$(top_srcdir)/include -I\$(top_srcdir)/portals/include -I$LINUX/include"
-else
- KINCFLAGS='-I$(top_srcdir)/include -I$(top_srcdir)/portals/include'
-fi
-CPPFLAGS="$KINCFLAGS $ARCHCPPFLAGS"
-
-if test $host_cpu != "lib" ; then
-# ------------ autoconf.h ------------------
- AC_MSG_CHECKING(if autoconf.h is in kernel source)
- if test -f $LINUX/include/linux/autoconf.h ; then
- AC_MSG_RESULT(yes)
- else
- AC_MSG_ERROR(** cannot find $LINUX/include/linux/autoconf.h. Run make config in $LINUX.)
- fi
-
-# ------------ LINUXRELEASE and moduledir ------------------
- AC_MSG_CHECKING(for Linux release)
-
- dnl We need to rid ourselves of the nasty [ ] quotes.
- changequote(, )
- dnl Get release from version.h
- LINUXRELEASE="`sed -ne 's/.*UTS_RELEASE[ \"]*\([0-9.a-zA-Z_-]*\).*/\1/p' $LINUX/include/linux/version.h`"
- changequote([, ])
-
- moduledir='$(libdir)/modules/'$LINUXRELEASE/kernel
- AC_SUBST(moduledir)
-
- modulefsdir='$(moduledir)/fs/$(PACKAGE)'
- AC_SUBST(modulefsdir)
-
- AC_MSG_RESULT($LINUXRELEASE)
- AC_SUBST(LINUXRELEASE)
-
-# ------------ RELEASE --------------------------------
- AC_MSG_CHECKING(lustre release)
-
- dnl We need to rid ourselves of the nasty [ ] quotes.
- changequote(, )
- dnl Get release from version.h
- RELEASE="`sed -ne 's/-/_/g' -e 's/.*UTS_RELEASE[ \"]*\([0-9.a-zA-Z_]*\).*/\1/p' $LINUX/include/linux/version.h`_`date +%Y%m%d%H%M`"
- changequote([, ])
-
- AC_MSG_RESULT($RELEASE)
- AC_SUBST(RELEASE)
-
-# ---------- modversions? --------------------
- AC_MSG_CHECKING(for MODVERSIONS)
- if egrep -e 'MODVERSIONS.*1' $LINUX/include/linux/autoconf.h >/dev/null 2>&1;
- then
- MFLAGS="-DMODULE -DMODVERSIONS -include $LINUX/include/linux/modversions.h -DEXPORT_SYMTAB"
- AC_MSG_RESULT(yes)
- else
- MFLAGS=
- AC_MSG_RESULT(no)
- fi
+if test x$enable_modules != xno ; then
+ # ------------ .config exists ----------------
+ AC_CHECK_FILE([$LINUX_CONFIG],[],
+ [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])])
+
+ # ----------- make dep run? ------------------
+ AC_CHECK_FILES([$LINUX/include/linux/autoconf.h
+ $LINUX/include/linux/version.h
+ $LINUX/include/linux/config.h],[],
+ [AC_MSG_ERROR([Run make config in $LINUX.])])
+
+ # ------------ rhconfig.h includes runtime-generated bits --
+ # red hat kernel-source checks
+
+ # we know this exists after the check above. if the user
+ # 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/include/linux/version.h >/dev/null ; then
+ # This is a clean kernel-source tree, we need to
+ # enable extensive workarounds to get this to build
+ # modules
+ AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
+ [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
+ AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
+ AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
+ AC_MSG_WARN([Consult README.kernel-source for details.])
+ fi],
+ [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])])
+ EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
+ fi
+
+ # --- check that we can build modules at all
+ AC_MSG_CHECKING([that modules can be built])
+ LUSTRE_MODULE_TRY_COMPILE([],[],
+ [
+ AC_MSG_RESULT([yes])
+ ],[
+ AC_MSG_RESULT([no])
+ AC_MSG_WARN([Consult config.log for details.])
+ AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
+ AC_MSG_ERROR([Kernel modules could not be built.])
+ ])
+
+ # ------------ LINUXRELEASE and moduledir ------------------
+ AC_MSG_CHECKING([for Linux release])
+ rm -f kernel-tests/conftest.i
+ LINUXRELEASE=
+ if test $linux25 = 'yes' ; then
+ makerule="$PWD/kernel-tests"
+ else
+ makerule="_dir_$PWD/kernel-tests"
+ fi
+ LUSTRE_MODULE_TRY_MAKE(
+ [#include <linux/version.h>],
+ [LINUXRELEASE=UTS_RELEASE],
+ [$makerule LUSTRE_KERNEL_TEST=conftest.i],
+ [test -s kernel-tests/conftest.i],
+ [
+ # LINUXRELEASE="UTS_RELEASE"
+ eval $(grep LINUXRELEASE kernel-tests/conftest.i)
+ ],[
+ AC_MSG_RESULT([unknown])
+ AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
+ ])
+ rm -f kernel-tests/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='$(libdir)/modules/'$LINUXRELEASE/kernel
+ AC_SUBST(moduledir)
+
+ modulefsdir='$(moduledir)/fs/$(PACKAGE)'
+ AC_SUBST(modulefsdir)
+
+ # ------------ RELEASE --------------------------------
+ AC_MSG_CHECKING([for Lustre release])
+ RELEASE="${LINUXRELEASE}_`date +%Y%m%d%H%M`"
+ AC_MSG_RESULT($RELEASE)
+ AC_SUBST(RELEASE)