# It also has some file merging facilities.
#
# usage:
-# awk -v arch=%{_target_base_arch} -f path/to/kernel-config.awk \
+# awk -v basearch=%{_target_base_arch} -v arch=%{_target_cpu} -f path/to/kernel-config.awk \
# kernel-important.config kernel-multiarch.config \
# kernel-%{arch}.config kernel-%{some_feature}.config \
# > .config
# - glen@pld-linux.org
#
# TODO:
-# - 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
# no:
print "arch= must be specified" > "/dev/stderr"
exit 1
}
- if ( ! basearch )
- basearch = arch
-
- targetLevel[ "all" ] = 1
- targetLevel[ basearch ] = 2
- targetLevel[ arch ] = 3
+ split( arch, Archs )
+ for (i = 1; i in Archs; i++) {
+ targetLevel[ Archs[ i ] ] = i
+ }
shouldDie = 0
+
+ lastFile = ""
}
function dieLater( code ) {
shouldDie = code
}
+{
+ f = FILENAME
+ sub( /^.*\//, "", f ) # strip path
+ if ( f != lastFile ) {
+ print "\n# file: " f
+ lastFile = f
+ }
+}
+
# convert special case:
# # CONFIG_SOMETHING it not set
# to:
next
}
+!/^[A-Za-z0-9_]+(=|[ \t]+[A-Za-z0-9_-]+=)/ {
+ warn( "ERROR: Incorrect line: " $0 )
+ dieLater( 3 )
+ next
+}
+
!/^CONFIG_/ {
$0 = "CONFIG_" $0
}
sub( "^" option, "", line )
sub( /^[ \t]*/, "", line )
+ delete archs
if ( line ~ /"/ ) {
# there can be white spaces
i = 0
- while ( match( line, /^[^=]+="[^"]*"/ ) ) {
+ while ( match( line, /^[^=]+="([^"]|\\")*"/ ) ) {
archs[ (++i) ] = substr( line, RSTART, RLENGTH )
line = substr( line, RSTART + RLENGTH )
sub( /^[ \t]*/, "", line )
level = 0
for ( i in archs ) {
- split( archs[i], opt, "=" );
- tl = targetLevel[ opt[ 1 ] ]
+ arch = val = archs[ i ]
+ sub( /=.*$/, "", arch )
+ sub( /^[^=]*=/, "", val )
+ tl = targetLevel[ arch ]
if ( tl > level ) {
- value = opt[2]
+ value = val
level = tl
}
}
if ( value == "y" || value == "m" )
; # OK
- else if ( value ~ /^"[^"]*"$/ )
+ else if ( value ~ /^"([^"]|\\")*"$/ )
; # OK
else if ( value ~ /^-?[0-9]+$/ || value ~ /^0x[0-9A-Fa-f]+$/ )
; # OK