ntmakefile-20040602
[openafs.git] / src / config / linux-version
1 #!/bin/sh
2 # Copyright 2000, International Business Machines Corporation and others.
3 # All Rights Reserved.
4
5 # This software has been released under the terms of the IBM Public
6 # License.  For details, see the LICENSE file in the top-level source
7 # directory or online at http://www.openafs.org/dl/license10.html
8
9 # Verify that this build machine has the required header files for the
10 # kernel versions specified in LINUX_VERS.
11 #
12 # The following critical variables are passed in from ./Makefile:
13 #
14 #   LINUX_SRCDIR="/usr/src/linux-"
15 #   LINUX_VERS="2.2.5-15 2.2.10 2.2.12 2.2.12-20 2.2.13 2.2.14"
16 #
17 # To add support for a new Linux kernel rev, msut therefore add it to 
18 # $LINUX_VERS in ./Makefile and create $LINUX_SRCDIR$VERS, populating
19 # the latter with header files including a version of the include file
20 # $LINUX_SRCDIR$VERS/include/linux/version.h  containing the appropriate
21 # UTS_RELEASE definition.
22 #
23
24 # The following two tests are done so that "make install" can be executed
25 # directly from the config directory.
26 if [ -z "$LINUX_VERS" ]; then
27         echo LINUX_VERS is not set. Not testing header links for kernel build.
28         exit 0
29 fi
30
31 if [ -z "$LINUX_SRCDIR" ]; then
32         echo "LINUX_SRCDIR is not set. Not testing header links for kernel build."
33         exit 0
34 fi
35
36 errors="false"
37 found_one="false"
38 CAN_BUILD=""
39
40 for VERS in $LINUX_VERS ; do
41         dir=$LINUX_SRCDIR$VERS
42         if [ ! -d $dir ] ; then
43                 echo "ERROR: Cannot build for Linux kernel $VERS: $dir does not exist."
44                 errors=true
45                 continue
46         fi
47         header=$LINUX_SRCDIR$VERS/include/linux/version.h
48         if [ ! -f $header ] ; then
49             echo "ERROR: Cannot build for Linux kernel $VERS: $header does not exist."
50             errors=true
51             continue
52         fi
53
54         vers=`fgrep UTS_RELEASE $LINUX_SRCDIR$VERS/include/linux/version.h |
55                 awk 'BEGIN { FS="\"" } { print $2 }'`
56         if [ "x$vers" = "x" ] ; then
57             echo "ERROR: Cannot build for Linux kernel $VERS:"
58             echo "       No UTS_RELEASE string found in $header."
59             continue
60         elif [ "$VERS" != "$vers" ] ; then
61 # Redhat kernel source has the problem that they create one version.h for
62 # all their builds; So, we have to be creative here.
63 #           echo "ERROR: Cannot build $VERS. Wrong version '('$vers')' in $header."
64 #           errors=true
65 #           continue
66             errors=true
67             for subvers in $vers ; do
68                 if [ "x$subvers" = "x$VERS" ] ; then
69                     errors=false
70                     continue
71                 fi
72             done
73         fi
74         CAN_BUILD="$CAN_BUILD $VERS"
75         found_one="true"
76 done
77
78 if [ "x$errors" = "xtrue" ] ; then
79     echo "ERROR: Should be able to build at least one of $LINUX_VERS."
80     if [ "x$found_one" = "xtrue" ] ; then
81         echo "       Cannot build all kernels. Only set up for $CAN_BUILD."
82     else
83         echo "       Valid headers not present for any Linux kernel."
84         exit -1
85     fi
86 fi
87
88 exit 0