ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / sh / tools / machgen.sh
1 #!/bin/sh
2 #
3 # include/asm-sh/machtype.h header generation script for SuperH
4 #
5 # Copyright (C) 2003 Paul Mundt
6 #
7 # This is pretty much a quick and dirty hack based off of the awk
8 # script written by rmk that ARM uses to achieve the same sort of
9 # thing.
10 #
11 # Unfortunately this script has a dependance on bash/sed/cut/tr,
12 # though they should be prevalent enough for this dependancy not
13 # to matter overly much.
14 #
15 # As a note for anyone attempting to manually invoke this script,
16 # it expects to be run straight out of the arch/sh/tools/ directory
17 # as it doesn't look at TOPDIR to figure out where asm-sh is
18 # located.
19 #
20 # See the note at the top of the generated header for additional
21 # information.
22 #
23 # Released under the terms of the GNU GPL v2.0.
24 #
25
26 [ $# -ne 1 ] && echo "Usage: $0 <mach defs>" && exit 1
27
28 cat << EOF > tmp.h
29 /*
30  * Automagically generated, don't touch.
31  */
32 #ifndef __ASM_SH_MACHTYPES_H
33 #define __ASM_SH_MACHTYPES_H
34
35 #include <linux/config.h>
36
37 /*
38  * We'll use the following MACH_xxx defs for placeholders for the time
39  * being .. these will all go away once sh_machtype is assigned per-board.
40  *
41  * For now we leave things the way they are for backwards compatibility.
42  */
43
44 /* Mach types */
45 EOF
46
47 newline='
48 '
49 IFS=$newline
50
51 rm -f tmp2.h
52
53 for entry in `cat $1 | sed -e 's/\#.*$//g;/^$/d' | tr '\t' ' ' | tr -s ' '`; do
54         board=`echo $entry | cut -f1 -d' '`
55
56         printf "#ifdef CONFIG_`echo $entry | cut -f2 -d' '`\n" >> tmp.h
57         printf "  #define MACH_$board\t\t1\n#else\n  #define MACH_$board\t\t0\n#endif\n" >> tmp.h
58         printf "#define mach_is_`echo $board | tr '[A-Z]' '[a-z]'`()\t\t\t(MACH_$board)\n" >> tmp2.h
59 done
60
61 printf "\n/* Machtype checks */\n" >> tmp.h
62 cat tmp2.h >> tmp.h && rm -f tmp2.h
63
64 cat << EOF >> tmp.h
65
66 #endif /* __ASM_SH_MACHTYPES_H */
67 EOF
68
69 cat tmp.h
70 rm -f tmp.h
71