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 # - check value correctness, should allow only:
16 # y, m, n, -[0-9]+, 0x[0-9A-Fa-f]+, ".*"
17 # - smarter arch split, there could be strings with spaces
18 # ( kernel-config.py does not suppoty it either )
19 # - use as many warnings as possible, we want our configs to be clean
22 # CONFIG_SOMETHING=n -- should warn
23 # SOMETHING=n -- should warn
24 # CONFIG_SOMETHING all=n -- should warn
26 # # CONFIG_SOMETHING is not set -- special case
30 # SOMETHING=y -- should warn
31 # CONFIG_SOMETHING all=y -- should warn
35 # return actual file name (without path) and line number
38 gsub( /^.*\//, "", f ) # strip path
43 function warn( msg ) {
44 print fileLine() ": " msg > "/dev/stderr"
49 print "arch= must be specified" > "/dev/stderr"
54 # convert special case:
55 # # CONFIG_SOMETHING it not set
58 /^# CONFIG_[A-Za-z0-9_-]+ is not set$/ {
59 match( $0, /CONFIG_[A-Za-z0-9_-]+/ )
60 option = substr( $0, RSTART, RLENGTH)
64 # ignore all the comments
78 gsub( /=.*$/, "", option )
79 gsub( /^[^=]*=/, "", line )
82 gsub( "^" option IFS, "", line )
85 split( archs[i], opt, "=" );
86 if ( opt[1] == "all" )
89 if ( opt[1] == arch ) {
90 # found best match, don't look further
97 if ( option in outputArray ) {
98 warn( option " already defined in: " outputArray[ option ] )
102 if ( length( value ) ) {
104 out = "# " option " is not set"
106 out = option "=" value
109 outputArray[ option ] = fileLine()