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

# Copyright (C) 1998, 1999 KITAJIMA Akira.

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

# $Id: tc-inst.in,v 1.2 1999/02/27 12:42:02 kitajima Exp $

### Code:

prefix=@prefix@
datadir=@datadir@

echo This is an install-script for data files used by tcode driver on Emacs.

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 $datadir/$1 $tcdatadir
		fi
	else
		cp -p $datadir/$1 $tcdatadir
	fi
}

install_file mazegaki.dic
install_file bushu.dic

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 \"$datadir/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/.tc
fi

exit 0
