#! /bin/sh
# $Id: mkanthydic,v 1.3 2001/12/30 15:04:12 tak Exp $

# Avoid effects from locale settings.
# The idea of this `unset' emulation is borrowed from Autoconf 2.50
unset=unset
(HEKE=heke; unset HEKE) >/dev/null 2>/dev/null || unset=false

$unset LANG	|| test -z "${LANG+set}"	|| { LANG=C; export LANG; }
$unset LC_ALL	|| test -z "${LC_ALL+set}"	|| { LC_ALL=C; export LC_ALL; }
$unset LC_COLLATE || test -z "${LC_COLLATE+set}" || { LC_COLLATE=C; export LC_COLLATE; }

tfiles=
ucdict=
dic=anthy.dic
while [ $# -gt 0 ]; do
    case $1 in
	-o?*)	dic=`expr "X$1" : 'X-o\(.*\)'` ;;
	-o)	if [ $# -le 1 ]; then
		    echo "$0: option requires an argument -- $1" >&2
		    exit 2
		fi
		shift; dic=$1 ;;
	-uc)	if [ $# -le 1 ]; then
		    echo "$0: option requires an argument -- $1" >&2
		    exit 2
		fi
		shift; ucdict=$1 ;;
	--)	shift; break ;;
	-*)	echo "$0: invalid option -- $1" >&2
		echo "Usage: $0 [-o ANTHY.DIC] FILES..." >&2
		exit 2 ;;
	*)	tfiles="$tfiles $1" ;;
    esac
    shift
done

cat -- $tfiles "$@" | sort -u | ./genanthydic -o "$dic" -uc "$ucdict"
