Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | #!/bin/sh |
2 | # ========== Copyright Header Begin ========================================== | |
3 | # | |
4 | # OpenSPARC T2 Processor File: hasnative.sh | |
5 | # Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | # | |
8 | # The above named program is free software; you can redistribute it and/or | |
9 | # modify it under the terms of the GNU General Public | |
10 | # License version 2 as published by the Free Software Foundation. | |
11 | # | |
12 | # The above named program is distributed in the hope that it will be | |
13 | # useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | # General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public | |
18 | # License along with this work; if not, write to the Free Software | |
19 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | # | |
21 | # ========== Copyright Header End ============================================ | |
22 | ||
23 | usage() | |
24 | { | |
25 | echo "" | |
26 | echo "`basename $0` [-p <prefix>] <srcname> <destfile>" | |
27 | echo "" | |
28 | echo "\tgenerate a .h file for instruction IMPL types" | |
29 | exit 1 | |
30 | } | |
31 | ||
32 | prefix="_" | |
33 | if [ $# -gt 1 ]; then | |
34 | if [ $1 = "-p" ] ; then | |
35 | prefix=$2; | |
36 | prefix="_`echo $prefix | sed -e 's/\.h$//g' | tr '[a-z]-/' '[A-Z]__'`_" | |
37 | shift | |
38 | shift | |
39 | fi | |
40 | fi | |
41 | ||
42 | if [ ! "$#" = "2" ] ; then | |
43 | usage | |
44 | fi | |
45 | ||
46 | ||
47 | srcname=$1 | |
48 | name=$2 | |
49 | ||
50 | if [ ! "`echo $name | egrep '\.h$'`" = $name ] ;then | |
51 | echo $name is not a .h filename ! | |
52 | exit 1 | |
53 | fi | |
54 | ||
55 | # | |
56 | # ok dig out the base filename | |
57 | # | |
58 | ||
59 | bname=`basename $name | sed -e 's/\.h$//g' | tr '[a-z] -/' '[A-Z]___' | sed -e 's/__/_/g'` | |
60 | ||
61 | cat << END > $name | |
62 | ||
63 | #ifndef ${prefix}${bname}_H_ | |
64 | #define ${prefix}${bname}_H_ | |
65 | ||
66 | /* This file is autogenerated from $srcname - DO NOT EDIT */ | |
67 | ||
68 | END | |
69 | ||
70 | list=`egrep '^IMPL\(' $srcname | sed -e 's?IMPL(??' -e 's?).*??'` | |
71 | ||
72 | for n in $list ; do | |
73 | cat <<END >> $name | |
74 | #define HAS_NATIVE_${n} 1 | |
75 | END | |
76 | done | |
77 | ||
78 | cat <<END >> $name | |
79 | ||
80 | #endif /* #ifndef ${prefix}${bname}_H_ */ | |
81 | ||
82 | END | |
83 | ||
84 | exit 0 | |
85 |