Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / bin / nasconfig
CommitLineData
86530b38
AT
1#! /bin/sh
2#
3# nasconfig
4#
5# Cloned from .common_tool_wrapper
6
7loginfo () {
8 echo "DATE: "`date`
9 echo "WRAPPER: /import/$TRE_PROJECT/exe/.ccad_tool_wrapper"
10 echo "USER: "`/usr/ucb/whoami`
11 echo "HOST: "`uname -n`
12 echo "SYS: "`uname -s` `uname -r`
13 echo "PWD: "`pwd`
14 echo "ARGV: "$ARGV
15 echo "TOOL: "$tool
16 echo "VERSION: "$version
17 echo "TRE_SEARCH: "$TRE_SEARCH
18 echo "TRE_ENTRY: "$TRE_ENTRY
19}
20
21mailinfo () {
22 echo To: $1
23 echo Subject: TRE_LOG
24 echo "#"
25 loginfo
26}
27
28mailerr () {
29 echo "To: $1"
30 echo "Subject: TRE ERROR"
31 echo "#"
32 echo "ERROR: $2"
33 loginfo
34}
35
36log () {
37 # Log to TRE_LOG if it is set properly.
38 # It is STRONGLY recommended that TRE_LOG be an e-mail address
39 # in order to avoid problems with several people simultanously
40 # writing to the same file.
41 # TRE_LOG must be set, but it can be broken.
42 # TRE_ULOG is optional, for users who want their own logging.
43
44 if [ ! -z "$TRE_LOG_ENABLED" -a ! -z "$TRE_LOG" ] ; then
45 # Check first if TRE_LOG is a file (this is cheap).
46 if [ -f $TRE_LOG -a -w $TRE_LOG ] ; then
47 echo "#" >> $TRE_LOG
48 loginfo >> $TRE_LOG
49 elif /usr/lib/sendmail -bv $TRE_LOG 1>&- 2>&- ; then
50 mailinfo $TRE_LOG | /usr/lib/sendmail $TRE_LOG
51 else
52 user=`/usr/ucb/whoami`
53 mailerr $user "Can't log to TRE_LOG=$TRE_LOG. Fix environment." | /usr/lib/sendmail $user
54 fi
55 #else
56 # die "TRE_LOG environment variable is not set."
57 fi
58 # TRE_ULOG is optional user log. EMAIL address is recommended.
59 if [ ! -z "$TRE_ULOG" ] ; then
60 # Check first if TRE_ULOG is a file (this is cheap).
61 if [ -f $TRE_ULOG -a -w $TRE_ULOG ] ; then
62 echo "#" >> $TRE_ULOG
63 loginfo >> $TRE_ULOG
64 elif /usr/lib/sendmail -bv $TRE_ULOG 1>&- 2>&- ; then
65 mailinfo $TRE_ULOG | /usr/lib/sendmail $TRE_ULOG
66 else
67 user=`/usr/ucb/whoami`
68 mailerr $user "Can't log to TRE_ULOG=$TRE_ULOG. Fix environment." | /usr/lib/sendmail $user
69 fi
70 fi
71}
72
73die () {
74 message="$1"
75 echo "$tool -> .ccad_tool_wrapper: $message Exiting ..."
76 if [ ! -z "$TRE_LOG" ] ; then
77 if [ -f ${TRE_LOG} -a -w ${TRE_LOG} ] ; then
78 echo "#" >> $TRE_LOG
79 echo "ERROR: $message" >> $TRE_LOG
80 loginfo >> $TRE_LOG
81 elif /usr/lib/sendmail -bv $TRE_LOG 1>&- 2>&- ; then
82 mailerr $TRE_LOG "$message" | /usr/lib/sendmail $TRE_LOG
83 else
84 user=`/usr/ucb/whoami`
85 echo "Can not log to TRE_LOG=${TRE_LOG}. Logging to '$user.'"
86 mailerr $user "$message" | /usr/lib/sendmail $user
87 fi
88 fi
89 # TRE_ULOG is optional user log. EMAIL address is recommended.
90 if [ ! -z "$TRE_ULOG" ] ; then
91 if [ -f ${TRE_ULOG} -a -w ${TRE_ULOG} ] ; then
92 echo "#" >> $TRE_ULOG
93 echo "ERROR: $message" >> $TRE_ULOG
94 loginfo >> $TRE_ULOG
95 elif /usr/lib/sendmail -bv $TRE_ULOG 1>&- 2>&- ; then
96 mailerr $TRE_ULOG "$message" | /usr/lib/sendmail $TRE_ULOG
97 else
98 user=`/usr/ucb/whoami`
99 echo "Can not log to TRE_ULOG=${TRE_ULOG}. Logging to '$user.'"
100 mailerr $user "$message" | /usr/lib/sendmail $user
101 fi
102 fi
103 exit 1
104}
105
106############################ main ##############################
107
108tool=`basename $0`
109ARGV="$*"
110
111TRE_ROOT=$DV_ROOT/tools/src
112
113### Verify TRE_SEARCH and TRE_ENTRY are defined and non-null
114
115if [ -z "$TRE_SEARCH" ]; then
116 die "TRE_SEARCH not defined"
117fi
118if [ -z "$TRE_ENTRY" ]; then
119 die "TRE_ENTRY not defined"
120fi
121
122### Get version, based on tool invoked, and $TRE_ENTRY
123
124version=`configsrch nas $TRE_ENTRY`
125if [ $? != 0 ] ; then
126 die "configsrch returned error code!"
127fi
128
129### Verify configsrch delivered a non-null version
130
131if [ -z "$version" ]; then
132 die "No version set by configsrch"
133fi
134
135
136### Find out about cpp
137cppversion=`bw_cpp -V < /dev/null > /dev/null 2>&1`
138if [ $? != 0 ] ; then
139 ### It's an error, so it must be GNU cpp
140 cppargs=""
141else
142 ### It's sun cpp, so we need -B
143 cppargs="-B"
144fi
145
146###
147
148echo "sed 's/common.exe/diag.exe/' $TRE_ROOT/nas,$version/home/common/common.simics | sed 's/common.conf/diag.conf/' | bw_cpp $cppargs $ARGV | grep -v '^#' > diag.simics"
149
150log
151ret=`bw_cpp $cppargs -P $ARGV $TRE_ROOT/nas,$version/home/common/common.conf > diag.conf`
152ret=`sed 's/common.exe/diag.exe/' $TRE_ROOT/nas,$version/home/common/common.simics | sed 's/common.conf/diag.conf/' | bw_cpp $cppargs $ARGV | grep -v '^#' > diag.simics`