1 |
1325 |
phoenix |
#!/bin/sh
|
2 |
|
|
# Copyright (C) 2003 Erik Andersen <andersen@uclibc.org>
|
3 |
|
|
#
|
4 |
|
|
# This program is free software; you can redistribute it and/or
|
5 |
|
|
# modify it under the terms of the GNU Library General Public
|
6 |
|
|
# License as published by the Free Software Foundation; either
|
7 |
|
|
# version 2 of the License, or (at your option) any later
|
8 |
|
|
# version.
|
9 |
|
|
#
|
10 |
|
|
# This program is distributed in the hope that it will be useful,
|
11 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
# GNU Library General Public License for more details.
|
14 |
|
|
#
|
15 |
|
|
# You should have received a copy of the GNU Library General
|
16 |
|
|
# Public License along with this program; if not, write to the
|
17 |
|
|
# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
18 |
|
|
# Boston, MA 02111-1307 USA
|
19 |
|
|
|
20 |
|
|
usage () {
|
21 |
|
|
echo ""
|
22 |
|
|
echo "usage: "`basename $0`" -k KERNEL_SOURCE_DIRECTORY -t TARGET_ARCH"
|
23 |
|
|
echo ""
|
24 |
|
|
echo "This utility scans the KERNEL_SOURCE_DIRECTORY directory and"
|
25 |
|
|
echo "checks that it contains well formed kernel headers suitable"
|
26 |
|
|
echo "for inclusion as the include/linux/ directory provided by"
|
27 |
|
|
echo "uClibc."
|
28 |
|
|
echo ""
|
29 |
|
|
echo "If the specified kernel headers are present and already"
|
30 |
|
|
echo "configured for the architecture specified by TARGET_ARCH,"
|
31 |
|
|
echo "they will be used as-is."
|
32 |
|
|
echo ""
|
33 |
|
|
echo "If the specified kernel headers are missing entirely, this"
|
34 |
|
|
echo "script will return an error."
|
35 |
|
|
echo ""
|
36 |
|
|
echo "If the specified kernel headers are present, but are either"
|
37 |
|
|
echo "not yet configured or are configured for an architecture"
|
38 |
|
|
echo "different than that specified by TARGET_ARCH, this script"
|
39 |
|
|
echo "will attempt to 'fix' the kernel headers and make them"
|
40 |
|
|
echo "suitable for use by uClibc. This fixing process may fail."
|
41 |
|
|
echo "It is therefore best to always provide kernel headers that"
|
42 |
|
|
echo "are already configured for the selected architecture."
|
43 |
|
|
echo ""
|
44 |
|
|
echo "Most Linux distributions provide 'kernel-headers' packages"
|
45 |
|
|
echo "that are suitable for use by uClibc."
|
46 |
|
|
echo ""
|
47 |
|
|
echo ""
|
48 |
|
|
exit 1;
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
HAS_MMU="y";
|
52 |
|
|
while [ -n "$1" ]; do
|
53 |
|
|
case $1 in
|
54 |
|
|
-k ) shift; if [ -n "$1" ]; then KERNEL_SOURCE=$1; shift; else usage; fi; ;;
|
55 |
|
|
-t ) shift; if [ -n "$1" ]; then TARGET_ARCH=$1; shift; else usage; fi; ;;
|
56 |
|
|
-n ) shift; HAS_MMU="n"; ;;
|
57 |
|
|
-* ) usage; ;;
|
58 |
|
|
* ) usage; ;;
|
59 |
|
|
esac;
|
60 |
|
|
done;
|
61 |
|
|
|
62 |
|
|
if [ ! -f "$KERNEL_SOURCE/Makefile" ]; then
|
63 |
|
|
echo "";
|
64 |
|
|
echo "";
|
65 |
|
|
echo "The file $KERNEL_SOURCE/Makefile is missing!";
|
66 |
|
|
echo "Perhaps your kernel source is broken?"
|
67 |
|
|
echo "";
|
68 |
|
|
echo "";
|
69 |
|
|
exit 1;
|
70 |
|
|
fi;
|
71 |
|
|
|
72 |
|
|
if [ ! -d "$KERNEL_SOURCE" ]; then
|
73 |
|
|
echo "";
|
74 |
|
|
echo "";
|
75 |
|
|
echo "$KERNEL_SOURCE is not a directory";
|
76 |
|
|
echo "";
|
77 |
|
|
echo "";
|
78 |
|
|
exit 1;
|
79 |
|
|
fi;
|
80 |
|
|
|
81 |
|
|
# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTERVERSION
|
82 |
|
|
eval `sed -n -e 's/^\([A-Z]*\) = \([0-9]*\)$/\1=\2/p' -e 's/^\([A-Z]*\) = \(-[-a-z0-9]*\)$/\1=\2/p' $KERNEL_SOURCE/Makefile`
|
83 |
|
|
if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
|
84 |
|
|
then
|
85 |
|
|
echo "Unable to determine version for kernel headers"
|
86 |
|
|
echo -e "\tprovided in directory $KERNEL_SOURCE"
|
87 |
|
|
exit 1
|
88 |
|
|
fi
|
89 |
|
|
|
90 |
|
|
echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION}"
|
91 |
|
|
|
92 |
|
|
|
93 |
|
|
echo -e "\n"
|
94 |
|
|
echo "Using kernel headers from $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} for architecture '$TARGET_ARCH'"
|
95 |
|
|
echo -e "\tprovided in directory $KERNEL_SOURCE"
|
96 |
|
|
echo -e "\n"
|
97 |
|
|
|
98 |
|
|
# Create a symlink to include/asm
|
99 |
|
|
|
100 |
|
|
rm -f include/asm*
|
101 |
|
|
if [ ! -d "$KERNEL_SOURCE/include/asm" ]; then
|
102 |
|
|
echo "";
|
103 |
|
|
echo "";
|
104 |
|
|
echo "The symlink $KERNEL_SOURCE/include/asm is missing\!";
|
105 |
|
|
echo "Perhaps you forgot to configure your kernel source?";
|
106 |
|
|
echo "You really should configure your kernel source tree so I";
|
107 |
|
|
echo "do not have to try and guess about this sort of thing.";
|
108 |
|
|
echo ""
|
109 |
|
|
echo "Attempting to guess a usable value....";
|
110 |
|
|
echo ""
|
111 |
|
|
echo "";
|
112 |
|
|
sleep 1;
|
113 |
|
|
|
114 |
|
|
if [ "$TARGET_ARCH" = "powerpc" ];then
|
115 |
|
|
set -x;
|
116 |
|
|
ln -fs $KERNEL_SOURCE/include/asm-ppc include/asm;
|
117 |
|
|
set +x;
|
118 |
|
|
elif [ "$TARGET_ARCH" = "mips" ];then
|
119 |
|
|
set -x;
|
120 |
|
|
ln -fs $KERNEL_SOURCE/include/asm-mips include/asm;
|
121 |
|
|
set +x;
|
122 |
|
|
elif [ "$TARGET_ARCH" = "arm" ];then
|
123 |
|
|
set -x;
|
124 |
|
|
ln -fs $KERNEL_SOURCE/include/asm-arm include/asm;
|
125 |
|
|
set +x;
|
126 |
|
|
if [ ! -L $KERNEL_SOURCE/include/asm-arm/proc ] ; then
|
127 |
|
|
if [ ! -L proc ] ; then
|
128 |
|
|
(cd include/asm;
|
129 |
|
|
ln -fs proc-armv proc;
|
130 |
|
|
ln -fs arch-ebsa285 arch);
|
131 |
|
|
fi
|
132 |
|
|
fi;
|
133 |
|
|
elif [ "$TARGET_ARCH" = "cris" ]; then
|
134 |
|
|
set -x;
|
135 |
|
|
ln -fs $KERNEL_SOURCE/include/asm-cris include/asm;
|
136 |
|
|
set +x;
|
137 |
|
|
elif [ "$HAS_MMU" != "y" ]; then
|
138 |
|
|
if [ -d $KERNEL_SOURCE/include/asm-${TARGET_ARCH}nommu ] ; then
|
139 |
|
|
set -x;
|
140 |
|
|
ln -fs $KERNEL_SOURCE/include/asm-${TARGET_ARCH}nommu include/asm;
|
141 |
|
|
set +x;
|
142 |
|
|
else
|
143 |
|
|
set -x;
|
144 |
|
|
ln -fs $KERNEL_SOURCE/include/asm-$TARGET_ARCH include/asm;
|
145 |
|
|
set +x;
|
146 |
|
|
fi;
|
147 |
|
|
else
|
148 |
|
|
set -x;
|
149 |
|
|
ln -fs $KERNEL_SOURCE/include/asm-$TARGET_ARCH include/asm;
|
150 |
|
|
set +x;
|
151 |
|
|
fi;
|
152 |
|
|
else
|
153 |
|
|
# No guessing required.....
|
154 |
|
|
ln -fs $KERNEL_SOURCE/include/asm include/asm
|
155 |
|
|
fi;
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
# Annoyingly, 2.6.x kernel headers also need an include/asm-generic/ directory
|
159 |
|
|
if [ $VERSION -eq 2 ] && [ $PATCHLEVEL -ge 6 ] ; then
|
160 |
|
|
ln -fs $KERNEL_SOURCE/include/asm-generic include/asm-generic
|
161 |
|
|
fi;
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
# Create the include/linux and include/scsi symlinks.
|
165 |
|
|
rm -f include/linux
|
166 |
|
|
ln -fs $KERNEL_SOURCE/include/linux include/linux
|
167 |
|
|
rm -f include/scsi
|
168 |
|
|
ln -fs $KERNEL_SOURCE/include/scsi include/scsi
|
169 |
|
|
|