]>
Commit | Line | Data |
---|---|---|
0c0de199 RL |
1 | #!/bin/sh |
2 | # | |
3 | # Generate the x86_cap_flags[] array from include/asm/cpufeature.h | |
4 | # | |
5 | ||
6 | IN=$1 | |
7 | OUT=$2 | |
8 | ||
9 | TABS="$(printf '\t\t\t\t\t')" | |
10 | trap 'rm "$OUT"' EXIT | |
11 | ||
12 | ( | |
13 | echo "#ifndef _ASM_X86_CPUFEATURE_H" | |
14 | echo "#include <asm/cpufeature.h>" | |
15 | echo "#endif" | |
16 | echo "" | |
17 | echo "const char * const x86_cap_flags[NCAPINTS*32] = {" | |
18 | ||
19 | # Iterate through any input lines starting with #define X86_FEATURE_ | |
20 | sed -n -e 's/\t/ /g' -e 's/^ *# *define *X86_FEATURE_//p' $IN | | |
21 | while read i | |
22 | do | |
23 | # Name is everything up to the first whitespace | |
24 | NAME="$(echo "$i" | sed 's/ .*//')" | |
25 | ||
26 | # If the /* comment */ starts with a quote string, grab that. | |
27 | VALUE="$(echo "$i" | sed -n 's@.*/\* *\("[^"]*"\).*\*/@\1@p')" | |
28 | [ -z "$VALUE" ] && VALUE="\"$NAME\"" | |
29 | [ "$VALUE" == '""' ] && continue | |
30 | ||
31 | # Name is uppercase, VALUE is all lowercase | |
32 | VALUE="$(echo "$VALUE" | tr A-Z a-z)" | |
33 | ||
34 | TABCOUNT=$(( ( 5*8 - 14 - $(echo "$NAME" | wc -c) ) / 8 )) | |
35 | printf "\t[%s]%.*s = %s,\n" \ | |
36 | "X86_FEATURE_$NAME" "$TABCOUNT" "$TABS" "$VALUE" | |
37 | done | |
38 | echo "};" | |
39 | ) > $OUT | |
40 | ||
41 | trap - EXIT |