#!/bin/sh
# Copyright 2001 BSDi, Inc. Concord, CA, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

VERSION=3.1.1.9

CWD=$(pwd)
TMP=/tmp/build-x3270

rm -rf $TMP
mkdir $TMP
cd $TMP

tar zxvf $CWD/x3270-$VERSION.tar.gz
cd x3270-3.1.1/

xmkmf -a
make

make install

for file in x3270-script.man x3270.man x3270if.man
do
   cat $file | gzip -9c \
       > /usr/X11R6/man/man1/$(basename $file .man).1.gz
done
cat ibm_hosts.man | gzip -9c > /usr/X11R6/man/man5/ibm_hosts.5.gz

cp X3270.xad /etc/X11/app-defaults/X3270

mkdir -p /usr/doc/x3270-$VERSION
cp -a Docs/* Examples html /usr/doc/x3270-$VERSION
chown -R root.root /usr/doc/x3270-${VERSION}
find /usr/doc/x3270-${VERSION} -type f -exec chmod 644 {} \;

chmod 644 /etc/X11/app-defaults/X3270

cd $PKG/usr/doc/x3270-$VERSION/Examples
for file in bash expect sh ksh
do
   chmod 755 /usr/doc/x3270-${VERSION}/*.${file}
done

rm /usr/X11R6/lib/fonts/misc/fonts.dir
