configure-linux-redhat-support-on-redhat-only-20010706
authorChaskiel M Grundman <cg2v@andrew.cmu.edu>
Fri, 6 Jul 2001 23:44:05 +0000 (23:44 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 6 Jul 2001 23:44:05 +0000 (23:44 +0000)
a) if the kernel headers use redhat's header-file selection thing, and
   doesn't define their __BOOT_KERNEL* symbols if not.
b) which AFS kernel modules (single-processor, multi-processor, or both)
   it makes sense to compile against these kernel headers. e.g. in a
   CONFIG_MODVERSIONS environment, it only makes sense to compile for the
   same SMP-ness as the headers.

configure.in
src/cf/linux-test3.m4 [new file with mode: 0644]
src/libafs/MakefileProto.LINUX.in

index 95e2448..d5e9863 100644 (file)
@@ -71,12 +71,17 @@ case $system in
                    LINUX_VERSION="$linux_kvers"
                  fi
                 else
+                    enable_kernel_module="no"
+                 fi
+                if test ! -f "$LINUX_KERNEL_PATH/include/linux/autoconf.h"; then
+                    enable_kernel_module="no"
+                fi
+                if test "x$enable_kernel_module" = "xno"; then
                  if test "x$with_linux_kernel_headers" != "x"; then
-                  AC_MSG_ERROR(No linux headers found at $LINUX_KERNEL_PATH)
+                  AC_MSG_ERROR(No usable linux headers found at $LINUX_KERNEL_PATH)
                   exit 1
                  else
-                  AC_MSG_WARN(No linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
-                  enable_kernel_module="no"
+                  AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module)
                  fi
                 fi
                fi
@@ -84,6 +89,9 @@ case $system in
                if test "x$enable_kernel_module" = "xyes"; then
                 LINUX_FS_STRUCT_INODE_HAS_I_BYTES
                 LINUX_INODE_SETATTR_RETURN_TYPE
+                LINUX_NEED_RHCONFIG
+                LINUX_WHICH_MODULES
+                :
                fi
                 ;;
         *-solaris*)
diff --git a/src/cf/linux-test3.m4 b/src/cf/linux-test3.m4
new file mode 100644 (file)
index 0000000..fe3ce59
--- /dev/null
@@ -0,0 +1,60 @@
+AC_DEFUN(LINUX_NEED_RHCONFIG,[
+AC_MSG_CHECKING(for redhat kernel configuration)
+if test -f "${LINUX_KERNEL_PATH}/include/linux/rhconfig.h"; then
+    ac_linux_rhconfig=yes
+    RHCONFIG_SP="-D__BOOT_KERNEL_UP=1 -D__BOOT_KERNEL_SMP=0"
+    RHCONFIG_MP="-D__BOOT_KERNEL_UP=0 -D__BOOT_KERNEL_SMP=1"
+    AC_MSG_RESULT($ac_linux_rhconfig)
+    if test ! -f "/boot/kernel.h"; then
+        AC_MSG_WARN([/boot/kernel.h does not exist. build may fail])
+    fi
+else
+    ac_linux_rhconfig=no
+    RHCONFIG_SP=""
+    RHCONFIG_MP=""
+    AC_MSG_RESULT($ac_linux_rhconfig)
+fi
+AC_SUBST(RHCONFIG_SP)
+AC_SUBST(RHCONFIG_MP)
+])
+
+AC_DEFUN(LINUX_WHICH_MODULES,[
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $RHCONFIG_SP $CPPFLAGS"
+AC_MSG_CHECKING(if kernel uses MODVERSIONS)
+AC_CACHE_VAL(ac_cv_linux_config_modversions,[
+AC_TRY_COMPILE(
+[#include <linux/config.h>
+],
+[#ifndef CONFIG_MODVERSIONS
+lose;
+#endif
+],
+ac_cv_linux_config_modversions=yes,
+ac_cv_linux_config_modversions=no)])
+AC_MSG_RESULT($ac_cv_linux_config_modversions)
+AC_MSG_CHECKING(which kernel modules to build)
+if test "x$ac_linux_rhconfig" = "xyes" -o "x$ac_cv_linux_config_modversions" = "xno"; then
+    MPS="MP SP"
+else
+AC_CACHE_VAL(ac_cv_linux_config_smp, [
+AC_TRY_COMPILE(
+[#include <linux/config.h>
+],
+[#ifndef CONFIG_SMP
+lose;
+#endif
+],
+ac_cv_linux_config_smp=yes,
+ac_cv_linux_config_smp=no)])
+dnl AC_MSG_RESULT($ac_cv_linux_config_smp)
+    if test "x$ac_cv_linux_config_smp" = "xyes"; then
+        MPS=MP
+    else
+        MPS=SP
+    fi
+fi
+AC_MSG_RESULT($MPS)
+AC_SUBST(MPS)
+CPPFLAGS=$save_CPPFLAGS])
+
index 1955f5e..c7cf7e7 100644 (file)
@@ -71,7 +71,7 @@ CFLAGS = $(CCFLAGS) $(DEFINES) $(INCLUDES)
 
 # Name of directory to hold object files and libraries.
 KOBJ = MODLOAD
-MPS = MP SP
+MPS = @MPS@
 
 # COMPDIRS is called in Makefile.common to do the actual builds.
 COMPDIRS=linux_compdirs
@@ -124,10 +124,10 @@ ${COMPDIRS}:
                KDIR=${KOBJ}-${LINUX_VERS}-$$m ; \
                echo Building in directory: $${KDIR} ; \
                if [ "$$m" = "MP" ] ; then \
-                       SMP_DEF="-DAFS_SMP -D__BOOT_KERNEL_SMP=1 -D__BOOT_KERNEL_UP=0 -D__SMP__" ; \
+                       SMP_DEF="-DAFS_SMP @RHCONFIG_MP@ -D__SMP__" ; \
                        TARG="libafs.mp" ; \
                else  \
-                       SMP_DEF="-D__BOOT_KERNEL_SMP=0 -D__BOOT_KERNEL_UP=1 -U__SMP__" ; \
+                       SMP_DEF="@RHCONFIG_SP@ -U__SMP__" ; \
                        TARG=libafs ; \
                fi ; \
                cd $${KDIR} ; \