#!/bin/sh

#################################################################
# makebin.csh - create gzipped tar archive containing the specified
# bin and lib directories. For a given platform, these could be any of:
#
#	solaris-sparc --> bin-solaris-sparc.tar.gz
#	solaris-amd64 --> bin-solaris-amd64.tar.gz
#	linux-intel --> bin-linux-intel.tar.gz
#	linux-x86_64 --> bin-linux-x86_64.tar.gz
#       linux-arm64
#       macos-arm64
#	AIX --> bin-AIX.tar.gz
#	HP --> bin-HP.tar.gz
#	
# The file is directly written to the FTP directory and
# read permissions set. 
#
# Synopsis: makebin.csh platform
#
# where platform is the name of the directory to be copied.
# This script appends _D to the directory name to indicate
# that it is the current development version.
#
#################################################################

#=======  GLOBAL VARIABLES ==============
PLATFORM=$*[1]
BIRCH=$HOME/BIRCHBINDEV
FTPDIR=$BIRCH
DBPATH=$BIRCH
BUILDDIR=$PWD
FILENAME=bin-"$PLATFORM"_D

# RM_CMD - command to be used for removing files and directories
if [ -e /usr/bin/rm ]
	then
   RM_CMD=/usr/bin/rm
else
   if [ -e /bin/rm ]
   	then
      RM_CMD=/bin/rm
   else
      RM_CMD=rm
   fi
fi



# Create a gzipped tar archive 
# This version copies symbolic links, rather than the files
# they point to.
# Tar with the 'h' option would replace symbolic
# links with real files.
# Unfortunately, tar does not do globbing, so things
# such as *.old or *.bak can not be used in the 
# exclude file.
cd $BIRCH
nice +10 tar -cvpf $FTPDIR/$FILENAME.tar -X $BUILDDIR/makebin.exclude bin-$PLATFORM lib-$PLATFORM bin-osx-x86_64 bin-osx-x86_64-legacy lib-osx-x86_64  lib-osx-x86_64-legacy
cd $FTPDIR
#nice +10 gzip -f $FILENAME.tar
#nice +10 pigz -f $FILENAME.tar
nice +10 gzip -f $FILENAME.tar
chmod a+r $FILENAME.tar.gz

