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>
15 # - smarter arch split, there could be strings with spaces
16 # ( kernel-config.py does not suppoty it either )
17 # - use as many warnings as possible, we want our configs to be clean
20 # CONFIG_SOMETHING=n -- should warn
21 # SOMETHING=n -- should warn
22 # CONFIG_SOMETHING all=n -- should warn
24 # # CONFIG_SOMETHING is not set -- special case
28 # SOMETHING=y -- should warn
29 # CONFIG_SOMETHING all=y -- should warn
33 # return actual file name (without path) and line number
36 gsub( /^.*\//, "", f ) # strip path
41 function warn( msg ) {
42 print fileLine() ": " msg > "/dev/stderr"
47 print "arch= must be specified" > "/dev/stderr"
53 function dieLater( code ) {
54 if ( shouldDie < code )
58 # convert special case:
59 # # CONFIG_SOMETHING it not set
62 /^# CONFIG_[A-Za-z0-9_-]+ is not set$/ {
63 match( $0, /CONFIG_[A-Za-z0-9_-]+/ )
64 option = substr( $0, RSTART, RLENGTH)
68 # ignore all the comments
82 gsub( /=.*$/, "", option )
83 gsub( /^[^=]*=/, "", line )
86 gsub( "^" option IFS, "", line )
89 split( archs[i], opt, "=" );
90 if ( opt[1] == "all" )
93 if ( opt[1] == arch ) {
94 # found best match, don't look further
101 if ( option in outputArray ) {
102 warn( option " already defined in: " outputArray[ option ] )
106 if ( length( value ) ) {
108 out = "# " option " is not set"
110 out = option "=" value
112 if ( value == "y" || value == "m" )
114 else if ( value ~ /^"[^"]*"$/ )
116 else if ( value ~ /^-?[0-9]+$/ || value ~ /^0x[0-9A-Fa-f]+$/ )
119 warn( "ERROR: Incorrect value: " $0 )
125 outputArray[ option ] = fileLine()