]>
Commit | Line | Data |
---|---|---|
c5f08860 | 1 | # $Id$ |
38a2649a | 2 | # A script for building kernel config from multiarch config file. |
3 | # It also has some file merging facilities. | |
4 | # | |
5 | # usage: | |
6 | # awk -v arch=%{_target_base_arch} -f path/to/kernel-config.awk \ | |
c5f08860 | 7 | # kernel-important.config kernel-multiarch.config \ |
8 | # kernel-%{arch}.config kernel-%{some_feature}.config \ | |
38a2649a | 9 | # > .config |
10 | # | |
c5f08860 | 11 | # Authors: |
12 | # - Przemysław Iskra <sparky@pld-linux.org> | |
13 | # | |
38a2649a | 14 | # TODO: |
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 | |
c5f08860 | 20 | |
21 | # no: | |
22 | # CONFIG_SOMETHING=n -- should warn | |
23 | # SOMETHING=n -- should warn | |
24 | # CONFIG_SOMETHING all=n -- should warn | |
25 | # SOMETHING all=n | |
26 | # # CONFIG_SOMETHING is not set -- special case | |
27 | ||
28 | # yes/module/other | |
29 | # CONFIG_SOMETHING=y | |
30 | # SOMETHING=y -- should warn | |
31 | # CONFIG_SOMETHING all=y -- should warn | |
32 | # SOMETHING all=y | |
33 | ||
34 | ||
35 | # return actual file name (without path) and line number | |
36 | function fileLine() { | |
37 | f = FILENAME | |
38 | gsub( /^.*\//, "", f ) # strip path | |
39 | ||
40 | return f " (" FNR ")" | |
41 | } | |
38a2649a | 42 | |
43 | function warn( msg ) { | |
c5f08860 | 44 | print fileLine() ": " msg > "/dev/stderr" |
38a2649a | 45 | } |
46 | ||
47 | BEGIN { | |
48 | if ( ! arch ) { | |
c5f08860 | 49 | print "arch= must be specified" > "/dev/stderr" |
38a2649a | 50 | exit 1 |
51 | } | |
38a2649a | 52 | } |
53 | ||
c5f08860 | 54 | # convert special case: |
55 | # # CONFIG_SOMETHING it not set | |
56 | # to: | |
57 | # SOMETHING all=n | |
58 | /^# CONFIG_[A-Za-z0-9_-]+ is not set$/ { | |
59 | match( $0, /CONFIG_[A-Za-z0-9_-]+/ ) | |
60 | option = substr( $0, RSTART, RLENGTH) | |
61 | $0 = option " all=n" | |
38a2649a | 62 | } |
63 | ||
c5f08860 | 64 | # ignore all the comments |
38a2649a | 65 | /^#/ || /^\s*$/ { |
66 | next | |
67 | } | |
68 | ||
c5f08860 | 69 | !/^CONFIG_/ { |
70 | $0 = "CONFIG_" $0 | |
38a2649a | 71 | } |
72 | ||
73 | { | |
74 | option = $1 | |
75 | line = $0 | |
c5f08860 | 76 | value = "" |
38a2649a | 77 | if ( option ~ /=/ ) { |
38a2649a | 78 | gsub( /=.*$/, "", option ) |
79 | gsub( /^[^=]*=/, "", line ) | |
c5f08860 | 80 | value = line |
38a2649a | 81 | } else { |
c5f08860 | 82 | gsub( "^" option IFS, "", line ) |
83 | split( line, archs ) | |
84 | for ( i in archs ) { | |
85 | split( archs[i], opt, "=" ); | |
86 | if ( opt[1] == "all" ) | |
87 | value = opt[2] | |
38a2649a | 88 | |
c5f08860 | 89 | if ( opt[1] == arch ) { |
90 | # found best match, don't look further | |
91 | value = opt[2] | |
92 | break | |
93 | } | |
38a2649a | 94 | } |
95 | } | |
38a2649a | 96 | |
c5f08860 | 97 | if ( option in outputArray ) { |
98 | warn( option " already defined in: " outputArray[ option ] ) | |
99 | next | |
100 | } | |
101 | ||
102 | if ( length( value ) ) { | |
103 | if ( value == "n" ) | |
38a2649a | 104 | out = "# " option " is not set" |
105 | else | |
c5f08860 | 106 | out = option "=" value |
107 | ||
38a2649a | 108 | print out |
c5f08860 | 109 | outputArray[ option ] = fileLine() |
38a2649a | 110 | } |
111 | } | |
112 | ||
113 | END { | |
114 | } |