]> git.pld-linux.org Git - packages/kernel.git/commitdiff
- rewritten and simplified, now it allows any combination of normal
authorsparky <sparky@pld-linux.org>
Thu, 18 Sep 2008 13:00:25 +0000 (13:00 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
  and multiarch options

Changed files:
    kernel-config.awk -> 1.2

kernel-config.awk

index bd7bb8ccff8cace227ce4479eed8d6cfe4969fe6..9408ad0cf6fea5fe7d73cc337d6e7b729c9dc895 100644 (file)
+# $Id$
 # A script for building kernel config from multiarch config file.
 # It also has some file merging facilities.
 #
 # usage:
 #  awk -v arch=%{_target_base_arch} -f path/to/kernel-config.awk \
-#    kernel-multiarch.config kernel-%{arch}.config kernel-%{some_feature}.config \
+#    kernel-important.config kernel-multiarch.config \
+#    kernel-%{arch}.config kernel-%{some_feature}.config \
 #     > .config
 #
+# Authors:
+# - Przemysław Iskra <sparky@pld-linux.org>
+# 
 # TODO:
 #  - check value correctness, should allow only:
 #    y, m, n, -[0-9]+, 0x[0-9A-Fa-f]+, ".*"
 #  - smarter arch split, there could be strings with spaces
 #    ( kernel-config.py does not suppoty it either )
 #  - use as many warnings as possible, we want our configs to be clean
-#  - allow more multiarch configs
+
+# no:
+# CONFIG_SOMETHING=n           -- should warn
+# SOMETHING=n                  -- should warn
+# CONFIG_SOMETHING all=n       -- should warn
+# SOMETHING all=n
+# # CONFIG_SOMETHING is not set        -- special case
+
+# yes/module/other
+# CONFIG_SOMETHING=y
+# SOMETHING=y                  -- should warn
+# CONFIG_SOMETHING all=y       -- should warn
+# SOMETHING all=y
+
+
+# return actual file name (without path) and line number
+function fileLine() {
+       f = FILENAME
+       gsub( /^.*\//, "", f ) # strip path
+
+       return f " (" FNR ")"
+}
 
 function warn( msg ) {
-       print FILENAME " (" FNR "): " msg > "/dev/stderr"
+       print fileLine() ": " msg > "/dev/stderr"
 }
 
 BEGIN {
        if ( ! arch ) {
-               warn( "arch= must be specified" )
+               print "arch= must be specified" > "/dev/stderr"
                exit 1
        }
-       firstfile = 1
 }
 
-{
-       # remember first file name
-       if ( ! file )
-               file = FILENAME
-
-       else if ( file != FILENAME ) { # second and following files
-               if ( match( $0, /CONFIG_[A-Za-z0-9_-]+/ ) ) {
-                       option = substr( $0, RSTART, RLENGTH )
-                       if ( $0 ~ "^" option "=.+$" || $0 ~ "^# " option " is not set$" ) {
-                               if ( option in outputArray )
-                                       warn( option " already defined in: " outputArray[ option ] )
-                               else {
-                                       print
-                                       outputArray[ option ] = FILENAME " (" FNR ")"
-                               }
-                       } else {
-                               if ( ! /^#/ )
-                                       warn( "Incorrect line: " $0 )
-                       }
-               } else if ( ! /^\s*$/ && ! /^#/ ) {
-                       warn( "Incorrect line: " $0 )
-               }
-               next
-       }
+# convert special case:
+# # CONFIG_SOMETHING it not set
+# to:
+# SOMETHING all=n
+/^# CONFIG_[A-Za-z0-9_-]+ is not set$/ {
+       match( $0, /CONFIG_[A-Za-z0-9_-]+/ )
+       option = substr( $0, RSTART, RLENGTH)
+       $0 = option " all=n"
 }
 
-# multiarch file proxessing
-
+# ignore all the comments
 /^#/ || /^\s*$/ {
        next
 }
 
-/^CONFIG_/ {
-       warn( "Options should not start with CONFIG_" )
-       gsub( /^CONFIG_/, "" )
+!/^CONFIG_/ {
+       $0 = "CONFIG_" $0
 }
 
 {
        option = $1
        line = $0
+       value = ""
        if ( option ~ /=/ ) {
-               warn( $0 " should have explicit ` all='" )
                gsub( /=.*$/, "", option )
                gsub( /^[^=]*=/, "", line )
-               line = "all=" line
+               value = line
        } else {
-               gsub( "^" option, "", line )
-       }
-       split( line, archs )
-
-       dest = ""
-       for ( inx in archs ) {
-               split( archs[inx], opt, "=" );
-               if ( opt[1] == "all" )
-                       dest = opt[2]
+               gsub( "^" option IFS, "", line )
+               split( line, archs )
+               for ( i in archs ) {
+                       split( archs[i], opt, "=" );
+                       if ( opt[1] == "all" )
+                               value = opt[2]
 
-               if ( opt[1] == arch ) {
-                       dest = opt[2]
-                       break
+                       if ( opt[1] == arch ) {
+                               # found best match, don't look further
+                               value = opt[2]
+                               break
+                       }
                }
        }
-       if ( length( dest ) ) {
-               option = "CONFIG_" option
 
-               if ( dest == "n" )
+       if ( option in outputArray ) {
+               warn( option " already defined in: " outputArray[ option ] )
+               next
+       }
+
+       if ( length( value ) ) {
+               if ( value == "n" )
                        out = "# " option " is not set"
                else
-                       out = option "=" dest
+                       out = option "=" value
+       
                print out
-
-               outputArray[ option ] = FILENAME " (" FNR ")"
+               outputArray[ option ] = fileLine()
        }
 }
 
This page took 2.02213 seconds and 4 git commands to generate.