Update to EFL 1.0-beta release
[qi-bootmenu-system.git] / sources / scripts / miniconfig.sh
blob34ad7dc0cd35ba0ba3dc1bf754a8cf679068f41f
1 #!/bin/bash
3 # miniconfig.sh copyright 2005 by Rob Landley <rob@landley.net>
4 # Licensed under the GNU General Public License version 2.
6 # Run this in the linux kernel build directory with a starting file, and
7 # it creates a file called mini.config with all the redundant lines of that
8 # .config removed. The starting file must match what the kernel outputs.
9 # If it doesn't, then run "make oldconfig" on it to get one that does.
11 export KCONFIG_NOTIMESTAMP=1
13 if [ $# -ne 1 ]
14 then
15 echo "Usage: miniconfig.sh configfile"
16 exit 1
19 if [ ! -f "$1" ]
20 then
21 echo "Couldn't find "'"'"$1"'"'
22 exit 1
25 if [ "$1" == ".config" ]
26 then
27 echo "It overwrites .config, rename it and try again."
28 exit 1
31 make allnoconfig KCONFIG_ALLCONFIG="$1" > /dev/null
32 # Shouldn't need this, but kconfig goes "boing" at times...
33 yes "" | make oldconfig > /dev/null
34 if ! cmp .config "$1"
35 then
36 echo Sanity test failed, normalizing starting configuration...
37 diff -u "$1" .config
39 cp .config .big.config
41 # Speed heuristic: remove all blank/comment lines
42 grep -v '^[#$]' .config | grep -v '^$' > mini.config
43 # This should never fail, but kconfig is so broken it does sometimes.
44 make allnoconfig KCONFIG_ALLCONFIG=mini.config > /dev/null
45 if ! cmp .config "$1"
46 then
47 echo Insanity test failed: reversing blank line removal heuristic.
48 cp .big.config mini.config
50 #cp .config mini.config
52 echo "Calculating mini.config..."
54 LENGTH=`cat mini.config | wc -l`
55 OLDLENGTH=$LENGTH
57 # Loop through all lines in the file
58 I=1
59 while true
61 if [ $I -gt $LENGTH ]
62 then
63 break
65 sed -n "${I}!p" mini.config > .config.test
66 # Do a config with this file
67 rm .config
68 make allnoconfig KCONFIG_ALLCONFIG=.config.test | head -n 1000000 > /dev/null
69 # Compare. Because we normalized at the start, the files should be identical.
70 if cmp -s .config .big.config
71 then
72 mv .config.test mini.config
73 LENGTH=$[$LENGTH-1]
74 else
75 I=$[$I + 1]
77 echo -n -e "\r$[$I-1]/$LENGTH lines $(cat mini.config | wc -c) bytes $[100-((($LENGTH-$I)*100)/$OLDLENGTH)]% "
78 done
79 rm .big.config
80 echo