Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / bin / rsyn
CommitLineData
86530b38
AT
1#! /bin/sh
2# ========== Copyright Header Begin ==========================================
3#
4# OpenSPARC T2 Processor File: rsyn
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# SCCS ID: @(#).perl_wrapper 1.1 02/03/99
24#
25# Cloned from .common_tool_wrapper
26
27loginfo () {
28 echo "DATE: "`date`
29 echo "WRAPPER: $TRE_PROJECT/tools/bin/perl_wrapper"
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
41mailinfo () {
42 echo To: $1
43 echo Subject: TRE_LOG
44 echo "#"
45 loginfo
46}
47
48mailerr () {
49 echo "To: $1"
50 echo "Subject: TRE ERROR"
51 echo "#"
52 echo "ERROR: $2"
53 loginfo
54}
55
56log () {
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
92die () {
93 message="$1"
94 echo "$tool -> perl_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
125tool=`basename $0`
126ARGV="$*"
127TRE_PROJECT=$DV_ROOT
128
129if [ -z "$TRE_PROJECT" ]; then
130 die "TRE_PROJECT not defined"
131fi
132
133TRE_ROOT=$TRE_PROJECT/tools/perlmod
134
135### Verify TRE_SEARCH and TRE_ENTRY are defined and non-null
136
137if [ -z "$TRE_SEARCH" ]; then
138 die "TRE_SEARCH not defined"
139fi
140if [ -z "$TRE_ENTRY" ]; then
141 die "TRE_ENTRY not defined"
142fi
143
144### Get version, based on tool invoked, and $TRE_ENTRY
145
146if [ $tool = "configsrch" ] ; then
147 exe=$TRE_ROOT/$tool
148 exec $exe "$@"
149 exit
150else
151
152 version=`configsrch $tool $TRE_ENTRY 2>&1`
153 stat=$?
154 if [ $stat != 0 ] ; then
155 die "configsrch returned error code $stat"
156 fi
157
158 ### Verify configsrch delivered a non-null version
159
160 if [ -z "$version" ]; then
161 die "No version set by configsrch"
162 fi
163fi
164
165### Assemble do-file name. If it's there, execute and test status.
166
167exe=$TRE_ROOT/$tool,$version.do
168if [ -x $exe ]; then
169 $exe
170 dostat=$?
171 if [ $? != 0 ] ; then
172 die "Error return from do file"
173 fi
174fi
175
176OS=`uname -s`
177if [ $OS = "SunOS" ] ; then
178 user=`/usr/ucb/whoami`
179 CPU=`uname -p`
180fi
181if [ $OS = "Linux" ]; then
182 user=`/usr/bin/whoami`
183 CPU=`uname -m`
184fi
185
186if [ -z "$PERL_VER" ] ; then
187 if [ -z "$PERL5OPT" ] ; then
188 PERL5OPT="-I$PERL_MODULE_BASE -I$PERL_MODULE_BASE/$OS-$CPU"
189 else
190 PERL5OPT="-I$PERL_MODULE_BASE -I$PERL_MODULE_BASE/$OS-$CPU $PERL5OPT"
191 fi
192else
193 if [ -z "$PERL5OPT" ] ; then
194 PERL5OPT="-I$PERL_MODULE_BASE -I$PERL_MODULE_BASE/$OS-$CPU -I$PERL5_PATH/$PERL_VER -I$PERL5_PATH/$PERL_VER/sun4-solaris"
195 else
196 PERL5OPT="-I$PERL_MODULE_BASE -I$PERL_MODULE_BASE/$OS-$CPU -I$PERL5_PATH/$PERL_VER -I$PERL5_PATH/$PERL_VER/sun4-solaris $PERL5OPT"
197 fi
198fi
199export PERL5OPT
200
201
202exe=$TRE_ROOT/$tool,$version
203if [ -x $exe ]; then
204 exec $PERL_CMD $exe "$@"
205else
206 die "executable $exe not found!"
207fi