Add set_kernel_arch(), which maps the genkernel arch to the arch that the kernel...
[genkernel.git] / gen_arch.sh
1 #!/bin/bash
2
3 get_official_arch() {
4         if [ "${CMD_ARCHOVERRIDE}" != '' ]
5         then
6                 ARCH=${CMD_ARCHOVERRIDE}
7         else
8                 if [ "${ARCH_OVERRIDE}" != '' ]
9                 then
10                         ARCH=${ARCH_OVERRIDE}
11                 else
12                         ARCH=`uname -m`
13                         case "${ARCH}" in
14                                 i?86)
15                                         ARCH="x86"
16                                 ;;
17                                 mips|mips64)
18                                         ARCH="mips"
19                                 ;;
20                                 *)
21                                 ;;
22                         esac
23                 fi
24         fi
25
26         if [ "${CMD_UTILS_ARCH}" != '' ]
27         then
28                 UTILS_ARCH=${CMD_UTILS_ARCH}
29         else
30                 if [ "${UTILS_ARCH}" != '' ]
31                 then
32                         UTILS_ARCH=${UTILS_ARCH}
33                 fi
34         fi
35
36         # sparc64 klibc is b0rked, so we force to 32
37         if [ "${ARCH}" = 'sparc64' ]
38         then
39                 UTILS_ARCH='sparc'
40         fi
41         
42         ARCH_CONFIG="${GK_SHARE}/${ARCH}/config.sh"
43         [ -f "${ARCH_CONFIG}" ] || gen_die "${ARCH} not yet supported by genkernel. Please add the arch-specific config file, ${ARCH_CONFIG}"
44 }
45
46 set_kernel_arch() {
47         KERNEL_ARCH=${ARCH}
48         case ${ARCH} in
49 # XXX: This doesn't seem to actually be necessary, as it still works just fine without it
50 #               ppc|ppc64)
51 #                       if [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ]
52 #                       then
53 #                               if [ "${PAT}" -eq "6" -a "${SUB}" -ge "17" ] || [ "${PAT}" -gt "6" ]
54 #                               then
55 #                                       KERNEL_ARCH=powerpc
56 #                               fi
57 #                       fi
58 #                       ;;
59                 x86)
60                         if [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ]
61                         then
62                                 if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ]
63                                 then
64                                         KERNEL_ARCH=x86
65                                 else
66                                         KERNEL_ARCH=i386
67                                 fi
68                         fi
69                         ;;
70                 x86_64)
71                         if [ "${VER}" -eq "2" -a "${PAT}" -ge "6" ] || [ "${VER}" -gt "2" ]
72                         then
73                                 if [ "${PAT}" -eq "6" -a "${SUB}" -ge "24" ] || [ "${PAT}" -gt "6" ]
74                                 then
75                                         KERNEL_ARCH=x86
76                                 fi
77                         fi
78                         ;;
79         esac
80 }