Whamcloud - gitweb
b=20383 fix errant m4 "dnl" usage
[fs/lustre-release.git] / build / autoconf / lustre-build-linux.m4
index 30d4076..840dc22 100644 (file)
@@ -104,29 +104,18 @@ AC_MSG_CHECKING([that RedHat kernel])
 LB_LINUX_TRY_COMPILE([
                #include <linux/version.h>
        ],[
-               #ifndef RHEL_MAJOR
+               #ifndef RHEL_RELEASE_CODE
                #error "not redhat kernel"
                #endif
        ],[
                RHEL_KENEL="yes"
+               RHEL_KERNEL="yes"
                AC_MSG_RESULT([yes])
        ],[
                AC_MSG_RESULT([no])
 ])
 
-AC_MSG_CHECKING([that SuSe kernel])
-LB_LINUX_TRY_COMPILE([
-               #include <linux/version.h>
-       ],[
-               #ifndef SLE_VERSION_CODE
-               #error "not sles kernel"
-               #endif
-       ],[
-               SUSE_KERNEL="yes"
-               AC_MSG_RESULT([yes])
-       ],[
-               AC_MSG_RESULT([no])
-])
+LB_LINUX_CONFIG([SUSE_KERNEL],[SUSE_KERNEL="yes"],[])
 
 ])
 
@@ -192,9 +181,9 @@ LB_CHECK_FILE([$LINUX_CONFIG],[],
 # at 2.6.19 # $LINUX/include/linux/config.h is removed
 # and at more old has only one line
 # include <autoconf.h>
-LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
-               $LINUX_OBJ/include/linux/version.h
-               ],[],
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/autoconf.h],[],
+       [AC_MSG_ERROR([Run make config in $LINUX.])])
+LB_CHECK_FILE([$LINUX_OBJ/include/linux/version.h],[],
        [AC_MSG_ERROR([Run make config in $LINUX.])])
 
 # ------------ rhconfig.h includes runtime-generated bits --
@@ -351,10 +340,10 @@ $2
 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
 [m4_ifvaln([$1], [LB_LINUX_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/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $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/`uname -m|sed -e 's/ppc.*/powerpc/' -e 's/x86_64/x86/' -e 's/i.86/x86/'`/include -I$LINUX/include -I$LINUX_OBJ/include -I$LINUX_OBJ/include2 -include include/linux/autoconf.h" -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
        [$4],
        [_AC_MSG_LOG_CONFTEST
-m4_ifvaln([$5],[$5])dnl])dnl
+m4_ifvaln([$5],[$5])dnl])
 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko m4_ifval([$1], [build/conftest.c conftest.c])[]dnl
 ])
 
@@ -367,7 +356,7 @@ AC_DEFUN([LB_LINUX_ARCH],
          [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_OBJ $ARCH_UM \
+                     LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $ARCH_UM \
                      ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`],
                 [AC_MSG_RESULT([$LINUX_ARCH])],
                 [AC_MSG_ERROR([Could not determine the kernel architecture.])])
@@ -523,6 +512,57 @@ else
 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
+AC_DEFUN([LC_MODULE_LOADING],
+[AC_MSG_CHECKING([if kernel module loading is possible])
+LB_LINUX_TRY_MAKE([
+        #include <linux/kmod.h>
+],[
+        int myretval=ENOSYS ;
+        return myretval;
+],[
+        $makerule LUSTRE_KERNEL_TEST=conftest.i
+],[
+        grep request_module build/conftest.i | grep -v `grep "int myretval=" build/conftest.i | cut -d= -f2 | cut -d" "  -f1` >/dev/null
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_MODULE_LOADING_SUPPORT, 1,
+                [kernel module loading is possible])
+],[
+        AC_MSG_RESULT(no)
+        AC_MSG_WARN([])
+        AC_MSG_WARN([Kernel module loading support is highly recommended.])
+        AC_MSG_WARN([])
+])
+])
+
+# 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
+AC_DEFUN([LC_MODULE_LOADING],
+[AC_MSG_CHECKING([if kernel module loading is possible])
+LB_LINUX_TRY_MAKE([
+        #include <linux/kmod.h>
+],[
+        int myretval=ENOSYS ;
+        return myretval;
+],[
+        $makerule LUSTRE_KERNEL_TEST=conftest.i
+],[
+        grep request_module build/conftest.i | grep -v `grep "int myretval=" build/conftest.i | cut -d= -f2 | cut -d" "  -f1` >/dev/null
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_MODULE_LOADING_SUPPORT, 1,
+                [kernel module loading is possible])
+],[
+        AC_MSG_RESULT(no)
+        AC_MSG_WARN([])
+        AC_MSG_WARN([Kernel module loading support is highly recommended.])
+        AC_MSG_WARN([])
+])
+])
 
 #
 # LB_PROG_LINUX
@@ -547,11 +587,8 @@ if test "x$ARCH_UM" = "x" ; then
 fi
 ])
 
-LB_LINUX_CONFIG([KMOD],[],[
-       AC_MSG_WARN([])
-       AC_MSG_WARN([Kernel module loading support is highly recommended.])
-       AC_MSG_WARN([])
-])
+# 2.6.28
+LC_MODULE_LOADING
 
 #LB_LINUX_CONFIG_BIG_STACK
 
@@ -622,16 +659,3 @@ AC_CACHE_CHECK([for $1], ac_Header,
 AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
 AS_VAR_POPDEF([ac_Header])dnl
 ])
-
-#
-# Like AC_CHECK_HEADERS but for kernel space headers
-#
-AC_DEFUN([LB_CHECK_LINUX_HEADERS],
-[AH_CHECK_HEADERS([$1])dnl
-for ac_header in $1
-do
-LB_CHECK_LINUX_HEADER($ac_header,
-               [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_header)) $2],
-               [$3])dnl
-done
-])