ws.sh revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# ident "%Z%%M% %I% %E% SMI"
#
# This script sets up the environment variables for a SunOS
# codemgr workspace and spawns a shell with the environment
# setup.
#
# The following Environment variables are set:
# CODEMGR_WS
# ONBLD_DIR
# SRC
# TSRC
# ROOT
# PARENT_ROOT
# MACH
# MAKEFLAGS
# ENVCPPFLAGS{1-4}
# ENVLDLIBS{1-3}
#
# The MAKEFLAGS environment variable is set to force make
# to read default make variables from the environment.
#
# Workspace names can be specified in two forms: pathname
# and hostname:pathname. If the hostname:pathname form is used
# the script accesses the environment through the /net automounter
# map.
#
#
# function to produce a pathname from a workspace name or subdirectory.
# The workspace name can have hostname:pathname format.
#
awk -F: '$1 != $0 { print "/net/"$1$2 } \
$1 == $0 { print $0 }'
}
#
# function to check to see if a proto area is new or old format
#
{
# Check for problematic parent specification and adjust
#
# that this is an old style proto area
#
echo $proto
else
echo "${proto}/root_${MACH}"
fi
}
{
# keep the env. clean when returning
return 0
}
if [ "$1" = "-e" ]; then
setenv=true
shift
else
setenv=false
fi
if [ $# -lt 1 ]; then
fi
if [ $# -lt 1 ]; then
echo "usage: ws [-e] [workspace_name]" >&2
if $setenv; then
return 1
else
exit 1
fi
fi
#
# This variable displays the nested activations of workspaces.
# This is done here to get the exact name the user entered.
#
shift
#
# Checking for CODEMGR_WSPATH
#
then
IFS=": "
for i in $CODEMGR_WSPATH
do
if [ -d ${i}/${wsname} ]; then
break
fi
done
fi
# to translate it to an absolute pathname. We need an
# absolute pathname in order to set CODEMGR_WS.
#
then
pwd=`pwd`
fi
if [ ! -d $wsname/Codemgr_wsdata ]; then
echo "Error: $wsname is not a workspace" >&2
if $setenv; then
return 1
else
exit 1
fi
fi
if [ -z "$tmpwsname" ]; then
echo "Error: $wsname is not a workspace" >&2
if $setenv; then
return 1
else
exit 1
fi
fi
#
# Check to see if this is a valid workspace
#
if [ ! -d $wsname ]; then
echo "$wsname . . . no such directory" >&2
if $setenv; then
return 1
else
exit 1
fi
fi
if [ -d ${wsname}/Codemgr_wsdata ]; then
else
echo "$wsname is not a workspace" >&2
if $setenv; then
return 1
else
exit 1
fi
fi
if [ ! -f $protofile ]; then
if [ ! -w $CODEMGR_WS/$CM_DATA ]; then
#
# The workspace doesn't have a protodefs file and I am
# unable to create one. Tell user and use /tmp instead.
#
echo "Unable to create the proto defaults file ($protofile)."
# Just make one in /tmp
fi
if [ ! -d $wsosdir ]; then
fi
cat << PROTOFILE_EoF > $protofile
#!/bin/sh
#
# Set default proto areas for this workspace
# NOTE: This file was initially automatically generated.
#
# Feel free to edit this file. If this file is removed
# it will be rebuilt containing default values.
#
# The variable CODEMGR_WS is available to this script.
#
# PROTO1 is the first proto area searched and is typically set
# to a proto area associated with the workspace. The ROOT
# environment variable is set to the same as PROTO1. If you
# will be doing make installs this proto area needs to be writable.
#
# PROTO2 and PROTO3 are set to proto areas to search before the
# search proceeds to the local machine or the proto area specified by
# TERMPROTO.
#
# TERMPROTO (if specified) is the last place searched. If
# TERMPROTO is not specified the search will end at the local
# machine.
#
PROTO1=\$CODEMGR_WS/proto
if [ -f "\$CODEMGR_WS/Codemgr_wsdata/parent" ]; then
#
# If this workspace has an codemgr parent then set PROTO2 to
# point to the parents proto space.
#
parent=\`workspace parent \$CODEMGR_WS\`
if [ -n \$parent ]; then
PROTO2=\$parent/proto
fi
fi
PROTOFILE_EoF
fi
# This means you don't have to type make -e all of the time
#
# Set up the environment variables
#
export ENVCPPFLAGS1
ENVLDLIBS1="-L$ROOT/lib -L$ROOT/usr/lib"
export ENVLDLIBS1
export ENVCPPFLAGS2
ENVLDLIBS2="-L$PROTO2/lib -L$PROTO2/usr/lib"
export ENVLDLIBS2
export ENVCPPFLAGS3
ENVLDLIBS3="-L$PROTO3/lib -L$PROTO3/usr/lib"
export ENVLDLIBS3
fi
fi
fi
export ROOT
ENVCPPFLAGS4="-Y I,$TERMPROTO/usr/include"
export ENVCPPFLAGS4
ENVLDLIBS3="$ENVLDLIBS3 -Y P,$TERMPROTO/lib:$TERMPROTO/usr/lib"
export ENVLDLIBS3
fi
#
# Now let's set those variables which are either 4.1.x specific
# or 5.0 specific
#
#
# Enable all of the DOUBLECROSS_ROOT components for the 4.1.x compile
#
export DOUBLECROSS_ROOT PATH
#
# Enable any 5.x specific variables here
#
fi
fi
export PATH
fi
if [ "$PROTO2" != "" ]; then
# This should point to the parent's proto
export PARENT_ROOT
else
# Clear it in case it's already in the env.
fi
export ONBLD_DIR
export MACH
else
#
#
echo " operating system. This machine appears to be running:"
echo " $os_rev "
fi
echo ""
echo "Workspace (\$CODEMGR_WS) : $CODEMGR_WS"
if [ -n "$parent" ]; then
echo "Workspace Parent : $parent"
fi
echo "Proto area (\$ROOT) : $ROOT"
if [ -n "$PARENT_ROOT" ]; then
echo "Parent proto area (\$PARENT_ROOT) : $PARENT_ROOT"
fi
echo "Root of source (\$SRC) : $SRC"
echo "Root of test source (\$TSRC) : $TSRC"
if [ $osbld_flag = "1" ]; then
echo "Prepended to PATH : $ONBLD_DIR"
fi
echo "Current directory (\$PWD) : $CODEMGR_WS"
echo ""
cd $CODEMGR_WS
if $setenv; then
else
fi