xref: /titanic_51/usr/src/tools/scripts/ws.sh (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate#!/bin/sh
2*7c478bd9Sstevel@tonic-gate#
3*7c478bd9Sstevel@tonic-gate# CDDL HEADER START
4*7c478bd9Sstevel@tonic-gate#
5*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*7c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*7c478bd9Sstevel@tonic-gate# with the License.
9*7c478bd9Sstevel@tonic-gate#
10*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
13*7c478bd9Sstevel@tonic-gate# and limitations under the License.
14*7c478bd9Sstevel@tonic-gate#
15*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*7c478bd9Sstevel@tonic-gate#
21*7c478bd9Sstevel@tonic-gate# CDDL HEADER END
22*7c478bd9Sstevel@tonic-gate#
23*7c478bd9Sstevel@tonic-gate#
24*7c478bd9Sstevel@tonic-gate# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
25*7c478bd9Sstevel@tonic-gate# Use is subject to license terms.
26*7c478bd9Sstevel@tonic-gate#
27*7c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate#
29*7c478bd9Sstevel@tonic-gate#	This script sets up the environment variables for a SunOS
30*7c478bd9Sstevel@tonic-gate#	codemgr workspace and spawns a shell with the environment
31*7c478bd9Sstevel@tonic-gate#	setup.
32*7c478bd9Sstevel@tonic-gate#
33*7c478bd9Sstevel@tonic-gate#	The following Environment variables are set:
34*7c478bd9Sstevel@tonic-gate#		CODEMGR_WS
35*7c478bd9Sstevel@tonic-gate#		ONBLD_DIR
36*7c478bd9Sstevel@tonic-gate#		SRC
37*7c478bd9Sstevel@tonic-gate#		TSRC
38*7c478bd9Sstevel@tonic-gate#		ROOT
39*7c478bd9Sstevel@tonic-gate#		PARENT_ROOT
40*7c478bd9Sstevel@tonic-gate#		MACH
41*7c478bd9Sstevel@tonic-gate#		MAKEFLAGS
42*7c478bd9Sstevel@tonic-gate#		ENVCPPFLAGS{1-4}
43*7c478bd9Sstevel@tonic-gate#		ENVLDLIBS{1-3}
44*7c478bd9Sstevel@tonic-gate#
45*7c478bd9Sstevel@tonic-gate#	The MAKEFLAGS environment variable is set to force make
46*7c478bd9Sstevel@tonic-gate#	to read default make variables from the environment.
47*7c478bd9Sstevel@tonic-gate#
48*7c478bd9Sstevel@tonic-gate#	Workspace names can be specified in two forms: pathname
49*7c478bd9Sstevel@tonic-gate#	and hostname:pathname.  If the hostname:pathname form is used
50*7c478bd9Sstevel@tonic-gate#	the script accesses the environment through the /net automounter
51*7c478bd9Sstevel@tonic-gate#	map.
52*7c478bd9Sstevel@tonic-gate#
53*7c478bd9Sstevel@tonic-gate
54*7c478bd9Sstevel@tonic-gate#
55*7c478bd9Sstevel@tonic-gate# function to produce a pathname from a workspace name or subdirectory.
56*7c478bd9Sstevel@tonic-gate# The workspace name can have hostname:pathname format.
57*7c478bd9Sstevel@tonic-gate#
58*7c478bd9Sstevel@tonic-gate
59*7c478bd9Sstevel@tonic-gatefmtwsname(){
60*7c478bd9Sstevel@tonic-gate	awk -F: '$1 != $0 { print "/net/"$1$2 } \
61*7c478bd9Sstevel@tonic-gate		 $1 == $0 { print $0 }'
62*7c478bd9Sstevel@tonic-gate}
63*7c478bd9Sstevel@tonic-gate
64*7c478bd9Sstevel@tonic-gate#
65*7c478bd9Sstevel@tonic-gate# function to check to see if a proto area is new or old format
66*7c478bd9Sstevel@tonic-gate#
67*7c478bd9Sstevel@tonic-gatecheck_proto()
68*7c478bd9Sstevel@tonic-gate{
69*7c478bd9Sstevel@tonic-gate	# Check for problematic parent specification and adjust
70*7c478bd9Sstevel@tonic-gate	proto=`echo $1|fmtwsname`
71*7c478bd9Sstevel@tonic-gate	#
72*7c478bd9Sstevel@tonic-gate	# if proto contains a /usr/include directory we assume
73*7c478bd9Sstevel@tonic-gate	# that this is an old style proto area
74*7c478bd9Sstevel@tonic-gate	#
75*7c478bd9Sstevel@tonic-gate	if [ -d $proto/usr/include ]; then
76*7c478bd9Sstevel@tonic-gate		echo $proto
77*7c478bd9Sstevel@tonic-gate	else
78*7c478bd9Sstevel@tonic-gate		echo "${proto}/root_${MACH}"
79*7c478bd9Sstevel@tonic-gate	fi
80*7c478bd9Sstevel@tonic-gate}
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gatecleanup_env()
83*7c478bd9Sstevel@tonic-gate{
84*7c478bd9Sstevel@tonic-gate	# keep the env. clean when returning
85*7c478bd9Sstevel@tonic-gate	unset setenv osbld_flag os_rev wsosdir protofile wsname ofs proto \
86*7c478bd9Sstevel@tonic-gate		pwd parent PROTO1 PROTO2 PROTO3 tmpwsname
87*7c478bd9Sstevel@tonic-gate	return 0
88*7c478bd9Sstevel@tonic-gate}
89*7c478bd9Sstevel@tonic-gate
90*7c478bd9Sstevel@tonic-gateif [ "$1" = "-e" ]; then
91*7c478bd9Sstevel@tonic-gate	setenv=true
92*7c478bd9Sstevel@tonic-gate	shift
93*7c478bd9Sstevel@tonic-gateelse
94*7c478bd9Sstevel@tonic-gate	setenv=false
95*7c478bd9Sstevel@tonic-gatefi
96*7c478bd9Sstevel@tonic-gate
97*7c478bd9Sstevel@tonic-gateif [ $# -lt 1 ]; then
98*7c478bd9Sstevel@tonic-gate	set -- `workspace name`
99*7c478bd9Sstevel@tonic-gate	[ $# -eq 1 ] && echo "Defaulting to workspace $1"
100*7c478bd9Sstevel@tonic-gatefi
101*7c478bd9Sstevel@tonic-gate
102*7c478bd9Sstevel@tonic-gateif [ $# -lt 1 ]; then
103*7c478bd9Sstevel@tonic-gate	echo "usage: ws [-e] [workspace_name]" >&2
104*7c478bd9Sstevel@tonic-gate	if $setenv; then
105*7c478bd9Sstevel@tonic-gate		cleanup_env
106*7c478bd9Sstevel@tonic-gate		return 1
107*7c478bd9Sstevel@tonic-gate	else
108*7c478bd9Sstevel@tonic-gate		exit 1
109*7c478bd9Sstevel@tonic-gate	fi
110*7c478bd9Sstevel@tonic-gatefi
111*7c478bd9Sstevel@tonic-gate
112*7c478bd9Sstevel@tonic-gate#
113*7c478bd9Sstevel@tonic-gate#	This variable displays the nested activations of workspaces.
114*7c478bd9Sstevel@tonic-gate#	This is done here to get the exact name the user entered.
115*7c478bd9Sstevel@tonic-gate#
116*7c478bd9Sstevel@tonic-gateWS_STACK="$1 $WS_STACK"; export WS_STACK
117*7c478bd9Sstevel@tonic-gate
118*7c478bd9Sstevel@tonic-gatewsname=`echo $1|fmtwsname`
119*7c478bd9Sstevel@tonic-gateshift
120*7c478bd9Sstevel@tonic-gate
121*7c478bd9Sstevel@tonic-gate#
122*7c478bd9Sstevel@tonic-gate# Checking for CODEMGR_WSPATH
123*7c478bd9Sstevel@tonic-gate#
124*7c478bd9Sstevel@tonic-gateif [ "(" "${CODEMGR_WSPATH}x" != "x" ")" -a "(" ! -d $wsname ")" -a \
125*7c478bd9Sstevel@tonic-gate     "(" `expr "$wsname" : "\/"` = "0" ")" ]
126*7c478bd9Sstevel@tonic-gatethen
127*7c478bd9Sstevel@tonic-gate	ofs=$IFS
128*7c478bd9Sstevel@tonic-gate	IFS=": 	"
129*7c478bd9Sstevel@tonic-gate	for i in $CODEMGR_WSPATH
130*7c478bd9Sstevel@tonic-gate	do
131*7c478bd9Sstevel@tonic-gate		if [ -d ${i}/${wsname} ]; then
132*7c478bd9Sstevel@tonic-gate			wsname=${i}/${wsname}
133*7c478bd9Sstevel@tonic-gate			break
134*7c478bd9Sstevel@tonic-gate		fi
135*7c478bd9Sstevel@tonic-gate	done
136*7c478bd9Sstevel@tonic-gate	IFS=$ofs
137*7c478bd9Sstevel@tonic-gatefi
138*7c478bd9Sstevel@tonic-gate
139*7c478bd9Sstevel@tonic-gate# to translate it to an absolute pathname.  We need an
140*7c478bd9Sstevel@tonic-gate# absolute pathname in order to set CODEMGR_WS.
141*7c478bd9Sstevel@tonic-gate#
142*7c478bd9Sstevel@tonic-gateif [ `expr "$wsname" : "\/"` = "0" ]
143*7c478bd9Sstevel@tonic-gatethen
144*7c478bd9Sstevel@tonic-gate	pwd=`pwd`
145*7c478bd9Sstevel@tonic-gate	wsname="$pwd/$wsname"
146*7c478bd9Sstevel@tonic-gatefi
147*7c478bd9Sstevel@tonic-gate
148*7c478bd9Sstevel@tonic-gateif [ ! -d $wsname/Codemgr_wsdata ]; then
149*7c478bd9Sstevel@tonic-gate	echo "Error: $wsname is not a workspace" >&2
150*7c478bd9Sstevel@tonic-gate	if $setenv; then
151*7c478bd9Sstevel@tonic-gate		cleanup_env
152*7c478bd9Sstevel@tonic-gate		return 1
153*7c478bd9Sstevel@tonic-gate	else
154*7c478bd9Sstevel@tonic-gate		exit 1
155*7c478bd9Sstevel@tonic-gate	fi
156*7c478bd9Sstevel@tonic-gatefi
157*7c478bd9Sstevel@tonic-gate
158*7c478bd9Sstevel@tonic-gatetmpwsname=`(cd $wsname >/dev/null && workspace name)`
159*7c478bd9Sstevel@tonic-gateif [ -z "$tmpwsname" ]; then
160*7c478bd9Sstevel@tonic-gate	echo "Error: $wsname is not a workspace" >&2
161*7c478bd9Sstevel@tonic-gate	if $setenv; then
162*7c478bd9Sstevel@tonic-gate		cleanup_env
163*7c478bd9Sstevel@tonic-gate		return 1
164*7c478bd9Sstevel@tonic-gate	else
165*7c478bd9Sstevel@tonic-gate		exit 1
166*7c478bd9Sstevel@tonic-gate	fi
167*7c478bd9Sstevel@tonic-gatefi
168*7c478bd9Sstevel@tonic-gatewsname=$tmpwsname
169*7c478bd9Sstevel@tonic-gate
170*7c478bd9Sstevel@tonic-gate#
171*7c478bd9Sstevel@tonic-gate#	Check to see if this is a valid workspace
172*7c478bd9Sstevel@tonic-gate#
173*7c478bd9Sstevel@tonic-gateif [ ! -d $wsname ]; then
174*7c478bd9Sstevel@tonic-gate	echo "$wsname . . . no such directory" >&2
175*7c478bd9Sstevel@tonic-gate	if $setenv; then
176*7c478bd9Sstevel@tonic-gate		cleanup_env
177*7c478bd9Sstevel@tonic-gate		return 1
178*7c478bd9Sstevel@tonic-gate	else
179*7c478bd9Sstevel@tonic-gate		exit 1
180*7c478bd9Sstevel@tonic-gate	fi
181*7c478bd9Sstevel@tonic-gatefi
182*7c478bd9Sstevel@tonic-gateif [ -d ${wsname}/Codemgr_wsdata ]; then
183*7c478bd9Sstevel@tonic-gate	CM_DATA=Codemgr_wsdata
184*7c478bd9Sstevel@tonic-gateelse
185*7c478bd9Sstevel@tonic-gate	echo "$wsname is not a workspace" >&2
186*7c478bd9Sstevel@tonic-gate	if $setenv; then
187*7c478bd9Sstevel@tonic-gate		cleanup_env
188*7c478bd9Sstevel@tonic-gate		return 1
189*7c478bd9Sstevel@tonic-gate	else
190*7c478bd9Sstevel@tonic-gate		exit 1
191*7c478bd9Sstevel@tonic-gate	fi
192*7c478bd9Sstevel@tonic-gatefi
193*7c478bd9Sstevel@tonic-gate
194*7c478bd9Sstevel@tonic-gateCODEMGR_WS=$wsname; export CODEMGR_WS
195*7c478bd9Sstevel@tonic-gateSRC=$CODEMGR_WS/usr/src; export SRC
196*7c478bd9Sstevel@tonic-gateTSRC=$CODEMGR_WS/usr/ontest; export TSRC
197*7c478bd9Sstevel@tonic-gate
198*7c478bd9Sstevel@tonic-gatewsosdir=$CODEMGR_WS/$CM_DATA/sunos
199*7c478bd9Sstevel@tonic-gateprotofile=$wsosdir/protodefs
200*7c478bd9Sstevel@tonic-gate
201*7c478bd9Sstevel@tonic-gateif [ ! -f $protofile ]; then
202*7c478bd9Sstevel@tonic-gate	if [ ! -w $CODEMGR_WS/$CM_DATA ]; then
203*7c478bd9Sstevel@tonic-gate		#
204*7c478bd9Sstevel@tonic-gate		# The workspace doesn't have a protodefs file and I am
205*7c478bd9Sstevel@tonic-gate		# unable to create one.  Tell user and use /tmp instead.
206*7c478bd9Sstevel@tonic-gate		#
207*7c478bd9Sstevel@tonic-gate		echo "Unable to create the proto defaults file ($protofile)."
208*7c478bd9Sstevel@tonic-gate
209*7c478bd9Sstevel@tonic-gate		# Just make one in /tmp
210*7c478bd9Sstevel@tonic-gate		wsosdir=/tmp
211*7c478bd9Sstevel@tonic-gate		protofile=$wsosdir/protodefs
212*7c478bd9Sstevel@tonic-gate	fi
213*7c478bd9Sstevel@tonic-gate
214*7c478bd9Sstevel@tonic-gate	if [ ! -d $wsosdir ]; then
215*7c478bd9Sstevel@tonic-gate		mkdir $wsosdir
216*7c478bd9Sstevel@tonic-gate	fi
217*7c478bd9Sstevel@tonic-gate
218*7c478bd9Sstevel@tonic-gate	cat << PROTOFILE_EoF > $protofile
219*7c478bd9Sstevel@tonic-gate#!/bin/sh
220*7c478bd9Sstevel@tonic-gate#
221*7c478bd9Sstevel@tonic-gate#	Set default proto areas for this workspace
222*7c478bd9Sstevel@tonic-gate#	NOTE: This file was initially automatically generated.
223*7c478bd9Sstevel@tonic-gate#
224*7c478bd9Sstevel@tonic-gate#	Feel free to edit this file.  If this file is removed
225*7c478bd9Sstevel@tonic-gate#	it will be rebuilt containing default values.
226*7c478bd9Sstevel@tonic-gate#
227*7c478bd9Sstevel@tonic-gate#	The variable CODEMGR_WS is available to this script.
228*7c478bd9Sstevel@tonic-gate#
229*7c478bd9Sstevel@tonic-gate#	PROTO1 is the first proto area searched and is typically set
230*7c478bd9Sstevel@tonic-gate#	to a proto area associated with the workspace.  The ROOT
231*7c478bd9Sstevel@tonic-gate#	environment variable is set to the same as PROTO1.  If you
232*7c478bd9Sstevel@tonic-gate#	will be doing make installs this proto area needs to be writable.
233*7c478bd9Sstevel@tonic-gate#
234*7c478bd9Sstevel@tonic-gate#	PROTO2 and PROTO3 are set to proto areas to search before the
235*7c478bd9Sstevel@tonic-gate#	search proceeds to the local machine or the proto area specified by
236*7c478bd9Sstevel@tonic-gate#	TERMPROTO.
237*7c478bd9Sstevel@tonic-gate#
238*7c478bd9Sstevel@tonic-gate#	TERMPROTO (if specified) is the last place searched.  If
239*7c478bd9Sstevel@tonic-gate#	TERMPROTO is not specified the search will end at the local
240*7c478bd9Sstevel@tonic-gate#	machine.
241*7c478bd9Sstevel@tonic-gate#
242*7c478bd9Sstevel@tonic-gate
243*7c478bd9Sstevel@tonic-gatePROTO1=\$CODEMGR_WS/proto
244*7c478bd9Sstevel@tonic-gate
245*7c478bd9Sstevel@tonic-gateif [ -f "\$CODEMGR_WS/Codemgr_wsdata/parent" ]; then
246*7c478bd9Sstevel@tonic-gate   #
247*7c478bd9Sstevel@tonic-gate   # If this workspace has an codemgr parent then set PROTO2 to
248*7c478bd9Sstevel@tonic-gate   # point to the parents proto space.
249*7c478bd9Sstevel@tonic-gate   #
250*7c478bd9Sstevel@tonic-gate   parent=\`workspace parent \$CODEMGR_WS\`
251*7c478bd9Sstevel@tonic-gate   if [ -n \$parent ]; then
252*7c478bd9Sstevel@tonic-gate	   PROTO2=\$parent/proto
253*7c478bd9Sstevel@tonic-gate   fi
254*7c478bd9Sstevel@tonic-gatefi
255*7c478bd9Sstevel@tonic-gatePROTOFILE_EoF
256*7c478bd9Sstevel@tonic-gate
257*7c478bd9Sstevel@tonic-gatefi
258*7c478bd9Sstevel@tonic-gate
259*7c478bd9Sstevel@tonic-gate. $protofile
260*7c478bd9Sstevel@tonic-gate
261*7c478bd9Sstevel@tonic-gate# This means you don't have to type make -e all of the time
262*7c478bd9Sstevel@tonic-gate
263*7c478bd9Sstevel@tonic-gateMAKEFLAGS=e; export MAKEFLAGS
264*7c478bd9Sstevel@tonic-gate
265*7c478bd9Sstevel@tonic-gate#
266*7c478bd9Sstevel@tonic-gate#	Set up the environment variables
267*7c478bd9Sstevel@tonic-gate#
268*7c478bd9Sstevel@tonic-gateMACH=`uname -p`
269*7c478bd9Sstevel@tonic-gateROOT=/proto/root_${MACH}	# default
270*7c478bd9Sstevel@tonic-gate
271*7c478bd9Sstevel@tonic-gate
272*7c478bd9Sstevel@tonic-gateENVCPPFLAGS1=
273*7c478bd9Sstevel@tonic-gateENVCPPFLAGS2=
274*7c478bd9Sstevel@tonic-gateENVCPPFLAGS3=
275*7c478bd9Sstevel@tonic-gateENVCPPFLAGS4=
276*7c478bd9Sstevel@tonic-gateENVLDLIBS1=
277*7c478bd9Sstevel@tonic-gateENVLDLIBS2=
278*7c478bd9Sstevel@tonic-gateENVLDLIBS3=
279*7c478bd9Sstevel@tonic-gate
280*7c478bd9Sstevel@tonic-gateif [ "$PROTO1" != "" ]; then	# first proto area specifed
281*7c478bd9Sstevel@tonic-gate	PROTO1=`check_proto $PROTO1`
282*7c478bd9Sstevel@tonic-gate	ROOT=$PROTO1
283*7c478bd9Sstevel@tonic-gate	ENVCPPFLAGS1=-I$ROOT/usr/include
284*7c478bd9Sstevel@tonic-gate	export ENVCPPFLAGS1
285*7c478bd9Sstevel@tonic-gate	ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
286*7c478bd9Sstevel@tonic-gate	export ENVLDLIBS1
287*7c478bd9Sstevel@tonic-gate
288*7c478bd9Sstevel@tonic-gate	if [ "$PROTO2" != "" ]; then	# second proto area specifed
289*7c478bd9Sstevel@tonic-gate		PROTO2=`check_proto $PROTO2`
290*7c478bd9Sstevel@tonic-gate		ENVCPPFLAGS2=-I$PROTO2/usr/include
291*7c478bd9Sstevel@tonic-gate		export ENVCPPFLAGS2
292*7c478bd9Sstevel@tonic-gate		ENVLDLIBS2="-L$PROTO2/lib -L$PROTO2/usr/lib"
293*7c478bd9Sstevel@tonic-gate		export ENVLDLIBS2
294*7c478bd9Sstevel@tonic-gate
295*7c478bd9Sstevel@tonic-gate		if [ "$PROTO3" != "" ]; then	# third proto area specifed
296*7c478bd9Sstevel@tonic-gate			PROTO3=`check_proto $PROTO3`
297*7c478bd9Sstevel@tonic-gate			ENVCPPFLAGS3=-I$PROTO3/usr/include
298*7c478bd9Sstevel@tonic-gate			export ENVCPPFLAGS3
299*7c478bd9Sstevel@tonic-gate			ENVLDLIBS3="-L$PROTO3/lib -L$PROTO3/usr/lib"
300*7c478bd9Sstevel@tonic-gate			export ENVLDLIBS3
301*7c478bd9Sstevel@tonic-gate		fi
302*7c478bd9Sstevel@tonic-gate	fi
303*7c478bd9Sstevel@tonic-gatefi
304*7c478bd9Sstevel@tonic-gate
305*7c478bd9Sstevel@tonic-gateexport ROOT
306*7c478bd9Sstevel@tonic-gate
307*7c478bd9Sstevel@tonic-gateif [ "$TERMPROTO" != "" ]; then	# fallback area specifed
308*7c478bd9Sstevel@tonic-gate	TERMPROTO=`check_proto $TERMPROTO`
309*7c478bd9Sstevel@tonic-gate	ENVCPPFLAGS4="-Y I,$TERMPROTO/usr/include"
310*7c478bd9Sstevel@tonic-gate	export ENVCPPFLAGS4
311*7c478bd9Sstevel@tonic-gate	ENVLDLIBS3="$ENVLDLIBS3 -Y P,$TERMPROTO/lib:$TERMPROTO/usr/lib"
312*7c478bd9Sstevel@tonic-gate	export ENVLDLIBS3
313*7c478bd9Sstevel@tonic-gatefi
314*7c478bd9Sstevel@tonic-gate
315*7c478bd9Sstevel@tonic-gate#
316*7c478bd9Sstevel@tonic-gate# Now let's set those variables which are either 4.1.x specific
317*7c478bd9Sstevel@tonic-gate# or 5.0 specific
318*7c478bd9Sstevel@tonic-gate#
319*7c478bd9Sstevel@tonic-gateos_rev=`uname -r`
320*7c478bd9Sstevel@tonic-gateosbld_flag=0
321*7c478bd9Sstevel@tonic-gate
322*7c478bd9Sstevel@tonic-gateif [ `expr $os_rev : "4\.1"` = "3" ]; then # This is a 4.1.x machine
323*7c478bd9Sstevel@tonic-gate   #
324*7c478bd9Sstevel@tonic-gate   # Enable all of the DOUBLECROSS_ROOT components for the 4.1.x compile
325*7c478bd9Sstevel@tonic-gate   #
326*7c478bd9Sstevel@tonic-gate   DOUBLECROSS_ROOT=${DOUBLECROSS_ROOT="/crossroot"}
327*7c478bd9Sstevel@tonic-gate   PATH=$DOUBLECROSS_ROOT/usr/ccs/bin:$DOUBLECROSS_ROOT/usr/bin:$DOUBLECROSS_ROOT/usr/sbin:$PATH
328*7c478bd9Sstevel@tonic-gate   export DOUBLECROSS_ROOT PATH
329*7c478bd9Sstevel@tonic-gateelif [ `expr $os_rev : "5\."` = "2" ]; then
330*7c478bd9Sstevel@tonic-gate   #
331*7c478bd9Sstevel@tonic-gate   # Enable any 5.x specific variables here
332*7c478bd9Sstevel@tonic-gate   #
333*7c478bd9Sstevel@tonic-gate   if [ ${ONBLD_DIR:-NULL} = "NULL" ]; then
334*7c478bd9Sstevel@tonic-gate      if [ -d /opt/onbld/bin ]; then
335*7c478bd9Sstevel@tonic-gate	 ONBLD_DIR=/opt/onbld/bin
336*7c478bd9Sstevel@tonic-gate      elif [ -d /usr/onbld/bin ]; then
337*7c478bd9Sstevel@tonic-gate	 ONBLD_DIR=/usr/onbld/bin
338*7c478bd9Sstevel@tonic-gate      fi
339*7c478bd9Sstevel@tonic-gate   fi
340*7c478bd9Sstevel@tonic-gate   if [ -d ${ONBLD_DIR:-\\NULL} ] ; then
341*7c478bd9Sstevel@tonic-gate      PATH=${ONBLD_DIR}:${PATH}
342*7c478bd9Sstevel@tonic-gate      osbld_flag=1
343*7c478bd9Sstevel@tonic-gate      export PATH
344*7c478bd9Sstevel@tonic-gate   fi
345*7c478bd9Sstevel@tonic-gate   if [ "$PROTO2" != "" ]; then
346*7c478bd9Sstevel@tonic-gate      # This should point to the parent's proto
347*7c478bd9Sstevel@tonic-gate      PARENT_ROOT=$PROTO2
348*7c478bd9Sstevel@tonic-gate      export PARENT_ROOT
349*7c478bd9Sstevel@tonic-gate   else
350*7c478bd9Sstevel@tonic-gate      # Clear it in case it's already in the env.
351*7c478bd9Sstevel@tonic-gate      PARENT_ROOT=
352*7c478bd9Sstevel@tonic-gate   fi
353*7c478bd9Sstevel@tonic-gate   export ONBLD_DIR
354*7c478bd9Sstevel@tonic-gate   export MACH
355*7c478bd9Sstevel@tonic-gateelse
356*7c478bd9Sstevel@tonic-gate   #
357*7c478bd9Sstevel@tonic-gate   # This is neither a 5.x machine nor a 4.1.x machine - something is wrong
358*7c478bd9Sstevel@tonic-gate   #
359*7c478bd9Sstevel@tonic-gate   echo "***WARNING: this script is meant to be run on a 4.1.x and/or a 5.x"
360*7c478bd9Sstevel@tonic-gate   echo "            operating system.  This machine appears to be running:"
361*7c478bd9Sstevel@tonic-gate   echo "                          $os_rev "
362*7c478bd9Sstevel@tonic-gatefi
363*7c478bd9Sstevel@tonic-gate
364*7c478bd9Sstevel@tonic-gateecho ""
365*7c478bd9Sstevel@tonic-gateecho "Workspace (\$CODEMGR_WS)      : $CODEMGR_WS"
366*7c478bd9Sstevel@tonic-gateif [ -n "$parent" ]; then
367*7c478bd9Sstevel@tonic-gate   echo "Workspace Parent             : $parent"
368*7c478bd9Sstevel@tonic-gatefi
369*7c478bd9Sstevel@tonic-gateecho "Proto area (\$ROOT)           : $ROOT"
370*7c478bd9Sstevel@tonic-gateif [ -n "$PARENT_ROOT" ]; then
371*7c478bd9Sstevel@tonic-gate   echo "Parent proto area (\$PARENT_ROOT) : $PARENT_ROOT"
372*7c478bd9Sstevel@tonic-gatefi
373*7c478bd9Sstevel@tonic-gateecho "Root of source (\$SRC)        : $SRC"
374*7c478bd9Sstevel@tonic-gateecho "Root of test source (\$TSRC)  : $TSRC"
375*7c478bd9Sstevel@tonic-gateif [ $osbld_flag = "1" ]; then
376*7c478bd9Sstevel@tonic-gate   echo "Prepended to PATH            : $ONBLD_DIR"
377*7c478bd9Sstevel@tonic-gatefi
378*7c478bd9Sstevel@tonic-gateecho "Current directory (\$PWD)     : $CODEMGR_WS"
379*7c478bd9Sstevel@tonic-gateecho ""
380*7c478bd9Sstevel@tonic-gate
381*7c478bd9Sstevel@tonic-gatecd $CODEMGR_WS
382*7c478bd9Sstevel@tonic-gate
383*7c478bd9Sstevel@tonic-gateif $setenv; then
384*7c478bd9Sstevel@tonic-gate	cleanup_env
385*7c478bd9Sstevel@tonic-gateelse
386*7c478bd9Sstevel@tonic-gate	exec ${SHELL:-sh} "$@"
387*7c478bd9Sstevel@tonic-gatefi
388