diff options
author | Rob Landley <rob@landley.net> | 2013-04-29 18:05:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-04-29 18:54:27 -0400 |
commit | 0c0de199ce1fef20c86679194e31133da21c3c2a (patch) | |
tree | 3a6fdc1da8e6856baba1bd736908e38b0f7dfc30 | |
parent | ec686c9239b4d472052a271c505d04dae84214cc (diff) |
mkcapflags.pl: convert to mkcapflags.sh
Generate asm-x86/cpufeature.h with posix-2008 commands instead of perl.
Signed-off-by: Rob Landley <rob@landley.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Josh Boyer <jwboyer@redhat.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: David Howells <dhowell@redhat.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/x86/kernel/cpu/Makefile | 4 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mkcapflags.pl | 48 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mkcapflags.sh | 41 |
3 files changed, 43 insertions, 50 deletions
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile index a0e067d3d96c..c9496313843b 100644 --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile | |||
@@ -43,10 +43,10 @@ obj-$(CONFIG_MTRR) += mtrr/ | |||
43 | obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o perf_event_amd_ibs.o | 43 | obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o perf_event_amd_ibs.o |
44 | 44 | ||
45 | quiet_cmd_mkcapflags = MKCAP $@ | 45 | quiet_cmd_mkcapflags = MKCAP $@ |
46 | cmd_mkcapflags = $(PERL) $(srctree)/$(src)/mkcapflags.pl $< $@ | 46 | cmd_mkcapflags = $(CONFIG_SHELL) $(srctree)/$(src)/mkcapflags.sh $< $@ |
47 | 47 | ||
48 | cpufeature = $(src)/../../include/asm/cpufeature.h | 48 | cpufeature = $(src)/../../include/asm/cpufeature.h |
49 | 49 | ||
50 | targets += capflags.c | 50 | targets += capflags.c |
51 | $(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.pl FORCE | 51 | $(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.sh FORCE |
52 | $(call if_changed,mkcapflags) | 52 | $(call if_changed,mkcapflags) |
diff --git a/arch/x86/kernel/cpu/mkcapflags.pl b/arch/x86/kernel/cpu/mkcapflags.pl deleted file mode 100644 index 091972ef49de..000000000000 --- a/arch/x86/kernel/cpu/mkcapflags.pl +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | # | ||
3 | # Generate the x86_cap_flags[] array from include/asm-x86/cpufeature.h | ||
4 | # | ||
5 | |||
6 | ($in, $out) = @ARGV; | ||
7 | |||
8 | open(IN, "< $in\0") or die "$0: cannot open: $in: $!\n"; | ||
9 | open(OUT, "> $out\0") or die "$0: cannot create: $out: $!\n"; | ||
10 | |||
11 | print OUT "#ifndef _ASM_X86_CPUFEATURE_H\n"; | ||
12 | print OUT "#include <asm/cpufeature.h>\n"; | ||
13 | print OUT "#endif\n"; | ||
14 | print OUT "\n"; | ||
15 | print OUT "const char * const x86_cap_flags[NCAPINTS*32] = {\n"; | ||
16 | |||
17 | %features = (); | ||
18 | $err = 0; | ||
19 | |||
20 | while (defined($line = <IN>)) { | ||
21 | if ($line =~ /^\s*\#\s*define\s+(X86_FEATURE_(\S+))\s+(.*)$/) { | ||
22 | $macro = $1; | ||
23 | $feature = "\L$2"; | ||
24 | $tail = $3; | ||
25 | if ($tail =~ /\/\*\s*\"([^"]*)\".*\*\//) { | ||
26 | $feature = "\L$1"; | ||
27 | } | ||
28 | |||
29 | next if ($feature eq ''); | ||
30 | |||
31 | if ($features{$feature}++) { | ||
32 | print STDERR "$in: duplicate feature name: $feature\n"; | ||
33 | $err++; | ||
34 | } | ||
35 | printf OUT "\t%-32s = \"%s\",\n", "[$macro]", $feature; | ||
36 | } | ||
37 | } | ||
38 | print OUT "};\n"; | ||
39 | |||
40 | close(IN); | ||
41 | close(OUT); | ||
42 | |||
43 | if ($err) { | ||
44 | unlink($out); | ||
45 | exit(1); | ||
46 | } | ||
47 | |||
48 | exit(0); | ||
diff --git a/arch/x86/kernel/cpu/mkcapflags.sh b/arch/x86/kernel/cpu/mkcapflags.sh new file mode 100644 index 000000000000..2bf616505499 --- /dev/null +++ b/arch/x86/kernel/cpu/mkcapflags.sh | |||
@@ -0,0 +1,41 @@ | |||
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 | ||