Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | #! /bin/sh |
2 | # ========== Copyright Header Begin ========================================== | |
3 | # | |
4 | # OpenSPARC T1 Processor File: bw_m4 | |
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 | # m4_gmp wrapper | |
24 | # | |
25 | # Cloned from .common_tool_wrapper | |
26 | ||
27 | loginfo () { | |
28 | echo "DATE: "`date` | |
29 | echo "WRAPPER: $TRE_PROJECT/tools" | |
30 | echo "USER: $user" | |
31 | echo "HOST: "`uname -n` | |
32 | echo "SYS: "`uname -s` `uname -r` | |
33 | echo "PWD: "`pwd` | |
34 | echo "ARGV: "$ARGV | |
35 | echo "TOOL: "$tool | |
36 | echo "VERSION: "$version | |
37 | echo "TRE_SEARCH: "$TRE_SEARCH | |
38 | echo "TRE_ENTRY: "$TRE_ENTRY | |
39 | } | |
40 | ||
41 | mailinfo () { | |
42 | echo To: $1 | |
43 | echo Subject: TRE_LOG | |
44 | echo "#" | |
45 | loginfo | |
46 | } | |
47 | ||
48 | mailerr () { | |
49 | echo "To: $1" | |
50 | echo "Subject: TRE ERROR" | |
51 | echo "#" | |
52 | echo "ERROR: $2" | |
53 | loginfo | |
54 | } | |
55 | ||
56 | log () { | |
57 | # Log to TRE_LOG if it is set properly. | |
58 | # It is STRONGLY recommended that TRE_LOG be an e-mail address | |
59 | # in order to avoid problems with several people simultanously | |
60 | # writing to the same file. | |
61 | # TRE_LOG must be set, but it can be broken. | |
62 | # TRE_ULOG is optional, for users who want their own logging. | |
63 | if [ ! -z "$TRE_LOG_ENABLED" ] ; then | |
64 | if [ ! -z "$TRE_LOG" ] ; then | |
65 | # Check first if TRE_LOG is a file (this is cheap). | |
66 | if [ -f $TRE_LOG -a -w $TRE_LOG ] ; then | |
67 | echo "#" >> $TRE_LOG | |
68 | loginfo >> $TRE_LOG | |
69 | elif /usr/lib/sendmail -bv $TRE_LOG 1>&- 2>&- ; then | |
70 | mailinfo $TRE_LOG | /usr/lib/sendmail $TRE_LOG | |
71 | else | |
72 | mailerr $user "Can't log to TRE_LOG=$TRE_LOG. Fix environment." | /usr/lib/sendmail $user | |
73 | fi | |
74 | else | |
75 | die "TRE_LOG environment variable is not set." | |
76 | fi | |
77 | fi | |
78 | # TRE_ULOG is optional user log. EMAIL address is recommended. | |
79 | if [ ! -z "$TRE_ULOG" ] ; then | |
80 | # Check first if TRE_ULOG is a file (this is cheap). | |
81 | if [ -f $TRE_ULOG -a -w $TRE_ULOG ] ; then | |
82 | echo "#" >> $TRE_ULOG | |
83 | loginfo >> $TRE_ULOG | |
84 | elif /usr/lib/sendmail -bv $TRE_ULOG 1>&- 2>&- ; then | |
85 | mailinfo $TRE_ULOG | /usr/lib/sendmail $TRE_ULOG | |
86 | else | |
87 | mailerr $user "Can't log to TRE_ULOG=$TRE_ULOG. Fix environment." | /usr/lib/sendmail $user | |
88 | fi | |
89 | fi | |
90 | } | |
91 | ||
92 | die () { | |
93 | message="$1" | |
94 | echo "$tool -> .local_tool_wrapper: $message Exiting ..." | |
95 | if [ ! -z "$TRE_LOG" ] ; then | |
96 | if [ -f ${TRE_LOG} -a -w ${TRE_LOG} ] ; then | |
97 | echo "#" >> $TRE_LOG | |
98 | echo "ERROR: $message" >> $TRE_LOG | |
99 | loginfo >> $TRE_LOG | |
100 | elif /usr/lib/sendmail -bv $TRE_LOG 1>&- 2>&- ; then | |
101 | mailerr $TRE_LOG "$message" | /usr/lib/sendmail $TRE_LOG | |
102 | else | |
103 | echo "Can not log to TRE_LOG=${TRE_LOG}. Logging to '$user.'" | |
104 | mailerr $user "$message" | /usr/lib/sendmail $user | |
105 | fi | |
106 | fi | |
107 | # TRE_ULOG is optional user log. EMAIL address is recommended. | |
108 | if [ ! -z "$TRE_ULOG" ] ; then | |
109 | if [ -f ${TRE_ULOG} -a -w ${TRE_ULOG} ] ; then | |
110 | echo "#" >> $TRE_ULOG | |
111 | echo "ERROR: $message" >> $TRE_ULOG | |
112 | loginfo >> $TRE_ULOG | |
113 | elif /usr/lib/sendmail -bv $TRE_ULOG 1>&- 2>&- ; then | |
114 | mailerr $TRE_ULOG "$message" | /usr/lib/sendmail $TRE_ULOG | |
115 | else | |
116 | echo "Can not log to TRE_ULOG=${TRE_ULOG}. Logging to '$user.'" | |
117 | mailerr $user "$message" | /usr/lib/sendmail $user | |
118 | fi | |
119 | fi | |
120 | exit 1 | |
121 | } | |
122 | ||
123 | ############################ main ############################## | |
124 | ||
125 | OS=`uname -s` | |
126 | ||
127 | if [ $OS = "SunOS" ] ; then | |
128 | user=`/usr/ucb/whoami` | |
129 | CPU=`uname -p` | |
130 | exe=$DV_ROOT/tools/SunOS/sparc/m4_gmp | |
131 | fi | |
132 | if [ $OS = "Linux" ] ; then | |
133 | user=`/usr/bin/whoami` | |
134 | CPU=`uname -m` | |
135 | exe=$DV_ROOT/tools/Linux/x86_64/m4_gmp | |
136 | fi | |
137 | ||
138 | LD_LIBRARY_PATH=$DV_ROOT/tools/$OS/$CPU/lib | |
139 | export LD_LIBRARY_PATH | |
140 | ||
141 | if [ -x $exe ]; then | |
142 | log | |
143 | exec $exe $ARGV | |
144 | else | |
145 | die "executable $exe not found!" | |
146 | fi | |
147 | fi |