summaryrefslogtreecommitdiff
path: root/chromeos/scripts/kernelconfig
blob: c4415359c38a169fbd3448404256c2585714511f (plain)
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
#!/bin/bash

# Script to merge all configs and run 'make silentoldconfig' on it to wade out bad juju.
# Then split the configs into distro-commmon and flavour-specific parts

# We have to be in the top level kernel source directory
if [ ! -f MAINTAINERS ] || [ ! -f Makefile ]; then
	echo "This does not appear to be the kernel source directory." 1>&2
	exit 1
fi

mode=${1:?"Usage: $0 [oldconfig|editconfig]"}
case "$mode" in
    oldconfig)  ;; # All is good
    editconfig) ;; # All is good
    genconfig)  ;; # All is good
    *) echo "$0 called with invalid mode" 1>&2
       exit 1 ;;
esac
kerneldir="`pwd`"
confdir="$kerneldir/chromeos/config"
archs="x86_64 i386 armel"
bindir="`pwd`/chromeos/scripts"
base_conf="$confdir/base.config"
tmpdir=`mktemp -d`

if [ "$mode" = "genconfig" ]; then
	keep=1
	mode="oldconfig"
	test -d CONFIGS || mkdir CONFIGS
fi

test -d build || mkdir build

for arch in $archs; do
	# Map debian archs to kernel archs
	case "$arch" in
		amd64)	kernarch="x86_64"	;;
		lpia)   kernarch="x86" ;;
		sparc)	kernarch="sparc64"	;;
		armel)  kernarch="arm" ;;
		*)	kernarch="$arch"	;;
	esac

	echo ""
	echo "***************************************"
	echo "* Processing $arch ($kernarch) ... "
	archconfdir=$confdir/$arch
	flavourconfigs=$(cd $archconfdir && ls *.flavour.config)

	# Merge configs
	# We merge base.config + common.config + <flavour>.flavour.config

	for config in $flavourconfigs; do
		fullconf="$tmpdir/$arch-$config-full"
		cp $base_conf "$fullconf"
		cat $archconfdir/common.config >> "$fullconf"
		cat $archconfdir/$config >> "$fullconf"
	done

	for config in $flavourconfigs; do
		fullconf="$tmpdir/$arch-$config-full"
		mv "$fullconf" build/.config
		# Call oldconfig or menuconfig
		case "$mode" in
		    oldconfig)
			# Weed out incorrect config parameters
			echo "* Run silentoldconfig on $arch/$config ..."
			make O=`pwd`/build ARCH=$kernarch silentoldconfig ;;
		    editconfig)
			# Interactively edit config parameters
			echo "* $arch/$config: press <Enter> to edit, S to skip"
			read -s -n 1
			if [ $REPLY = 's' -o $REPLY = 'S' ]; then
			    echo "* Skip: running silentoldconfig"
			    make O=`pwd`/build ARCH=$kernarch silentoldconfig
			else
			    echo "* Running menuconfig"
			    make O=`pwd`/build ARCH=$kernarch menuconfig
			fi ;;
		    *)  # Bad!
			exit 1 ;;
		esac
		cat build/.config > $archconfdir/$config
		if [ "$keep" = "1" ]; then
			mv build/.config CONFIGS/$arch-$config
		fi
	done

	echo "Running splitconfig for $arch"
	echo

	# Can we make this more robust by avoiding $tmpdir completely?
	# This approach was used for now because I didn't want to change
	# splitconfig
	(cd $archconfdir; rm common.config; $bindir/splitconfig; \
	    mv common.config $tmpdir/$arch.config)
done

# Now run splitconfig on all the <arch>.common.config copied to
# $tmpdir
(cd $tmpdir; $bindir/splitconfig)
mv $tmpdir/common.config $base_conf
for arch in $archs; do
	mv $tmpdir/$arch.config $confdir/$arch/common.config
done

rm -rf $tmpdir