Moved architecture folders under the arch subfolder.
[genkernel.git] / gen_configkernel.sh
1 #!/bin/bash
2
3 determine_config_file() {
4         if [ "${CMD_KERNEL_CONFIG}" != "" ]
5         then
6                 KERNEL_CONFIG="${CMD_KERNEL_CONFIG}"
7         elif [ -f "/etc/kernels/kernel-config-${ARCH}-${KV}" ]
8         then
9                 KERNEL_CONFIG="/etc/kernels/kernel-config-${ARCH}-${KV}"
10         elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}" ]
11         then
12                 KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${KV}"
13         elif [ "${DEFAULT_KERNEL_CONFIG}" != "" -a -f "${DEFAULT_KERNEL_CONFIG}" ]
14         then
15                 KERNEL_CONFIG="${DEFAULT_KERNEL_CONFIG}"
16         elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}" ]
17         then
18                 KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config-${VER}.${PAT}"
19         elif [ -f "${GK_SHARE}/arch/${ARCH}/kernel-config" ]
20         then
21                 KERNEL_CONFIG="${GK_SHARE}/arch/${ARCH}/kernel-config"
22         else
23                 gen_die 'Error: No kernel .config specified, or file not found!'
24         fi
25 }
26
27 config_kernel() {
28         determine_config_file
29         cd "${KERNEL_DIR}" || gen_die 'Could not switch to the kernel directory!'
30
31         isTrue "${CLEAN}" && cp "${KERNEL_DIR}/.config" "${KERNEL_DIR}/.config.bak" > /dev/null 2>&1
32         if isTrue ${MRPROPER}
33         then
34                 print_info 1 'kernel: >> Running mrproper...'
35                 compile_generic mrproper kernel
36         fi
37
38         # If we're not cleaning, then we don't want to try to overwrite the configs
39         # or we might remove configurations someone is trying to test.
40
41         if isTrue "${CLEAN}"
42         then
43                 print_info 1 "config: Using config from ${KERNEL_CONFIG}"
44                 print_info 1 '        Previous config backed up to .config.bak'
45                 cp "${KERNEL_CONFIG}" "${KERNEL_DIR}/.config" || gen_die 'Could not copy configuration file!'
46         fi
47         if isTrue "${OLDCONFIG}"
48         then
49                 print_info 1 '        >> Running oldconfig...'
50                 yes '' 2>/dev/null | compile_generic oldconfig kernel 2>/dev/null
51         fi
52         if isTrue "${CLEAN}"
53         then
54                 print_info 1 'kernel: >> Cleaning...'
55                 compile_generic clean kernel
56         else
57                 print_info 1 "config: --no-clean is enabled; leaving the .config alone."
58         fi
59         
60         if isTrue ${MENUCONFIG}
61         then
62                 print_info 1 'config: >> Invoking menuconfig...'
63                 compile_generic menuconfig runtask
64                 [ "$?" ] || gen_die 'Error: menuconfig failed!'
65         elif isTrue ${CMD_GCONFIG}
66         then
67                 if [ "${VER}" == '2' ] && [ "${PAT}" -lt '6' ]
68                 then
69                         print_warning 1 'config: gconfig is not available in 2.4 series kernels. Running xconfig'
70                         print_warning 1 '        instead...'
71
72                         CMD_GCONFIG=0
73                         CMD_XCONFIG=1
74                 else
75                         print_info 1 'config: >> Invoking gconfig...'
76                         compile_generic gconfig kernel
77                         [ "$?" ] || gen_die 'Error: gconfig failed!'
78
79                         CMD_XCONFIG=0
80                 fi
81         fi
82
83         if isTrue ${CMD_XCONFIG}
84         then
85                 print_info 1 'config: >> Invoking xconfig...'
86                 compile_generic xconfig kernel
87                 [ "$?" ] || gen_die 'Error: xconfig failed!'
88         fi
89
90         # Force this on if we are a 2.4 kernel or less
91         # This is required for initrd support
92         # Initramfs doesn't require this
93         # TODO: force on with --genzimage
94         if [ "${KERN_24}" -eq '1' ]
95         then
96                 # Make sure Ext2 support is on...
97                 sed -e 's/#\? \?CONFIG_EXT2_FS[ =].*/CONFIG_EXT2_FS=y/g' \
98                         -i ${KERNEL_DIR}/.config 
99         fi
100
101         # Make sure lvm modules are on if --lvm/--lvm
102         if isTrue ${CMD_LVM}
103         then
104                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
105                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_SNAPSHOT is.*/CONFIG_DM_SNAPSHOT=m/g'
106                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MIRROR is.*/CONFIG_DM_MIRROR=m/g'
107         fi
108
109         # Make sure dmraid modules are on if --dmraid
110         if isTrue ${CMD_DMRAID}
111         then
112                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
113         fi
114
115         if isTrue ${SPLASH}
116         then
117                 sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g'
118         fi
119 }