xref: /titanic_41/usr/src/tools/scripts/ws.sh (revision 1fb95e48b0ed76e2ce9a37cb14d82c1ad8e941f6)
1cdf0c1d5Smjnelson#!/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
6cdf0c1d5Smjnelson# Common Development and Distribution License (the "License").
7cdf0c1d5Smjnelson# 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#
23cdf0c1d5Smjnelson# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate# Use is subject to license terms.
257c478bd9Sstevel@tonic-gate#
26*1fb95e48SDan McDonald# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
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
58cdf0c1d5Smjnelsonfmtwsname()
59cdf0c1d5Smjnelson{
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#
65cdf0c1d5Smjnelson# Return a valid proto area, if one exists.
667c478bd9Sstevel@tonic-gate#
677c478bd9Sstevel@tonic-gatecheck_proto()
687c478bd9Sstevel@tonic-gate{
69cdf0c1d5Smjnelson	if [[ -z $1 ]]; then
70cdf0c1d5Smjnelson		return
71cdf0c1d5Smjnelson	fi
72cdf0c1d5Smjnelson
73cdf0c1d5Smjnelson	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}"
77cdf0c1d5Smjnelson	elif [ "$SCM_MODE" = "mercurial" ]; then
78cdf0c1d5Smjnelson		proto=$1
79cdf0c1d5Smjnelson		#
80cdf0c1d5Smjnelson		# If the proto is a local repository then we can use it
81cdf0c1d5Smjnelson		# to point to the parents proto area. Don't bother to
82cdf0c1d5Smjnelson		# check if it exists or not, we never did for Teamware,
83cdf0c1d5Smjnelson		# since it might appear later anyway.
84cdf0c1d5Smjnelson		#
85cdf0c1d5Smjnelson		if [ "${proto##ssh://}" == "$proto" -a \
86cdf0c1d5Smjnelson		     "${proto##http://}" == "$proto" -a \
87cdf0c1d5Smjnelson		     "${proto##https://}" == "$proto" ]; then
88cdf0c1d5Smjnelson			echo "${proto}/root_${MACH}"
89cdf0c1d5Smjnelson		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
108cdf0c1d5SmjnelsonWHICH_SCM=$(dirname $(whence $0))/which_scm
109916d673dSmjnelsonif [[ ! -x $WHICH_SCM ]]; then
110916d673dSmjnelson	WHICH_SCM=which_scm
111916d673dSmjnelsonfi
1127c478bd9Sstevel@tonic-gate
113cdf0c1d5Smjnelson#
114cdf0c1d5Smjnelson# No workspace/repository path was given, so try and detect one from our
115cdf0c1d5Smjnelson# current directory we're in
116cdf0c1d5Smjnelson#
1177c478bd9Sstevel@tonic-gateif [ $# -lt 1 ]; then
118f7e41c80Smjnelson	if env CODEMGR_WS="" $WHICH_SCM | read SCM_MODE tmpwsname && \
119cdf0c1d5Smjnelson	    [[ $SCM_MODE != unknown ]]; then
120cdf0c1d5Smjnelson		echo "Defaulting to $SCM_MODE repository $tmpwsname"
121cdf0c1d5Smjnelson	else
1227c478bd9Sstevel@tonic-gate		echo "usage: ws [-e] [workspace_name]" >&2
1237c478bd9Sstevel@tonic-gate		if $setenv; then
1247c478bd9Sstevel@tonic-gate			cleanup_env
1257c478bd9Sstevel@tonic-gate			return 1
1267c478bd9Sstevel@tonic-gate		else
1277c478bd9Sstevel@tonic-gate			exit 1
1287c478bd9Sstevel@tonic-gate		fi
1297c478bd9Sstevel@tonic-gate	fi
130cdf0c1d5Smjnelsonelse
131cdf0c1d5Smjnelson	#
132cdf0c1d5Smjnelson	# A workspace/repository path was passed in, grab it and pop
133cdf0c1d5Smjnelson	# it off the stack
134cdf0c1d5Smjnelson	#
135cdf0c1d5Smjnelson	tmpwsname=$1
136cdf0c1d5Smjnelson	shift
137cdf0c1d5Smjnelsonfi
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate#
1407c478bd9Sstevel@tonic-gate#	This variable displays the nested activations of workspaces.
1417c478bd9Sstevel@tonic-gate#	This is done here to get the exact name the user entered.
1427c478bd9Sstevel@tonic-gate#
143cdf0c1d5SmjnelsonWS_STACK="$tmpwsname $WS_STACK"; export WS_STACK
1447c478bd9Sstevel@tonic-gate
145cdf0c1d5Smjnelson#
146cdf0c1d5Smjnelson# Set the workspace name and unset tmpwsname (as we reuse it later)
147cdf0c1d5Smjnelson#
148cdf0c1d5Smjnelsonwsname=`echo $tmpwsname|fmtwsname`
149cdf0c1d5Smjnelsonunset tmpwsname
1507c478bd9Sstevel@tonic-gate
1517c478bd9Sstevel@tonic-gate#
1527c478bd9Sstevel@tonic-gate# Checking for CODEMGR_WSPATH
1537c478bd9Sstevel@tonic-gate#
1547c478bd9Sstevel@tonic-gateif [ "(" "${CODEMGR_WSPATH}x" != "x" ")" -a "(" ! -d $wsname ")" -a \
1557c478bd9Sstevel@tonic-gate     "(" `expr "$wsname" : "\/"` = "0" ")" ]
1567c478bd9Sstevel@tonic-gatethen
1577c478bd9Sstevel@tonic-gate	ofs=$IFS
1587c478bd9Sstevel@tonic-gate	IFS=": 	"
1597c478bd9Sstevel@tonic-gate	for i in $CODEMGR_WSPATH
1607c478bd9Sstevel@tonic-gate	do
1617c478bd9Sstevel@tonic-gate		if [ -d ${i}/${wsname} ]; then
1627c478bd9Sstevel@tonic-gate			wsname=${i}/${wsname}
1637c478bd9Sstevel@tonic-gate			break
1647c478bd9Sstevel@tonic-gate		fi
1657c478bd9Sstevel@tonic-gate	done
1667c478bd9Sstevel@tonic-gate	IFS=$ofs
1677c478bd9Sstevel@tonic-gatefi
1687c478bd9Sstevel@tonic-gate
169cdf0c1d5Smjnelson#
1707c478bd9Sstevel@tonic-gate# to translate it to an absolute pathname.  We need an
1717c478bd9Sstevel@tonic-gate# absolute pathname in order to set CODEMGR_WS.
1727c478bd9Sstevel@tonic-gate#
1737c478bd9Sstevel@tonic-gateif [ `expr "$wsname" : "\/"` = "0" ]
1747c478bd9Sstevel@tonic-gatethen
1757c478bd9Sstevel@tonic-gate	pwd=`pwd`
1767c478bd9Sstevel@tonic-gate	wsname="$pwd/$wsname"
1777c478bd9Sstevel@tonic-gatefi
1787c478bd9Sstevel@tonic-gate
1797c478bd9Sstevel@tonic-gate#
1807c478bd9Sstevel@tonic-gate#	Check to see if this is a valid workspace
1817c478bd9Sstevel@tonic-gate#
1827c478bd9Sstevel@tonic-gateif [ ! -d $wsname ]; then
1837c478bd9Sstevel@tonic-gate	echo "$wsname . . . no such directory" >&2
1847c478bd9Sstevel@tonic-gate	if $setenv; then
1857c478bd9Sstevel@tonic-gate		cleanup_env
1867c478bd9Sstevel@tonic-gate		return 1
1877c478bd9Sstevel@tonic-gate	else
1887c478bd9Sstevel@tonic-gate		exit 1
1897c478bd9Sstevel@tonic-gate	fi
1907c478bd9Sstevel@tonic-gatefi
191cdf0c1d5Smjnelson
192cdf0c1d5Smjnelson#
193cdf0c1d5Smjnelson# This catches the case of a passed in workspace path
194cdf0c1d5Smjnelson# Check which type of SCM is in use by $wsname.
195cdf0c1d5Smjnelson#
196f7e41c80Smjnelson(cd $wsname && env CODEMGR_WS="" $WHICH_SCM) | read SCM_MODE tmpwsname
197cdf0c1d5Smjnelsonif [[ $? != 0 || "$SCM_MODE" == unknown ]]; then
198cdf0c1d5Smjnelson	echo "Error: Unable to detect a supported SCM repository in $wsname"
1997c478bd9Sstevel@tonic-gate	if $setenv; then
2007c478bd9Sstevel@tonic-gate		cleanup_env
2017c478bd9Sstevel@tonic-gate		return 1
2027c478bd9Sstevel@tonic-gate	else
2037c478bd9Sstevel@tonic-gate		exit 1
2047c478bd9Sstevel@tonic-gate	fi
2057c478bd9Sstevel@tonic-gatefi
2067c478bd9Sstevel@tonic-gate
207cdf0c1d5Smjnelsonwsname=$tmpwsname
2087c478bd9Sstevel@tonic-gateCODEMGR_WS=$wsname ; export CODEMGR_WS
209cdf0c1d5SmjnelsonSRC=$wsname/usr/src; export SRC
210cdf0c1d5SmjnelsonTSRC=$wsname/usr/ontest; export TSRC
2117c478bd9Sstevel@tonic-gate
212cdf0c1d5Smjnelsonif [ "$SCM_MODE" = "teamware" -a -d ${wsname}/Codemgr_wsdata ]; then
213cdf0c1d5Smjnelson	CM_DATA="Codemgr_wsdata"
2147c478bd9Sstevel@tonic-gate	wsosdir=$CODEMGR_WS/$CM_DATA/sunos
2157c478bd9Sstevel@tonic-gate	protofile=$wsosdir/protodefs
216cdf0c1d5Smjnelsonelif [ "$SCM_MODE" = "mercurial" -a -d ${wsname}/.hg ]; then
217cdf0c1d5Smjnelson	CM_DATA=".hg"
218cdf0c1d5Smjnelson	wsosdir=$CODEMGR_WS/$CM_DATA
219cdf0c1d5Smjnelson	protofile=$wsosdir/org.opensolaris.protodefs
220cdf0c1d5Smjnelsonelse
221cdf0c1d5Smjnelson	echo "$wsname is not a supported workspace; type is $SCM_MODE" >&2
222cdf0c1d5Smjnelson	if $setenv; then
223cdf0c1d5Smjnelson		cleanup_env
224cdf0c1d5Smjnelson		return 1
225cdf0c1d5Smjnelson	else
226cdf0c1d5Smjnelson		exit 1
227cdf0c1d5Smjnelson	fi
228cdf0c1d5Smjnelsonfi
2297c478bd9Sstevel@tonic-gate
230f7e41c80SmjnelsonMACH=`uname -p`
231f7e41c80Smjnelson
2327c478bd9Sstevel@tonic-gateif [ ! -f $protofile ]; then
2337c478bd9Sstevel@tonic-gate	if [ ! -w $CODEMGR_WS/$CM_DATA ]; then
2347c478bd9Sstevel@tonic-gate		#
2357c478bd9Sstevel@tonic-gate		# The workspace doesn't have a protodefs file and I am
2367c478bd9Sstevel@tonic-gate		# unable to create one.  Tell user and use /tmp instead.
2377c478bd9Sstevel@tonic-gate		#
2387c478bd9Sstevel@tonic-gate		echo "Unable to create the proto defaults file ($protofile)."
2397c478bd9Sstevel@tonic-gate
2407c478bd9Sstevel@tonic-gate		# Just make one in /tmp
2417c478bd9Sstevel@tonic-gate		wsosdir=/tmp
2427c478bd9Sstevel@tonic-gate		protofile=$wsosdir/protodefs
2437c478bd9Sstevel@tonic-gate	fi
2447c478bd9Sstevel@tonic-gate
2457c478bd9Sstevel@tonic-gate	if [ ! -d $wsosdir ]; then
2467c478bd9Sstevel@tonic-gate		mkdir $wsosdir
2477c478bd9Sstevel@tonic-gate	fi
2487c478bd9Sstevel@tonic-gate
2497c478bd9Sstevel@tonic-gate	cat << PROTOFILE_EoF > $protofile
2507c478bd9Sstevel@tonic-gate#!/bin/sh
2517c478bd9Sstevel@tonic-gate#
2527c478bd9Sstevel@tonic-gate#	Set default proto areas for this workspace
2537c478bd9Sstevel@tonic-gate#	NOTE: This file was initially automatically generated.
2547c478bd9Sstevel@tonic-gate#
2557c478bd9Sstevel@tonic-gate#	Feel free to edit this file.  If this file is removed
2567c478bd9Sstevel@tonic-gate#	it will be rebuilt containing default values.
2577c478bd9Sstevel@tonic-gate#
2587c478bd9Sstevel@tonic-gate#	The variable CODEMGR_WS is available to this script.
2597c478bd9Sstevel@tonic-gate#
2607c478bd9Sstevel@tonic-gate#	PROTO1 is the first proto area searched and is typically set
2617c478bd9Sstevel@tonic-gate#	to a proto area associated with the workspace.  The ROOT
2627c478bd9Sstevel@tonic-gate#	environment variable is set to the same as PROTO1.  If you
2637c478bd9Sstevel@tonic-gate#	will be doing make installs this proto area needs to be writable.
2647c478bd9Sstevel@tonic-gate#
2657c478bd9Sstevel@tonic-gate#	PROTO2 and PROTO3 are set to proto areas to search before the
2667c478bd9Sstevel@tonic-gate#	search proceeds to the local machine or the proto area specified by
2677c478bd9Sstevel@tonic-gate#	TERMPROTO.
2687c478bd9Sstevel@tonic-gate#
2697c478bd9Sstevel@tonic-gate#	TERMPROTO (if specified) is the last place searched.  If
2707c478bd9Sstevel@tonic-gate#	TERMPROTO is not specified the search will end at the local
2717c478bd9Sstevel@tonic-gate#	machine.
2727c478bd9Sstevel@tonic-gate#
2737c478bd9Sstevel@tonic-gate
2747c478bd9Sstevel@tonic-gatePROTO1=\$CODEMGR_WS/proto
275cdf0c1d5SmjnelsonPROTOFILE_EoF
2767c478bd9Sstevel@tonic-gate
277cdf0c1d5Smjnelson	if [ "$SCM_MODE" = "teamware" ]; then
278cdf0c1d5Smjnelson		cat << PROTOFILE_EoF >> $protofile
2797c478bd9Sstevel@tonic-gateif [ -f "\$CODEMGR_WS/Codemgr_wsdata/parent" ]; then
2807c478bd9Sstevel@tonic-gate   #
2817c478bd9Sstevel@tonic-gate   # If this workspace has an codemgr parent then set PROTO2 to
2827c478bd9Sstevel@tonic-gate   # point to the parents proto space.
2837c478bd9Sstevel@tonic-gate   #
2847c478bd9Sstevel@tonic-gate   parent=\`workspace parent \$CODEMGR_WS\`
285cdf0c1d5Smjnelson   if [[ -n \$parent ]]; then
2867c478bd9Sstevel@tonic-gate	   PROTO2=\$parent/proto
2877c478bd9Sstevel@tonic-gate   fi
2887c478bd9Sstevel@tonic-gatefi
2897c478bd9Sstevel@tonic-gatePROTOFILE_EoF
290cdf0c1d5Smjnelson	elif [ "$SCM_MODE" = "mercurial" ]; then
291cdf0c1d5Smjnelson		cat << PROTOFILE_EoF >> $protofile
292cdf0c1d5Smjnelsonparent=\`(cd \$CODEMGR_WS && hg path default 2>/dev/null)\`
293cdf0c1d5Smjnelsonif [[ \$? -eq 0 && -n \$parent ]]; then
294f7e41c80Smjnelson   [[ -n \$(check_proto \$parent/proto) ]] && PROTO2=\$parent/proto
295cdf0c1d5Smjnelsonfi
296cdf0c1d5SmjnelsonPROTOFILE_EoF
297cdf0c1d5Smjnelson	fi
2987c478bd9Sstevel@tonic-gatefi
2997c478bd9Sstevel@tonic-gate
3007c478bd9Sstevel@tonic-gate. $protofile
3017c478bd9Sstevel@tonic-gate
3027c478bd9Sstevel@tonic-gate# This means you don't have to type make -e all of the time
3037c478bd9Sstevel@tonic-gate
3047c478bd9Sstevel@tonic-gateMAKEFLAGS=e; export MAKEFLAGS
3057c478bd9Sstevel@tonic-gate
3067c478bd9Sstevel@tonic-gate#
3077c478bd9Sstevel@tonic-gate#	Set up the environment variables
3087c478bd9Sstevel@tonic-gate#
3097c478bd9Sstevel@tonic-gateROOT=/proto/root_${MACH}	# default
3107c478bd9Sstevel@tonic-gate
3117c478bd9Sstevel@tonic-gateENVCPPFLAGS1=
3127c478bd9Sstevel@tonic-gateENVCPPFLAGS2=
3137c478bd9Sstevel@tonic-gateENVCPPFLAGS3=
3147c478bd9Sstevel@tonic-gateENVCPPFLAGS4=
3157c478bd9Sstevel@tonic-gateENVLDLIBS1=
3167c478bd9Sstevel@tonic-gateENVLDLIBS2=
3177c478bd9Sstevel@tonic-gateENVLDLIBS3=
3187c478bd9Sstevel@tonic-gate
3197c478bd9Sstevel@tonic-gatePROTO1=`check_proto $PROTO1`
320cdf0c1d5Smjnelsonif [[ -n "$PROTO1" ]]; then	# first proto area specifed
3217c478bd9Sstevel@tonic-gate	ROOT=$PROTO1
3227c478bd9Sstevel@tonic-gate	ENVCPPFLAGS1=-I$ROOT/usr/include
3237c478bd9Sstevel@tonic-gate	export ENVCPPFLAGS1
3247c478bd9Sstevel@tonic-gate	ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
3257c478bd9Sstevel@tonic-gate	export ENVLDLIBS1
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate	PROTO2=`check_proto $PROTO2`
328cdf0c1d5Smjnelson	if [[ -n "$PROTO2" ]]; then	# second proto area specifed
3297c478bd9Sstevel@tonic-gate		ENVCPPFLAGS2=-I$PROTO2/usr/include
3307c478bd9Sstevel@tonic-gate		export ENVCPPFLAGS2
3317c478bd9Sstevel@tonic-gate		ENVLDLIBS2="-L$PROTO2/lib -L$PROTO2/usr/lib"
3327c478bd9Sstevel@tonic-gate		export ENVLDLIBS2
3337c478bd9Sstevel@tonic-gate
334cdf0c1d5Smjnelson		PROTO3=`check_proto $PROTO3`
335cdf0c1d5Smjnelson		if [[ -n "$PROTO3" ]]; then	# third proto area specifed
3367c478bd9Sstevel@tonic-gate			ENVCPPFLAGS3=-I$PROTO3/usr/include
3377c478bd9Sstevel@tonic-gate			export ENVCPPFLAGS3
3387c478bd9Sstevel@tonic-gate			ENVLDLIBS3="-L$PROTO3/lib -L$PROTO3/usr/lib"
3397c478bd9Sstevel@tonic-gate			export ENVLDLIBS3
3407c478bd9Sstevel@tonic-gate		fi
3417c478bd9Sstevel@tonic-gate	fi
3427c478bd9Sstevel@tonic-gatefi
3437c478bd9Sstevel@tonic-gate
3447c478bd9Sstevel@tonic-gateexport ROOT
3457c478bd9Sstevel@tonic-gate
346cdf0c1d5Smjnelsonif [[ -n "$TERMPROTO" ]]; then	# fallback area specifed
3477c478bd9Sstevel@tonic-gate	TERMPROTO=`check_proto $TERMPROTO`
3487c478bd9Sstevel@tonic-gate	ENVCPPFLAGS4="-Y I,$TERMPROTO/usr/include"
3497c478bd9Sstevel@tonic-gate	export ENVCPPFLAGS4
3507c478bd9Sstevel@tonic-gate	ENVLDLIBS3="$ENVLDLIBS3 -Y P,$TERMPROTO/lib:$TERMPROTO/usr/lib"
3517c478bd9Sstevel@tonic-gate	export ENVLDLIBS3
3527c478bd9Sstevel@tonic-gatefi
3537c478bd9Sstevel@tonic-gate
3547c478bd9Sstevel@tonic-gateosbld_flag=0
3557c478bd9Sstevel@tonic-gate
356*1fb95e48SDan McDonaldif [[ ! -v CLOSED_IS_PRESENT ]]; then
357*1fb95e48SDan McDonald        if [[ -d $SRC/../closed ]]; then
358*1fb95e48SDan McDonald                export CLOSED_IS_PRESENT="yes"
359*1fb95e48SDan McDonald        else
360*1fb95e48SDan McDonald                export CLOSED_IS_PRESENT="no"
361*1fb95e48SDan McDonald        fi
362*1fb95e48SDan McDonaldfi
363*1fb95e48SDan McDonald
364cdf0c1d5Smjnelsonif [[ -z "$ONBLD_DIR" ]]; then
365cdf0c1d5Smjnelson	ONBLD_DIR=$(dirname $(whence $0))
3667c478bd9Sstevel@tonic-gatefi
367cdf0c1d5Smjnelson
368cdf0c1d5Smjnelsonif ! echo ":$PATH:" | grep ":${ONBLD_DIR}:" > /dev/null; then
369cdf0c1d5Smjnelson	PATH="${ONBLD_DIR}:${ONBLD_DIR}/${MACH}:${PATH}"
3707c478bd9Sstevel@tonic-gate	osbld_flag=1
3717c478bd9Sstevel@tonic-gatefi
372cdf0c1d5Smjnelson
373cdf0c1d5Smjnelsonexport PATH
374cdf0c1d5Smjnelson
375cdf0c1d5Smjnelsonif [[ -n "$PROTO2" ]]; then
3767c478bd9Sstevel@tonic-gate   # This should point to the parent's proto
3777c478bd9Sstevel@tonic-gate   PARENT_ROOT=$PROTO2
3787c478bd9Sstevel@tonic-gate   export PARENT_ROOT
3797c478bd9Sstevel@tonic-gateelse
3807c478bd9Sstevel@tonic-gate   # Clear it in case it's already in the env.
3817c478bd9Sstevel@tonic-gate   PARENT_ROOT=
3827c478bd9Sstevel@tonic-gatefi
3837c478bd9Sstevel@tonic-gateexport ONBLD_DIR
3847c478bd9Sstevel@tonic-gateexport MACH
385cdf0c1d5Smjnelson
386cdf0c1d5Smjnelsonos_rev=`uname -r`
387cdf0c1d5Smjnelsonos_name=`uname -s`
388cdf0c1d5Smjnelson
389cdf0c1d5Smjnelsonif [[ $os_name != "SunOS" || `expr $os_rev : "5\."` != "2" ]]; then
3907c478bd9Sstevel@tonic-gate   #
391cdf0c1d5Smjnelson   # This is not a SunOS 5.x machine - something is wrong
3927c478bd9Sstevel@tonic-gate   #
393cdf0c1d5Smjnelson   echo "***WARNING: this script is meant to be run on SunOS 5.x."
394cdf0c1d5Smjnelson   echo "            This machine appears to be running: $os_name $os_rev"
3957c478bd9Sstevel@tonic-gatefi
3967c478bd9Sstevel@tonic-gate
3977c478bd9Sstevel@tonic-gateecho ""
398cdf0c1d5Smjnelsonecho "Workspace                    : $wsname"
3997c478bd9Sstevel@tonic-gateif [ -n "$parent" ]; then
4007c478bd9Sstevel@tonic-gate   echo "Workspace Parent             : $parent"
4017c478bd9Sstevel@tonic-gatefi
4027c478bd9Sstevel@tonic-gateecho "Proto area (\$ROOT)           : $ROOT"
4037c478bd9Sstevel@tonic-gateif [ -n "$PARENT_ROOT" ]; then
4047c478bd9Sstevel@tonic-gate   echo "Parent proto area (\$PARENT_ROOT) : $PARENT_ROOT"
4057c478bd9Sstevel@tonic-gatefi
4067c478bd9Sstevel@tonic-gateecho "Root of source (\$SRC)        : $SRC"
4077c478bd9Sstevel@tonic-gateecho "Root of test source (\$TSRC)  : $TSRC"
4087c478bd9Sstevel@tonic-gateif [ $osbld_flag = "1" ]; then
4097c478bd9Sstevel@tonic-gate   echo "Prepended to PATH            : $ONBLD_DIR"
4107c478bd9Sstevel@tonic-gatefi
411cdf0c1d5Smjnelsonecho "Current directory (\$PWD)     : $wsname"
4127c478bd9Sstevel@tonic-gateecho ""
4137c478bd9Sstevel@tonic-gate
414cdf0c1d5Smjnelsoncd $wsname
4157c478bd9Sstevel@tonic-gate
4167c478bd9Sstevel@tonic-gateif $setenv; then
4177c478bd9Sstevel@tonic-gate	cleanup_env
4187c478bd9Sstevel@tonic-gateelse
4197c478bd9Sstevel@tonic-gate	exec ${SHELL:-sh} "$@"
4207c478bd9Sstevel@tonic-gatefi
421