#! /bin/sh
#
# install-examples
# 		Use this script to copy all examples into a common place.
#		You should be in the examples directory when you run this.
#
#		This creates a file example-setup that, when sourced,
#		sets environment variables to allow acces to the examples
#
#		Edit ROOT to change where to install the examples.

set -x

ROOT=.
LIBDIR=${ROOT}/lib
BINDIR=${ROOT}/bin

mkdir ${BINDIR}

# Install example binaries

cp src/examples/clock/clock ${BINDIR}
cp src/examples/control/control ${BINDIR}
cp src/examples/dial/dial ${BINDIR}
cp src/examples/hello/hello ${BINDIR}
cp src/examples/hit/hit ${BINDIR}
cp src/examples/import/import ${BINDIR}
cp src/examples/line/line ${BINDIR}
cp src/examples/scrolling/scrolling ${BINDIR}
cp src/examples/stroke/stroke ${BINDIR}
cp src/examples/text/text ${BINDIR}

# Install example application defaults files

mkdir ${LIBDIR}
mkdir ${LIBDIR}/app-defaults

cp src/examples/clock/Clock.ad ${LIBDIR}/app-defaults/Clock
cp src/examples/control/Control.ad ${LIBDIR}/app-defaults/Control
cp src/examples/dial/Dial.ad ${LIBDIR}/app-defaults/Dial
cp src/examples/hello/Hello.ad ${LIBDIR}/app-defaults/Hello
cp src/examples/hit/Hit.ad ${LIBDIR}/app-defaults/Hit
cp src/examples/import/Import.ad ${LIBDIR}/app-defaults/Import
cp src/examples/line/Line.ad ${LIBDIR}/app-defaults/Line
cp src/examples/scrolling/Scrolling.ad ${LIBDIR}/app-defaults/Scrolling
cp src/examples/stroke/Stroke.ad ${LIBDIR}/app-defaults/Stroke
cp src/examples/text/Text.ad ${LIBDIR}/app-defaults/Text

# Install example application UID files

mkdir ${LIBDIR}/uid

cp src/examples/clock/Clock.uid ${LIBDIR}/uid
cp src/examples/control/Control.uid ${LIBDIR}/uid
cp src/examples/dial/Dial.uid ${LIBDIR}/uid
cp src/examples/hello/Hello.uid ${LIBDIR}/uid
cp src/examples/hit/Hit.uid ${LIBDIR}/uid
cp src/examples/import/Import.uid ${LIBDIR}/uid
cp src/examples/line/Line.uid ${LIBDIR}/uid
cp src/examples/scrolling/Scrolling.uid ${LIBDIR}/uid
cp src/examples/stroke/Stroke.uid ${LIBDIR}/uid
cp src/examples/text/Text.uid ${LIBDIR}/uid

# Install misc. example application files

mkdir ${LIBDIR}/bitmaps

cp src/examples/control/*.xbm ${LIBDIR}/bitmaps
cp src/examples/hit/*.xbm ${LIBDIR}/bitmaps
cp src/examples/stroke/*.xbm ${LIBDIR}/bitmaps

mkdir ${LIBDIR}/afm

cp src/examples/text/PSres.upr ${LIBDIR}/afm
cp src/examples/text/TimesRoman.afm ${LIBDIR}/afm

mkdir ${LIBDIR}/ps

cp src/examples/scrolling/still.ps ${LIBDIR}/ps

#
# Create example-setup script
#

rm -f example-setup

echo echo Source this script \\\(do not execute it\\\) before running example apps. >> example-setup
echo setenv XBMLANGPATH ${LIBDIR}/bitmaps/%B:\`printenv XBMLANGPATH\` >> example-setup
echo setenv UIDPATH ${LIBDIR}/uid/%U:\`printenv UIDPATH\` >> example-setup
echo setenv XFILESEARCHPATH ${LIBDIR}/%T/%N%S:\`printenv XFILESEARCHPATH\` >> example-setup
echo setenv PSRESOURCEPATH ${LIBDIR}/afm:\`printenv PSRESOURCEPATH\` >> example-setup
echo setenv POSTSCRIPT_DISTILLERY ${LIBDIR}/ps/still.ps >> example-setup

