1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
#!/bin/bash
#
# Generate a header that defines the kernel we care about.
#
# Version 1.0
#
# Adapted from Red Hat's initscripts package
# Licensed under the GNU GPL
kernel_version=`uname -r`
output_file="/boot/kernel.h"
target_arch=""
# Parse command line arguments
action_flag=""
while [ $# -gt 0 ]; do
case $1 in
--targetarch*|-a)
if echo $1 | grep '=' >/dev/null ; then
target_arch=`echo $1 | sed 's/^.*=//'`
else
target_arch="$2"
shift
fi
;;
--kernelver*|-k)
if echo $1 | grep '=' >/dev/null ; then
kernel_version=`echo $1 | sed 's/^.*=//'`
else
kernel_version="$2"
shift
fi
;;
--output*|-o)
if echo $1 | grep '=' >/dev/null ; then
output_file=`echo $1 | sed 's/^.*=//'`
else
output_file="$2"
shift
fi
;;
esac
shift
done
KERNEL_TYPE=`echo ${kernel_version} | sed 's_^.*\(BOOT\|smp\|enterprise\|bigmem\|hugemem\|debug\|vmnix\)$_-\1_;t;s_.*__;'`
KERNEL_RELEASE=`echo ${kernel_version} | sed 's|BOOT\|smp\|enterprise\|bigmem\|hugemem\|debug||g'`
if [ -n "${target_arch}" ]; then
KERNEL_ARCH="${target_arch}"
else
rpm -q kernel$KERNEL_TYPE-$KERNEL_RELEASE >/dev/null 2>&1 && KERNEL_ARCH=`rpm -q --qf '%{ARCH}' kernel$KERNEL_TYPE-$KERNEL_RELEASE 2>/dev/null` || KERNEL_ARCH=`uname -m`
fi
if [ -n "$KERNEL_ARCH" ]; then
ENTERPRISE='0'
SMP='0'
UP='0'
BIGMEM='0'
HUGEMEM='0'
BOOT='0'
DEBUG='0'
VMNIX='0'
case "$KERNEL_TYPE" in
-BOOT)
BOOT='1'
if [ "${KERNEL_ARCH}" = "i686" ] || [ "${KERNEL_ARCH}" = "i586" ] || [ "${KERNEL_ARCH}" = "athlon" ]; then
KERNEL_ARCH="i386"
fi
;;
-smp) SMP='1';;
-enterprise) ENTERPRISE='1';;
-bigmem) BIGMEM='1';;
-hugemem) HUGEMEM='1';;
-vmnix) VMNIX='1';;
*) UP='1';;
esac
cat > ${output_file} << EOF
/* This file is automatically generated at boot time. */
#ifndef __BOOT_KERNEL_H_
#define __BOOT_KERNEL_H_
/* Kernel type $KERNEL_ARCH$KERNEL_TYPE */
#ifndef __MODULE_KERNEL_$KERNEL_ARCH
#define __MODULE_KERNEL_$KERNEL_ARCH 1
#endif
#ifndef __BOOT_KERNEL_ENTERPRISE
#define __BOOT_KERNEL_ENTERPRISE $ENTERPRISE
#endif
#ifndef __BOOT_KERNEL_BIGMEM
#define __BOOT_KERNEL_BIGMEM $BIGMEM
#endif
#ifndef __BOOT_KERNEL_HUGEMEM
#define __BOOT_KERNEL_HUGEMEM $HUGEMEM
#endif
#ifndef __BOOT_KERNEL_SMP
#define __BOOT_KERNEL_SMP $SMP
#endif
#ifndef __BOOT_KERNEL_UP
#define __BOOT_KERNEL_UP $UP
#endif
#ifndef __BOOT_KERNEL_BOOT
#define __BOOT_KERNEL_BOOT $BOOT
#endif
#ifndef __BOOT_KERNEL_DEBUG
#define __BOOT_KERNEL_DEBUG $DEBUG
#endif
#ifndef __BOOT_KERNEL_VMNIX
#define __BOOT_KERNEL_VMNIX $VMNIX
#endif
#endif
EOF
fi
|