From e05b0b10b942ba3585f6d5d505a282c2de95c243 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Sat, 30 Dec 2017 12:12:59 -0500 Subject: [PATCH] autoconf: refactor ostype.m4 Further refactoring of the autoconf macros. Move more linux and solaris specific checks into their own files. This is a non-functional change. Care has been taken preserve the ordering of the autoconf tests. Except for whitespace, the generated configure file has not been changed by this refactoring. This has been verified with a 'diff -u -w -B' comparison of the generated configure file before and after applying this commit. Reviewed-on: https://gerrit.openafs.org/12843 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit 3c2e39bab7d927aa5f20d02a5e327927a4b2b553) Change-Id: I4d91753afd90e4735ab61413e757f6852750a3de Reviewed-on: https://gerrit.openafs.org/12877 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- src/cf/linux-guess-version.m4 | 14 ++++++ src/cf/linux-kernel-path.m4 | 70 ++++++++++++++++++++++++++ src/cf/ostype.m4 | 93 ++--------------------------------- src/cf/solaris-ostype.m4 | 9 ++++ 4 files changed, 97 insertions(+), 89 deletions(-) create mode 100644 src/cf/linux-guess-version.m4 create mode 100644 src/cf/linux-kernel-path.m4 create mode 100644 src/cf/solaris-ostype.m4 diff --git a/src/cf/linux-guess-version.m4 b/src/cf/linux-guess-version.m4 new file mode 100644 index 000000000..365051ad9 --- /dev/null +++ b/src/cf/linux-guess-version.m4 @@ -0,0 +1,14 @@ +AC_DEFUN([OPENAFS_LINUX_GUESS_VERSION],[ +GUESS_LINUX_VERSION= +if test "x$enable_kernel_module" = "xyes"; then + GUESS_LINUX_VERSION=${LINUX_VERSION} +else + GUESS_LINUX_VERSION=`uname -r` +fi +case "$GUESS_LINUX_VERSION" in + 2.2.*) AFS_SYSKVERS=22 ;; + 2.4.*) AFS_SYSKVERS=24 ;; + [2.6.* | [3-9]* | [1-2][0-9]*]) AFS_SYSKVERS=26 ;; + *) AC_MSG_ERROR(Couldn't guess your Linux version [2]) ;; +esac +]) diff --git a/src/cf/linux-kernel-path.m4 b/src/cf/linux-kernel-path.m4 new file mode 100644 index 000000000..ac43a859d --- /dev/null +++ b/src/cf/linux-kernel-path.m4 @@ -0,0 +1,70 @@ +AC_DEFUN([OPENAFS_LINUX_KERNEL_PATH],[ +if test "x$with_linux_kernel_headers" != "x"; then + LINUX_KERNEL_PATH="$with_linux_kernel_headers" +else + for utsdir in "/lib/modules/`uname -r`/build" \ + "/lib/modules/`uname -r`/source" \ + "/usr/src/linux-2.4" \ + "/usr/src/linux"; do + LINUX_KERNEL_PATH="$utsdir" + for utsfile in "include/generated/utsrelease.h" \ + "include/linux/utsrelease.h" \ + "include/linux/version.h" \ + "include/linux/version-up.h"; do + if grep "UTS_RELEASE" "$utsdir/$utsfile" >/dev/null 2>&1; then + break 2 + fi + done + done +fi +if test "x$with_linux_kernel_build" != "x"; then + LINUX_KERNEL_BUILD="$with_linux_kernel_build" +else + LINUX_KERNEL_BUILD=$LINUX_KERNEL_PATH +fi +if test -f "$LINUX_KERNEL_BUILD/include/generated/utsrelease.h"; then + linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/generated/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1` + LINUX_VERSION="$linux_kvers" +else + if test -f "$LINUX_KERNEL_BUILD/include/linux/utsrelease.h"; then + linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1` + LINUX_VERSION="$linux_kvers" + else + if test -f "$LINUX_KERNEL_BUILD/include/linux/version.h"; then + linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1` + if test "x$linux_kvers" = "x"; then + if test -f "$LINUX_KERNEL_BUILD/include/linux/version-up.h"; then + linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1` + if test "x$linux_kvers" = "x"; then + AC_MSG_ERROR(Linux headers lack version definition [2]) + exit 1 + else + LINUX_VERSION="$linux_kvers" + fi + else + AC_MSG_ERROR(Linux headers lack version definition) + exit 1 + fi + else + LINUX_VERSION="$linux_kvers" + fi + else + enable_kernel_module="no" + fi + fi +fi +if test ! -f "$LINUX_KERNEL_BUILD/include/generated/autoconf.h" && + test ! -f "$LINUX_KERNEL_BUILD/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 usable linux headers found at $LINUX_KERNEL_PATH) + exit 1 + else + AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module) + fi +fi +dnl do we need to determine SUBARCH from autoconf.h +SUBARCH=default +]) diff --git a/src/cf/ostype.m4 b/src/cf/ostype.m4 index f65d26d4c..ae4da4633 100644 --- a/src/cf/ostype.m4 +++ b/src/cf/ostype.m4 @@ -3,105 +3,20 @@ AC_MSG_CHECKING(your OS) system=$host case $system in *-linux*) - MKAFS_OSTYPE=LINUX if test "x$enable_redhat_buildsys" = "xyes"; then - AC_DEFINE(ENABLE_REDHAT_BUILDSYS, 1, [define if you have redhat buildsystem]) + AC_DEFINE(ENABLE_REDHAT_BUILDSYS, 1, [define if you have redhat buildsystem]) fi if test "x$enable_kernel_module" = "xyes"; then - if test "x$with_linux_kernel_headers" != "x"; then - LINUX_KERNEL_PATH="$with_linux_kernel_headers" - else - for utsdir in "/lib/modules/`uname -r`/build" \ - "/lib/modules/`uname -r`/source" \ - "/usr/src/linux-2.4" \ - "/usr/src/linux"; do - LINUX_KERNEL_PATH="$utsdir" - for utsfile in "include/generated/utsrelease.h" \ - "include/linux/utsrelease.h" \ - "include/linux/version.h" \ - "include/linux/version-up.h"; do - if grep "UTS_RELEASE" "$utsdir/$utsfile" >/dev/null 2>&1; then - break 2 - fi - done - done - fi - if test "x$with_linux_kernel_build" != "x"; then - LINUX_KERNEL_BUILD="$with_linux_kernel_build" - else - LINUX_KERNEL_BUILD=$LINUX_KERNEL_PATH - fi - if test -f "$LINUX_KERNEL_BUILD/include/generated/utsrelease.h"; then - linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/generated/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1` - LINUX_VERSION="$linux_kvers" - else - if test -f "$LINUX_KERNEL_BUILD/include/linux/utsrelease.h"; then - linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/utsrelease.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1` - LINUX_VERSION="$linux_kvers" - else - if test -f "$LINUX_KERNEL_BUILD/include/linux/version.h"; then - linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1` - if test "x$linux_kvers" = "x"; then - if test -f "$LINUX_KERNEL_BUILD/include/linux/version-up.h"; then - linux_kvers=`fgrep UTS_RELEASE $LINUX_KERNEL_BUILD/include/linux/version-up.h |awk 'BEGIN { FS="\"" } { print $[]2 }'|tail -n 1` - if test "x$linux_kvers" = "x"; then - AC_MSG_ERROR(Linux headers lack version definition [2]) - exit 1 - else - LINUX_VERSION="$linux_kvers" - fi - else - AC_MSG_ERROR(Linux headers lack version definition) - exit 1 - fi - else - LINUX_VERSION="$linux_kvers" - fi - else - enable_kernel_module="no" - fi - fi - fi - if test ! -f "$LINUX_KERNEL_BUILD/include/generated/autoconf.h" && - test ! -f "$LINUX_KERNEL_BUILD/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 usable linux headers found at $LINUX_KERNEL_PATH) - exit 1 - else - AC_MSG_WARN(No usable linux headers found at $LINUX_KERNEL_PATH so disabling kernel module) - fi - fi - dnl do we need to determine SUBARCH from autoconf.h - SUBARCH=default + OPENAFS_LINUX_KERNEL_PATH fi AC_MSG_RESULT(linux) - GUESS_LINUX_VERSION= - if test "x$enable_kernel_module" = "xyes"; then - GUESS_LINUX_VERSION=${LINUX_VERSION} - else - GUESS_LINUX_VERSION=`uname -r` - fi - case "$GUESS_LINUX_VERSION" in - 2.2.*) AFS_SYSKVERS=22 ;; - 2.4.*) AFS_SYSKVERS=24 ;; - [2.6.* | [3-9]* | [1-2][0-9]*]) AFS_SYSKVERS=26 ;; - *) AC_MSG_ERROR(Couldn't guess your Linux version [2]) ;; - esac + OPENAFS_LINUX_GUESS_VERSION ;; *-solaris*) MKAFS_OSTYPE=SOLARIS AC_MSG_RESULT(sun4) - SOLARIS_PATH_CC - SOLARIS_CC_TAKES_XVECTOR_NONE - AC_SUBST(SOLARIS_CC_KOPTS) - SOLARIS_UFSVFS_HAS_DQRWLOCK - SOLARIS_FS_HAS_FS_ROLLED - SOLARIS_SOLOOKUP_TAKES_SOCKPARAMS - SOLARIS_HAVE_VN_RENAMEPATH + OPENAFS_SOLARIS_OSTYPE ;; *-sunos*) MKAFS_OSTYPE=SUNOS diff --git a/src/cf/solaris-ostype.m4 b/src/cf/solaris-ostype.m4 new file mode 100644 index 000000000..2fdfc6b6d --- /dev/null +++ b/src/cf/solaris-ostype.m4 @@ -0,0 +1,9 @@ +AC_DEFUN([OPENAFS_SOLARIS_OSTYPE],[ +SOLARIS_PATH_CC +SOLARIS_CC_TAKES_XVECTOR_NONE +AC_SUBST(SOLARIS_CC_KOPTS) +SOLARIS_UFSVFS_HAS_DQRWLOCK +SOLARIS_FS_HAS_FS_ROLLED +SOLARIS_SOLOOKUP_TAKES_SOCKPARAMS +SOLARIS_HAVE_VN_RENAMEPATH +]) -- 2.39.5