1 # A script for building kernel config from multiarch config file.
2 # It also has some file merging facilities.
5 # awk -v arch=%{_target_base_arch} -f path/to/kernel-config.awk \
6 # kernel-multiarch.config kernel-%{arch}.config kernel-%{some_feature}.config \
10 # - check value correctness, should allow only:
11 # y, m, n, -[0-9]+, 0x[0-9A-Fa-f]+, ".*"
12 # - smarter arch split, there could be strings with spaces
13 # ( kernel-config.py does not suppoty it either )
14 # - use as many warnings as possible, we want our configs to be clean
15 # - allow more multiarch configs
17 function warn( msg ) {
18 print FILENAME " (" FNR "): " msg > "/dev/stderr"
23 warn( "arch= must be specified" )
30 # remember first file name
34 else if ( file != FILENAME ) { # second and following files
35 if ( match( $0, /CONFIG_[A-Za-z0-9_-]+/ ) ) {
36 option = substr( $0, RSTART, RLENGTH )
37 if ( $0 ~ "^" option "=.+$" || $0 ~ "^# " option " is not set$" ) {
38 if ( option in outputArray )
39 warn( option " already defined in: " outputArray[ option ] )
42 outputArray[ option ] = FILENAME " (" FNR ")"
46 warn( "Incorrect line: " $0 )
48 } else if ( ! /^\s*$/ && ! /^#/ ) {
49 warn( "Incorrect line: " $0 )
55 # multiarch file proxessing
62 warn( "Options should not start with CONFIG_" )
63 gsub( /^CONFIG_/, "" )
70 warn( $0 " should have explicit ` all='" )
71 gsub( /=.*$/, "", option )
72 gsub( /^[^=]*=/, "", line )
75 gsub( "^" option, "", line )
80 for ( inx in archs ) {
81 split( archs[inx], opt, "=" );
82 if ( opt[1] == "all" )
85 if ( opt[1] == arch ) {
90 if ( length( dest ) ) {
91 option = "CONFIG_" option
94 out = "# " option " is not set"
99 outputArray[ option ] = FILENAME " (" FNR ")"