Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / config / linux-version
1 #!/bin/sh
2 #
3 # linux-version
4 #
5 # Verify that this build machine has the required header files for the
6 # kernel versions specified in LINUX_VERS.
7 #
8 # The following critical variables are passed in from ./Makefile:
9 #
10 #   LINUX_SRCDIR="/usr/src/linux-"
11 #   LINUX_VERS="2.2.5-15 2.2.10 2.2.12 2.2.12-20 2.2.13 2.2.14"
12 #
13 # To add support for a new Linux kernel rev, msut therefore add it to 
14 # $LINUX_VERS in ./Makefile and create $LINUX_SRCDIR$VERS, populating
15 # the latter with header files including a version of the include file
16 # $LINUX_SRCDIR$VERS/include/linux/version.h  containing the appropriate
17 # UTS_RELEASE definition.
18 #
19
20 # The following two tests are done so that "make install" can be executed
21 # directly from the config directory.
22 if [ -z "$LINUX_VERS" ]; then
23         echo LINUX_VERS is not set. Not testing header links for kernel build.
24         exit 0
25 fi
26
27 if [ -z "$LINUX_SRCDIR" ]; then
28         echo "LINUX_SRCDIR is not set. Not testing header links for kernel build."
29         exit 0
30 fi
31
32 errors="false"
33 found_one="false"
34 CAN_BUILD=""
35
36 for VERS in $LINUX_VERS ; do
37         dir=$LINUX_SRCDIR$VERS
38         if [ ! -d $dir ] ; then
39                 echo "ERROR: Cannot build for Linux kernel $VERS: $dir does not exist."
40                 errors=true
41                 continue
42         fi
43         header=$LINUX_SRCDIR$VERS/include/linux/version.h
44         if [ ! -f $header ] ; then
45             echo "ERROR: Cannot build for Linux kernel $VERS: $header does not exist."
46             errors=true
47             continue
48         fi
49
50         vers=`fgrep UTS_RELEASE $LINUX_SRCDIR$VERS/include/linux/version.h |
51                 awk 'BEGIN { FS="\"" } { print $2 }'`
52         if [ "x$vers" = "x" ] ; then
53             echo "ERROR: Cannot build for Linux kernel $VERS:"
54             echo "       No UTS_RELEASE string found in $header."
55             continue
56         elif [ "$VERS" != "$vers" ] ; then
57             echo "ERROR: Cannot build $VERS. Wrong version '('$vers')' in $header."
58             errors=true
59             continue
60         fi
61         CAN_BUILD="$CAN_BUILD $VERS"
62         found_one="true"
63 done
64
65 if [ "x$errors" = "xtrue" ] ; then
66     echo "ERROR: Should be able to build at least one of $LINUX_VERS."
67     if [ "x$found_one" = "xtrue" ] ; then
68         echo "       Cannot build all kernels. Only set up for $CAN_BUILD."
69     else
70         echo "       Valid headers not present for any Linux kernel."
71         exit -1
72     fi
73 fi
74
75 exit 0