CHROMIUM: dts: spring: Disable Exynos RTC.
[cascardo/linux.git] / chromeos / scripts / kernelconfig
1 #!/bin/bash
2
3 # Script to merge all configs and run 'make silentoldconfig' on it to wade out bad juju.
4 # Then split the configs into distro-commmon and flavour-specific parts
5
6 # We have to be in the top level kernel source directory
7 if [ ! -f MAINTAINERS ] || [ ! -f Makefile ]; then
8         echo "This does not appear to be the kernel source directory." 1>&2
9         exit 1
10 fi
11
12 mode=${1:?"Usage: $0 [oldconfig|editconfig]"}
13 case "$mode" in
14     oldconfig)  ;; # All is good
15     editconfig) ;; # All is good
16     genconfig)  ;; # All is good
17     *) echo "$0 called with invalid mode" 1>&2
18        exit 1 ;;
19 esac
20 kerneldir="`pwd`"
21 confdir="$kerneldir/chromeos/config"
22 archs="x86_64 i386 armel"
23 bindir="`pwd`/chromeos/scripts"
24 base_conf="$confdir/base.config"
25 tmpdir=`mktemp -d`
26
27 if [ "$mode" = "genconfig" ]; then
28         keep=1
29         mode="oldconfig"
30         test -d CONFIGS || mkdir CONFIGS
31 fi
32
33 test -d build || mkdir build
34
35 for arch in $archs; do
36         # Map debian archs to kernel archs
37         case "$arch" in
38                 amd64)  kernarch="x86_64"       ;;
39                 lpia)   kernarch="x86" ;;
40                 sparc)  kernarch="sparc64"      ;;
41                 armel)  kernarch="arm" ;;
42                 *)      kernarch="$arch"        ;;
43         esac
44
45         echo ""
46         echo "***************************************"
47         echo "* Processing $arch ($kernarch) ... "
48         archconfdir=$confdir/$arch
49         flavourconfigs=$(cd $archconfdir && ls *.flavour.config)
50
51         # Merge configs
52         # We merge base.config + common.config + <flavour>.flavour.config
53
54         for config in $flavourconfigs; do
55                 fullconf="$tmpdir/$arch-$config-full"
56                 cp $base_conf "$fullconf"
57                 cat $archconfdir/common.config >> "$fullconf"
58                 cat $archconfdir/$config >> "$fullconf"
59         done
60
61         for config in $flavourconfigs; do
62                 fullconf="$tmpdir/$arch-$config-full"
63                 mv "$fullconf" build/.config
64                 # Call oldconfig or menuconfig
65                 case "$mode" in
66                     oldconfig)
67                         # Weed out incorrect config parameters
68                         echo "* Run silentoldconfig on $arch/$config ..."
69                         make O=`pwd`/build ARCH=$kernarch silentoldconfig ;;
70                     editconfig)
71                         # Interactively edit config parameters
72                         echo "* $arch/$config: press <Enter> to edit, S to skip"
73                         read -s -n 1
74                         if [ $REPLY = 's' -o $REPLY = 'S' ]; then
75                             echo "* Skip: running silentoldconfig"
76                             make O=`pwd`/build ARCH=$kernarch silentoldconfig
77                         else
78                             echo "* Running menuconfig"
79                             make O=`pwd`/build ARCH=$kernarch menuconfig
80                         fi ;;
81                     *)  # Bad!
82                         exit 1 ;;
83                 esac
84                 cat build/.config > $archconfdir/$config
85                 if [ "$keep" = "1" ]; then
86                         make O=`pwd`/build ARCH=$kernarch oldconfig
87                         make O=`pwd`/build ARCH=$kernarch savedefconfig
88                         mv build/.config CONFIGS/$arch-$config
89                         mv build/defconfig CONFIGS/$arch-$config.def
90                 fi
91         done
92
93         echo "Running splitconfig for $arch"
94         echo
95
96         # Can we make this more robust by avoiding $tmpdir completely?
97         # This approach was used for now because I didn't want to change
98         # splitconfig
99         (cd $archconfdir; rm common.config; $bindir/splitconfig; \
100             mv common.config $tmpdir/$arch.config)
101 done
102
103 # Now run splitconfig on all the <arch>.common.config copied to
104 # $tmpdir
105 (cd $tmpdir; $bindir/splitconfig)
106 mv $tmpdir/common.config $base_conf
107 for arch in $archs; do
108         mv $tmpdir/$arch.config $confdir/$arch/common.config
109 done
110
111 rm -rf $tmpdir