#!/bin/sh
# tc-inst --- install data files used by tcode driver on Emacs.

# Copyright (C) 1998-2000 KITAJIMA Akira.

# Author: KITAJIMA Akira <kitajima@ics.es.osaka-u.ac.jp>
# Create: 28th December, 1998

# $Id: tc-inst.in,v 1.2 2001/10/27 08:20:41 kitajima Exp $

### Code:

prefix=/usr
pkgdatadir=/usr/share/tc

echo This is an install-script for data files used by tcode driver on Emacs.
echo Directory for original data: $pkgdatadir

if [ $# = 0 ]; then
	echo usage: $0 tcode-data-directory
	exit 1
fi

tcdatadir=$1

if [ ! -d $tcdatadir ]; then
	echo -n "Directory $tcdatadir does not exist.  "
	echo -n "Create (y/n) [y]? "
	read yn
	if [ x"$yn" = xn ]; then
		exit 1
	fi
	mkdir -p $tcdatadir
fi

install_file () {
	if [ -f "$tcdatadir/$1" ]; then
		echo "File $tcdatadir/$1 already exists."
		echo -n "Overwrite (y/n) [n]? "
		read yn
		if [ x"$yn" != xy ]; then
			echo 'Skipped.'
		else
			cp -p $pkgdatadir/$1 $tcdatadir
		fi
	else
		cp -p $pkgdatadir/$1 $tcdatadir
	fi
}

install_file mazegaki.dic
install_file bushu.rev
install_file symbol.rev
install_file .tc-bitmap-8x16

if [ -f $HOME/.tc ]; then
	echo -n "File ~/.tc already exists.  "
	echo -n "Overwrite (y/n) [n]? "
	read yn
	if [ x"$yn" != xy ]; then
		echo "You may add (setq tcode-data-directory \"$tcdatadir/\")"
		echo "in your .tc"
		exit 0
	fi
	cp -p $HOME/.tc $HOME/.tc.bak
fi

echo ";;; -*-emacs-lisp-*- This file is automatically created" > $HOME/.tc
echo "(setq tcode-data-directory \"$tcdatadir/\")" >> $HOME/.tc
echo "(setq eelll-text \"$pkgdatadir/EELLLTXT\")" >> $HOME/.tc

echo
echo "You have to append the following line to your .emacs."
echo "(require 'tc-setup)"
echo -n "Append now (y/n) [n]? "
read yn
if [ x"$yn" = xy ]; then
	echo "(require 'tc-setup)" >> $HOME/.emacs
fi

exit 0
