2 # A script for building kernel config from multiarch config file.
3 # It also has some file merging facilities.
6 # awk -v arch=%{_target_base_arch} -f path/to/kernel-config.awk \
7 # kernel-important.config kernel-multiarch.config \
8 # kernel-%{arch}.config kernel-%{some_feature}.config \
12 # - Przemysław Iskra <sparky@pld-linux.org>
13 # parts based on kernel-config.py, by:
14 # - arekm@pld-linux.org
15 # - glen@pld-linux.org
18 # - smarter arch split, there could be strings with spaces
19 # ( kernel-config.py does not suppoty it either )
20 # - use as many warnings as possible, we want our configs to be clean
25 # CONFIG_SOMETHING all=n
27 # # CONFIG_SOMETHING is not set -- special case
32 # CONFIG_SOMETHING all=y
36 # return actual file name (without path) and line number
39 sub( /^.*\//, "", f ) # strip path
44 function warn( msg ) {
45 print fileLine() ": " msg > "/dev/stderr"
50 print "arch= must be specified" > "/dev/stderr"
56 function dieLater( code ) {
57 if ( shouldDie < code )
61 # convert special case:
62 # # CONFIG_SOMETHING it not set
65 /^# CONFIG_[A-Za-z0-9_]+ is not set$/ {
66 match( $0, /CONFIG_[A-Za-z0-9_]+/ )
67 option = substr( $0, RSTART, RLENGTH)
71 # ignore all the comments and empty lines
85 sub( /=.*$/, "", option )
86 sub( /^[^=]*=/, "", line )
89 sub( "^" option, "", line )
90 sub( /^[ \t]*/, "", line )
93 # there can be white spaces
95 while ( match( line, /^[^=]+="[^"]*"/ ) ) {
96 archs[ (++i) ] = substr( line, RSTART, RLENGTH )
97 line = substr( line, RSTART + RLENGTH )
98 sub( /^[ \t]*/, "", line )
104 split( archs[i], opt, "=" );
105 if ( opt[1] == "all" )
108 if ( opt[1] == arch ) {
109 # found best match, don't look further
116 if ( option in outputArray ) {
117 warn( option " already defined in: " outputArray[ option ] )
121 if ( length( value ) ) {
123 out = "# " option " is not set"
125 out = option "=" value
127 if ( value == "y" || value == "m" )
129 else if ( value ~ /^"[^"]*"$/ )
131 else if ( value ~ /^-?[0-9]+$/ || value ~ /^0x[0-9A-Fa-f]+$/ )
134 warn( "ERROR: Incorrect value: " $0 )
140 outputArray[ option ] = fileLine()