#!/bin/ksh
# *************************************************
# *                                               *
# *  Make Special Source Distribution for Turkey  *
# *                                               *
# *************************************************
# File: TurkeySource
#
#                   COPYRIGHT (c) 2003, 2004 BY
#         SIGMET INCORPORATED, WESTFORD MASSACHUSETTS, U.S.A.
# 
# THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND  COPIED
# ONLY  IN  ACCORDANCE WITH  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
# INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE  OR  ANY OTHER
# COPIES  THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
# OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF  THE  SOFTWARE  IS  HEREBY
# TRANSFERED.

BASENAME="turkey-source"

VERSION="`show_machine_code -version | tr -dc '.[0-9]'`"

IRIS_REL=${IRIS_ROOT}"/iris-${VERSION}/"
IRIS_INS=${IRIS_ROOT}"/install/"

PUBLICNAME="haze:/usr/sigmet/info/DeveloperResources/Turkey-Files/${BASENAME}-${VERSION}.tgz"

# The original release directory had better be there, but not the file
# we're about to create.
#
if [ ! -d ${IRIS_REL} ] ; then
  echo "Sorry, '${IRIS_REL}' does not yet exist.  You must build"
  echo "  a standard IRIS release first before adding these special source"
  echo "  files to it."
  exit 1
fi
if [ -r "${IRIS_REL}${BASENAME}.tgz" ] ; then
  echo "Sorry, ${IRIS_REL}${BASENAME}.tgz already exists.  Please manually"
  echo "  delete the existing file if you really intend to recreate it."
  exit 1
fi

echo "Making ${IRIS_REL}${BASENAME}.tgz..."

rm -f ${IRIS_REL}${BASENAME} ${IRIS_REL}${BASENAME}.tgz

# This requires the IRIS/Display source.  To do this, we are providing
# the source code to the following processes:
#   iris/output (libs/outlib)
#   iris/window
# And the following libraries (antenna, config, dsp, rtq, user, xsig are standard):
#   libs/share
#   libs/misc
#   libs/tvsubs
#   libs/vtv
#   libs/link
#   libs/fileformats
#   libs/tiff
#   libs/jpeg
#   libs/maps
#   libs/uxsig
#   libs/xpm
#
${IRIS_INS}make_iris_tape -stdout 8 \
  -source iris/output       -source libs/outlib      -source iris/window \
  -source libs/share        -source libs/misc \
  -source libs/tvsubs       -source libs/vtv         -source libs/link \
  -source libs/fileformats  -source libs/tiff \
  -source libs/jpeg         -source libs/maps \
  -source libs/uxsig        -source libs/xpm \
    > ${IRIS_REL}${BASENAME}

gzip -S .tgz --best ${IRIS_REL}${BASENAME}

echo ""
echo "Make this file available as:"
read "REPLY?    ${PUBLICNAME} ? [no]"
if [ "${REPLY}" = "yes" ] ; then
  echo "Installing public file..."
  rcp ${IRIS_REL}${BASENAME}.tgz ${PUBLICNAME}
fi
