xref: /titanic_41/usr/src/tools/scripts/ws.sh (revision cdf0c1d55d9b3b6beaf994835440dfb01aef5cf0)
1*cdf0c1d5Smjnelson#!/bin/ksh -p
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*cdf0c1d5Smjnelson# Common Development and Distribution License (the "License").
7*cdf0c1d5Smjnelson# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
23*cdf0c1d5Smjnelson# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate# Use is subject to license terms.
257c478bd9Sstevel@tonic-gate#
267c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate#
287c478bd9Sstevel@tonic-gate#	This script sets up the environment variables for a SunOS
297c478bd9Sstevel@tonic-gate#	codemgr workspace and spawns a shell with the environment
307c478bd9Sstevel@tonic-gate#	setup.
317c478bd9Sstevel@tonic-gate#
327c478bd9Sstevel@tonic-gate#	The following Environment variables are set:
337c478bd9Sstevel@tonic-gate#		CODEMGR_WS
347c478bd9Sstevel@tonic-gate#		ONBLD_DIR
357c478bd9Sstevel@tonic-gate#		SRC
367c478bd9Sstevel@tonic-gate#		TSRC
377c478bd9Sstevel@tonic-gate#		ROOT
387c478bd9Sstevel@tonic-gate#		PARENT_ROOT
397c478bd9Sstevel@tonic-gate#		MACH
407c478bd9Sstevel@tonic-gate#		MAKEFLAGS
417c478bd9Sstevel@tonic-gate#		ENVCPPFLAGS{1-4}
427c478bd9Sstevel@tonic-gate#		ENVLDLIBS{1-3}
437c478bd9Sstevel@tonic-gate#
447c478bd9Sstevel@tonic-gate#	The MAKEFLAGS environment variable is set to force make
457c478bd9Sstevel@tonic-gate#	to read default make variables from the environment.
467c478bd9Sstevel@tonic-gate#
477c478bd9Sstevel@tonic-gate#	Workspace names can be specified in two forms: pathname
487c478bd9Sstevel@tonic-gate#	and hostname:pathname.  If the hostname:pathname form is used
497c478bd9Sstevel@tonic-gate#	the script accesses the environment through the /net automounter
507c478bd9Sstevel@tonic-gate#	map.
517c478bd9Sstevel@tonic-gate#
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gate#
547c478bd9Sstevel@tonic-gate# function to produce a pathname from a workspace name or subdirectory.
557c478bd9Sstevel@tonic-gate# The workspace name can have hostname:pathname format.
567c478bd9Sstevel@tonic-gate#
577c478bd9Sstevel@tonic-gate
58*cdf0c1d5Smjnelsonfmtwsname()
59*cdf0c1d5Smjnelson{
607c478bd9Sstevel@tonic-gate	awk -F: '$1 != $0 { print "/net/"$1$2 } \
617c478bd9Sstevel@tonic-gate		 $1 == $0 { print $0 }'
627c478bd9Sstevel@tonic-gate}
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate#
65*cdf0c1d5Smjnelson# Return a valid proto area, if one exists.
667c478bd9Sstevel@tonic-gate#
677c478bd9Sstevel@tonic-gatecheck_proto()
687c478bd9Sstevel@tonic-gate{
69*cdf0c1d5Smjnelson	if [[ -z $1 ]]; then
70*cdf0c1d5Smjnelson		return
71*cdf0c1d5Smjnelson	fi
72*cdf0c1d5Smjnelson
73*cdf0c1d5Smjnelson	if [ "$SCM_MODE" = "teamware" ]; then
747c478bd9Sstevel@tonic-gate		# Check for problematic parent specification and adjust
757c478bd9Sstevel@tonic-gate		proto=`echo $1|fmtwsname`
767c478bd9Sstevel@tonic-gate		echo "${proto}/root_${MACH}"
77*cdf0c1d5Smjnelson	elif [ "$SCM_MODE" = "mercurial" ]; then
78*cdf0c1d5Smjnelson		proto=$1
79*cdf0c1d5Smjnelson		#
80*cdf0c1d5Smjnelson		# If the proto is a local repository then we can use it
81*cdf0c1d5Smjnelson		# to point to the parents proto area. Don't bother to
82*cdf0c1d5Smjnelson		# check if it exists or not, we never did for Teamware,
83*cdf0c1d5Smjnelson		# since it might appear later anyway.
84*cdf0c1d5Smjnelson		#
85*cdf0c1d5Smjnelson		if [ "${proto##ssh://}" == "$proto" -a \
86*cdf0c1d5Smjnelson		     "${proto##http://}" == "$proto" -a \
87*cdf0c1d5Smjnelson		     "${proto##https://}" == "$proto" ]; then
88*cdf0c1d5Smjnelson			echo "${proto}/root_${MACH}"
89*cdf0c1d5Smjnelson		fi
907c478bd9Sstevel@tonic-gate	fi
917c478bd9Sstevel@tonic-gate}
927c478bd9Sstevel@tonic-gate
937c478bd9Sstevel@tonic-gatecleanup_env()
947c478bd9Sstevel@tonic-gate{
957c478bd9Sstevel@tonic-gate	# keep the env. clean when returning
967c478bd9Sstevel@tonic-gate	unset setenv osbld_flag os_rev wsosdir protofile wsname ofs proto \
977c478bd9Sstevel@tonic-gate		pwd parent PROTO1 PROTO2 PROTO3 tmpwsname
987c478bd9Sstevel@tonic-gate	return 0
997c478bd9Sstevel@tonic-gate}
1007c478bd9Sstevel@tonic-gate
1017c478bd9Sstevel@tonic-gateif [ "$1" = "-e" ]; then
1027c478bd9Sstevel@tonic-gate	setenv=true
1037c478bd9Sstevel@tonic-gate	shift
1047c478bd9Sstevel@tonic-gateelse
1057c478bd9Sstevel@tonic-gate	setenv=false
1067c478bd9Sstevel@tonic-gatefi
1077c478bd9Sstevel@tonic-gate
108*cdf0c1d5SmjnelsonWHICH_SCM=$(dirname $(whence $0))/which_scm
1097c478bd9Sstevel@tonic-gate
110*cdf0c1d5Smjnelson#
111*cdf0c1d5Smjnelson# No workspace/repository path was given, so try and detect one from our
112*cdf0c1d5Smjnelson# current directory we're in
113*cdf0c1d5Smjnelson#
1147c478bd9Sstevel@tonic-gateif [ $# -lt 1 ]; then
115*cdf0c1d5Smjnelson	if $WHICH_SCM | read SCM_MODE tmpwsname && \
116*cdf0c1d5Smjnelson	    [[ $SCM_MODE != unknown ]]; then
117*cdf0c1d5Smjnelson		echo "Defaulting to $SCM_MODE repository $tmpwsname"
118*cdf0c1d5Smjnelson	else
1197c478bd9Sstevel@tonic-gate		echo "usage: ws [-e] [workspace_name]" >&2
1207c478bd9Sstevel@tonic-gate		if $setenv; then
1217c478bd9Sstevel@tonic-gate			cleanup_env
1227c478bd9Sstevel@tonic-gate			return 1
1237c478bd9Sstevel@tonic-gate		else
1247c478bd9Sstevel@tonic-gate			exit 1
1257c478bd9Sstevel@tonic-gate		fi
1267c478bd9Sstevel@tonic-gate	fi
127*cdf0c1d5Smjnelsonelse
128*cdf0c1d5Smjnelson	#
129*cdf0c1d5Smjnelson	# A workspace/repository path was passed in, grab it and pop
130*cdf0c1d5Smjnelson	# it off the stack
131*cdf0c1d5Smjnelson	#
132*cdf0c1d5Smjnelson	tmpwsname=$1
133*cdf0c1d5Smjnelson	shift
134*cdf0c1d5Smjnelsonfi
1357c478bd9Sstevel@tonic-gate
1367c478bd9Sstevel@tonic-gate#
1377c478bd9Sstevel@tonic-gate#	This variable displays the nested activations of workspaces.
1387c478bd9Sstevel@tonic-gate#	This is done here to get the exact name the user entered.
1397c478bd9Sstevel@tonic-gate#
140*cdf0c1d5SmjnelsonWS_STACK="$tmpwsname $WS_STACK"; export WS_STACK
1417c478bd9Sstevel@tonic-gate
142*cdf0c1d5Smjnelson#
143*cdf0c1d5Smjnelson# Set the workspace name and unset tmpwsname (as we reuse it later)
144*cdf0c1d5Smjnelson#
145*cdf0c1d5Smjnelsonwsname=`echo $tmpwsname|fmtwsname`
146*cdf0c1d5Smjnelsonunset tmpwsname
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gate#
1497c478bd9Sstevel@tonic-gate# Checking for CODEMGR_WSPATH
1507c478bd9Sstevel@tonic-gate#
1517c478bd9Sstevel@tonic-gateif [ "(" "${CODEMGR_WSPATH}x" != "x" ")" -a "(" ! -d $wsname ")" -a \
1527c478bd9Sstevel@tonic-gate     "(" `expr "$wsname" : "\/"` = "0" ")" ]
1537c478bd9Sstevel@tonic-gatethen
1547c478bd9Sstevel@tonic-gate	ofs=$IFS
1557c478bd9Sstevel@tonic-gate	IFS=": 	"
1567c478bd9Sstevel@tonic-gate	for i in $CODEMGR_WSPATH
1577c478bd9Sstevel@tonic-gate	do
1587c478bd9Sstevel@tonic-gate		if [ -d ${i}/${wsname} ]; then
1597c478bd9Sstevel@tonic-gate			wsname=${i}/${wsname}
1607c478bd9Sstevel@tonic-gate			break
1617c478bd9Sstevel@tonic-gate		fi
1627c478bd9Sstevel@tonic-gate	done
1637c478bd9Sstevel@tonic-gate	IFS=$ofs
1647c478bd9Sstevel@tonic-gatefi
1657c478bd9Sstevel@tonic-gate
166*cdf0c1d5Smjnelson#
1677c478bd9Sstevel@tonic-gate# to translate it to an absolute pathname.  We need an
1687c478bd9Sstevel@tonic-gate# absolute pathname in order to set CODEMGR_WS.
1697c478bd9Sstevel@tonic-gate#
1707c478bd9Sstevel@tonic-gateif [ `expr "$wsname" : "\/"` = "0" ]
1717c478bd9Sstevel@tonic-gatethen
1727c478bd9Sstevel@tonic-gate	pwd=`pwd`
1737c478bd9Sstevel@tonic-gate	wsname="$pwd/$wsname"
1747c478bd9Sstevel@tonic-gatefi
1757c478bd9Sstevel@tonic-gate
1767c478bd9Sstevel@tonic-gate#
1777c478bd9Sstevel@tonic-gate#	Check to see if this is a valid workspace
1787c478bd9Sstevel@tonic-gate#
1797c478bd9Sstevel@tonic-gateif [ ! -d $wsname ]; then
1807c478bd9Sstevel@tonic-gate	echo "$wsname . . . no such directory" >&2
1817c478bd9Sstevel@tonic-gate	if $setenv; then
1827c478bd9Sstevel@tonic-gate		cleanup_env
1837c478bd9Sstevel@tonic-gate		return 1
1847c478bd9Sstevel@tonic-gate	else
1857c478bd9Sstevel@tonic-gate		exit 1
1867c478bd9Sstevel@tonic-gate	fi
1877c478bd9Sstevel@tonic-gatefi
188*cdf0c1d5Smjnelson
189*cdf0c1d5Smjnelson#
190*cdf0c1d5Smjnelson# This catches the case of a passed in workspace path
191*cdf0c1d5Smjnelson# Check which type of SCM is in use by $wsname.
192*cdf0c1d5Smjnelson#
193*cdf0c1d5Smjnelson(cd $wsname && $WHICH_SCM) | read SCM_MODE tmpwsname
194*cdf0c1d5Smjnelsonif [[ $? != 0 || "$SCM_MODE" == unknown ]]; then
195*cdf0c1d5Smjnelson	echo "Error: Unable to detect a supported SCM repository in $wsname"
1967c478bd9Sstevel@tonic-gate	if $setenv; then
1977c478bd9Sstevel@tonic-gate		cleanup_env
1987c478bd9Sstevel@tonic-gate		return 1
1997c478bd9Sstevel@tonic-gate	else
2007c478bd9Sstevel@tonic-gate		exit 1
2017c478bd9Sstevel@tonic-gate	fi
2027c478bd9Sstevel@tonic-gatefi
2037c478bd9Sstevel@tonic-gate
204*cdf0c1d5Smjnelsonwsname=$tmpwsname
2057c478bd9Sstevel@tonic-gateCODEMGR_WS=$wsname ; export CODEMGR_WS
206*cdf0c1d5SmjnelsonSRC=$wsname/usr/src; export SRC
207*cdf0c1d5SmjnelsonTSRC=$wsname/usr/ontest; export TSRC
2087c478bd9Sstevel@tonic-gate
209*cdf0c1d5Smjnelsonif [ "$SCM_MODE" = "teamware" -a -d ${wsname}/Codemgr_wsdata ]; then
210*cdf0c1d5Smjnelson	CM_DATA="Codemgr_wsdata"
2117c478bd9Sstevel@tonic-gate	wsosdir=$CODEMGR_WS/$CM_DATA/sunos
2127c478bd9Sstevel@tonic-gate	protofile=$wsosdir/protodefs
213*cdf0c1d5Smjnelsonelif [ "$SCM_MODE" = "mercurial" -a -d ${wsname}/.hg ]; then
214*cdf0c1d5Smjnelson	CM_DATA=".hg"
215*cdf0c1d5Smjnelson	wsosdir=$CODEMGR_WS/$CM_DATA
216*cdf0c1d5Smjnelson	protofile=$wsosdir/org.opensolaris.protodefs
217*cdf0c1d5Smjnelsonelse
218*cdf0c1d5Smjnelson	echo "$wsname is not a supported workspace; type is $SCM_MODE" >&2
219*cdf0c1d5Smjnelson	if $setenv; then
220*cdf0c1d5Smjnelson		cleanup_env
221*cdf0c1d5Smjnelson		return 1
222*cdf0c1d5Smjnelson	else
223*cdf0c1d5Smjnelson		exit 1
224*cdf0c1d5Smjnelson	fi
225*cdf0c1d5Smjnelsonfi
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gateif [ ! -f $protofile ]; then
2287c478bd9Sstevel@tonic-gate	if [ ! -w $CODEMGR_WS/$CM_DATA ]; then
2297c478bd9Sstevel@tonic-gate		#
2307c478bd9Sstevel@tonic-gate		# The workspace doesn't have a protodefs file and I am
2317c478bd9Sstevel@tonic-gate		# unable to create one.  Tell user and use /tmp instead.
2327c478bd9Sstevel@tonic-gate		#
2337c478bd9Sstevel@tonic-gate		echo "Unable to create the proto defaults file ($protofile)."
2347c478bd9Sstevel@tonic-gate
2357c478bd9Sstevel@tonic-gate		# Just make one in /tmp
2367c478bd9Sstevel@tonic-gate		wsosdir=/tmp
2377c478bd9Sstevel@tonic-gate		protofile=$wsosdir/protodefs
2387c478bd9Sstevel@tonic-gate	fi
2397c478bd9Sstevel@tonic-gate
2407c478bd9Sstevel@tonic-gate	if [ ! -d $wsosdir ]; then
2417c478bd9Sstevel@tonic-gate		mkdir $wsosdir
2427c478bd9Sstevel@tonic-gate	fi
2437c478bd9Sstevel@tonic-gate
2447c478bd9Sstevel@tonic-gate	cat << PROTOFILE_EoF > $protofile
2457c478bd9Sstevel@tonic-gate#!/bin/sh
2467c478bd9Sstevel@tonic-gate#
2477c478bd9Sstevel@tonic-gate#	Set default proto areas for this workspace
2487c478bd9Sstevel@tonic-gate#	NOTE: This file was initially automatically generated.
2497c478bd9Sstevel@tonic-gate#
2507c478bd9Sstevel@tonic-gate#	Feel free to edit this file.  If this file is removed
2517c478bd9Sstevel@tonic-gate#	it will be rebuilt containing default values.
2527c478bd9Sstevel@tonic-gate#
2537c478bd9Sstevel@tonic-gate#	The variable CODEMGR_WS is available to this script.
2547c478bd9Sstevel@tonic-gate#
2557c478bd9Sstevel@tonic-gate#	PROTO1 is the first proto area searched and is typically set
2567c478bd9Sstevel@tonic-gate#	to a proto area associated with the workspace.  The ROOT
2577c478bd9Sstevel@tonic-gate#	environment variable is set to the same as PROTO1.  If you
2587c478bd9Sstevel@tonic-gate#	will be doing make installs this proto area needs to be writable.
2597c478bd9Sstevel@tonic-gate#
2607c478bd9Sstevel@tonic-gate#	PROTO2 and PROTO3 are set to proto areas to search before the
2617c478bd9Sstevel@tonic-gate#	search proceeds to the local machine or the proto area specified by
2627c478bd9Sstevel@tonic-gate#	TERMPROTO.
2637c478bd9Sstevel@tonic-gate#
2647c478bd9Sstevel@tonic-gate#	TERMPROTO (if specified) is the last place searched.  If
2657c478bd9Sstevel@tonic-gate#	TERMPROTO is not specified the search will end at the local
2667c478bd9Sstevel@tonic-gate#	machine.
2677c478bd9Sstevel@tonic-gate#
2687c478bd9Sstevel@tonic-gate
2697c478bd9Sstevel@tonic-gatePROTO1=\$CODEMGR_WS/proto
270*cdf0c1d5SmjnelsonPROTOFILE_EoF
2717c478bd9Sstevel@tonic-gate
272*cdf0c1d5Smjnelson	if [ "$SCM_MODE" = "teamware" ]; then
273*cdf0c1d5Smjnelson		cat << PROTOFILE_EoF >> $protofile
2747c478bd9Sstevel@tonic-gateif [ -f "\$CODEMGR_WS/Codemgr_wsdata/parent" ]; then
2757c478bd9Sstevel@tonic-gate   #
2767c478bd9Sstevel@tonic-gate   # If this workspace has an codemgr parent then set PROTO2 to
2777c478bd9Sstevel@tonic-gate   # point to the parents proto space.
2787c478bd9Sstevel@tonic-gate   #
2797c478bd9Sstevel@tonic-gate   parent=\`workspace parent \$CODEMGR_WS\`
280*cdf0c1d5Smjnelson   if [[ -n \$parent ]]; then
2817c478bd9Sstevel@tonic-gate	   PROTO2=\$parent/proto
2827c478bd9Sstevel@tonic-gate   fi
2837c478bd9Sstevel@tonic-gatefi
2847c478bd9Sstevel@tonic-gatePROTOFILE_EoF
285*cdf0c1d5Smjnelson	elif [ "$SCM_MODE" = "mercurial" ]; then
286*cdf0c1d5Smjnelson		cat << PROTOFILE_EoF >> $protofile
287*cdf0c1d5Smjnelsonparent=\`(cd \$CODEMGR_WS && hg path default 2>/dev/null)\`
288*cdf0c1d5Smjnelsonif [[ \$? -eq 0 && -n \$parent ]]; then
289*cdf0c1d5Smjnelson   PROTO2=\$(check_proto \$parent/proto)
290*cdf0c1d5Smjnelsonfi
291*cdf0c1d5SmjnelsonPROTOFILE_EoF
292*cdf0c1d5Smjnelson	fi
2937c478bd9Sstevel@tonic-gatefi
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gate. $protofile
2967c478bd9Sstevel@tonic-gate
2977c478bd9Sstevel@tonic-gate# This means you don't have to type make -e all of the time
2987c478bd9Sstevel@tonic-gate
2997c478bd9Sstevel@tonic-gateMAKEFLAGS=e; export MAKEFLAGS
3007c478bd9Sstevel@tonic-gate
3017c478bd9Sstevel@tonic-gate#
3027c478bd9Sstevel@tonic-gate#	Set up the environment variables
3037c478bd9Sstevel@tonic-gate#
3047c478bd9Sstevel@tonic-gateMACH=`uname -p`
3057c478bd9Sstevel@tonic-gateROOT=/proto/root_${MACH}	# default
3067c478bd9Sstevel@tonic-gate
3077c478bd9Sstevel@tonic-gateENVCPPFLAGS1=
3087c478bd9Sstevel@tonic-gateENVCPPFLAGS2=
3097c478bd9Sstevel@tonic-gateENVCPPFLAGS3=
3107c478bd9Sstevel@tonic-gateENVCPPFLAGS4=
3117c478bd9Sstevel@tonic-gateENVLDLIBS1=
3127c478bd9Sstevel@tonic-gateENVLDLIBS2=
3137c478bd9Sstevel@tonic-gateENVLDLIBS3=
3147c478bd9Sstevel@tonic-gate
3157c478bd9Sstevel@tonic-gatePROTO1=`check_proto $PROTO1`
316*cdf0c1d5Smjnelsonif [[ -n "$PROTO1" ]]; then	# first proto area specifed
3177c478bd9Sstevel@tonic-gate	ROOT=$PROTO1
3187c478bd9Sstevel@tonic-gate	ENVCPPFLAGS1=-I$ROOT/usr/include
3197c478bd9Sstevel@tonic-gate	export ENVCPPFLAGS1
3207c478bd9Sstevel@tonic-gate	ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
3217c478bd9Sstevel@tonic-gate	export ENVLDLIBS1
3227c478bd9Sstevel@tonic-gate
3237c478bd9Sstevel@tonic-gate	PROTO2=`check_proto $PROTO2`
324*cdf0c1d5Smjnelson	if [[ -n "$PROTO2" ]]; then	# second proto area specifed
3257c478bd9Sstevel@tonic-gate		ENVCPPFLAGS2=-I$PROTO2/usr/include
3267c478bd9Sstevel@tonic-gate		export ENVCPPFLAGS2
3277c478bd9Sstevel@tonic-gate		ENVLDLIBS2="-L$PROTO2/lib -L$PROTO2/usr/lib"
3287c478bd9Sstevel@tonic-gate		export ENVLDLIBS2
3297c478bd9Sstevel@tonic-gate
330*cdf0c1d5Smjnelson		PROTO3=`check_proto $PROTO3`
331*cdf0c1d5Smjnelson		if [[ -n "$PROTO3" ]]; then	# third proto area specifed
3327c478bd9Sstevel@tonic-gate			PROTO3=`check_proto $PROTO3`
3337c478bd9Sstevel@tonic-gate			ENVCPPFLAGS3=-I$PROTO3/usr/include
3347c478bd9Sstevel@tonic-gate			export ENVCPPFLAGS3
3357c478bd9Sstevel@tonic-gate			ENVLDLIBS3="-L$PROTO3/lib -L$PROTO3/usr/lib"
3367c478bd9Sstevel@tonic-gate			export ENVLDLIBS3
3377c478bd9Sstevel@tonic-gate		fi
3387c478bd9Sstevel@tonic-gate	fi
3397c478bd9Sstevel@tonic-gatefi
3407c478bd9Sstevel@tonic-gate
3417c478bd9Sstevel@tonic-gateexport ROOT
3427c478bd9Sstevel@tonic-gate
343*cdf0c1d5Smjnelsonif [[ -n "$TERMPROTO" ]]; then	# fallback area specifed
3447c478bd9Sstevel@tonic-gate	TERMPROTO=`check_proto $TERMPROTO`
3457c478bd9Sstevel@tonic-gate	ENVCPPFLAGS4="-Y I,$TERMPROTO/usr/include"
3467c478bd9Sstevel@tonic-gate	export ENVCPPFLAGS4
3477c478bd9Sstevel@tonic-gate	ENVLDLIBS3="$ENVLDLIBS3 -Y P,$TERMPROTO/lib:$TERMPROTO/usr/lib"
3487c478bd9Sstevel@tonic-gate	export ENVLDLIBS3
3497c478bd9Sstevel@tonic-gatefi
3507c478bd9Sstevel@tonic-gate
3517c478bd9Sstevel@tonic-gateosbld_flag=0
3527c478bd9Sstevel@tonic-gate
353*cdf0c1d5Smjnelsonif [[ -z "$ONBLD_DIR" ]]; then
354*cdf0c1d5Smjnelson	ONBLD_DIR=$(dirname $(whence $0))
3557c478bd9Sstevel@tonic-gatefi
356*cdf0c1d5Smjnelson
357*cdf0c1d5Smjnelsonif ! echo ":$PATH:" | grep ":${ONBLD_DIR}:" > /dev/null; then
358*cdf0c1d5Smjnelson	PATH="${ONBLD_DIR}:${ONBLD_DIR}/${MACH}:${PATH}"
3597c478bd9Sstevel@tonic-gate	osbld_flag=1
3607c478bd9Sstevel@tonic-gatefi
361*cdf0c1d5Smjnelson
362*cdf0c1d5Smjnelsonexport PATH
363*cdf0c1d5Smjnelson
364*cdf0c1d5Smjnelsonif [[ -n "$PROTO2" ]]; then
3657c478bd9Sstevel@tonic-gate   # This should point to the parent's proto
3667c478bd9Sstevel@tonic-gate   PARENT_ROOT=$PROTO2
3677c478bd9Sstevel@tonic-gate   export PARENT_ROOT
3687c478bd9Sstevel@tonic-gateelse
3697c478bd9Sstevel@tonic-gate   # Clear it in case it's already in the env.
3707c478bd9Sstevel@tonic-gate   PARENT_ROOT=
3717c478bd9Sstevel@tonic-gatefi
3727c478bd9Sstevel@tonic-gateexport ONBLD_DIR
3737c478bd9Sstevel@tonic-gateexport MACH
374*cdf0c1d5Smjnelson
375*cdf0c1d5Smjnelsonos_rev=`uname -r`
376*cdf0c1d5Smjnelsonos_name=`uname -s`
377*cdf0c1d5Smjnelson
378*cdf0c1d5Smjnelsonif [[ $os_name != "SunOS" || `expr $os_rev : "5\."` != "2" ]]; then
3797c478bd9Sstevel@tonic-gate   #
380*cdf0c1d5Smjnelson   # This is not a SunOS 5.x machine - something is wrong
3817c478bd9Sstevel@tonic-gate   #
382*cdf0c1d5Smjnelson   echo "***WARNING: this script is meant to be run on SunOS 5.x."
383*cdf0c1d5Smjnelson   echo "            This machine appears to be running: $os_name $os_rev"
3847c478bd9Sstevel@tonic-gatefi
3857c478bd9Sstevel@tonic-gate
3867c478bd9Sstevel@tonic-gateecho ""
387*cdf0c1d5Smjnelsonecho "Workspace                    : $wsname"
3887c478bd9Sstevel@tonic-gateif [ -n "$parent" ]; then
3897c478bd9Sstevel@tonic-gate   echo "Workspace Parent             : $parent"
3907c478bd9Sstevel@tonic-gatefi
3917c478bd9Sstevel@tonic-gateecho "Proto area (\$ROOT)           : $ROOT"
3927c478bd9Sstevel@tonic-gateif [ -n "$PARENT_ROOT" ]; then
3937c478bd9Sstevel@tonic-gate   echo "Parent proto area (\$PARENT_ROOT) : $PARENT_ROOT"
3947c478bd9Sstevel@tonic-gatefi
3957c478bd9Sstevel@tonic-gateecho "Root of source (\$SRC)        : $SRC"
3967c478bd9Sstevel@tonic-gateecho "Root of test source (\$TSRC)  : $TSRC"
3977c478bd9Sstevel@tonic-gateif [ $osbld_flag = "1" ]; then
3987c478bd9Sstevel@tonic-gate   echo "Prepended to PATH            : $ONBLD_DIR"
3997c478bd9Sstevel@tonic-gatefi
400*cdf0c1d5Smjnelsonecho "Current directory (\$PWD)     : $wsname"
4017c478bd9Sstevel@tonic-gateecho ""
4027c478bd9Sstevel@tonic-gate
403*cdf0c1d5Smjnelsoncd $wsname
4047c478bd9Sstevel@tonic-gate
4057c478bd9Sstevel@tonic-gateif $setenv; then
4067c478bd9Sstevel@tonic-gate	cleanup_env
4077c478bd9Sstevel@tonic-gateelse
4087c478bd9Sstevel@tonic-gate	exec ${SHELL:-sh} "$@"
4097c478bd9Sstevel@tonic-gatefi
410