#!/bin/sh
#
#ident	"@(#)mkmsg.sh	1.1	95/01/12 SMI"
#
# Copyright (c) 1995 by Sun Microsystems, Inc.
# All rights reserved.
#
# This script is called by the nightly build script to build the _msg
# target that generates a package containing message files for delivery
# to the localization center (the SUNW0on package).
#

USAGE='	usage: mkmsg <env_file>'
#

# test that the path to the environment-setting file was given
if [ $# -ne 1 ]
then
	echo "$USAGE"
	exit 1
fi

# 	Setup environmental variables
. $1

if [ ! -d $PKGARCHIVE ]; then
	mkdir -p $PKGARCHIVE
	echo "Created $PKGARCHIVE"
fi

# standard build path with fast install but no parallel make
#PATH="/opt/onbld/bin:/usr/sbin:/opt/SUNWspro/bin:/usr/ccs/bin:/usr/bin"
#PATH="/opt/onbld/bin/install:$PATH"
#
#automount map for generic tools: teamware/onbld/ongk
TOOLPATH=/shared/ON/tools

 
#Locally mounted compiler always has precedence 
#Impt for Sustaining work to freeze construction set by mounting locally
#
if [ -d /opt/SUNWspro/bin ]; then
        SP=/opt/SUNWspro/bin
else
        if [ "$SPRO_BIN" ]; then
                SP=${SPRO_BIN}
        else
                echo "Error: SPRO_BIN undefined in env" && exit 1
        fi
fi
[ ! -d $SP ] && echo "${SP} not found!" && exit 1
 
if [ -d /opt/onbld/bin ]; then
        BLD="/opt/onbld/bin"
else
        BLD="${TOOLPATH}/onbld/bin"
fi
PATH="${BLD}:/usr/sbin:${SP}:/usr/ccs/bin:/usr/bin"
PATH="${BLD}/install:$PATH"

export PATH
TMPDIR="/tmp"
export TMPDIR
ENVCPPFLAGS1="-I$ROOT/usr/include"
export ENVCPPFLAGS1

unset CFLAGS LD_LIBRARY_PATH

# if superuser, set CH to null
if [ -w /etc/shadow ]
then
	CH=
	export CH
fi

# build message files throughout OS-Net source
cd $SRC
make -e _msg

# initialize the package build referencing shell variables
# force update: if the awk script exists, remove it.
cd $PKGDEFS
[ -f awk_pkginfo ] && rm -f awk_pkginfo
make -e awk_pkginfo

# build the localization package
cd SUNW0on
# consolidate the message files into their installed locations
make -e _msg
# package them
make -e install
