#!/usr/local/bin/perl
#-*- perl -*-
#######################################################################
# Merge Index for IISA
#                                   Copyright (C) 1998, Takuya NAKAYAMA
#######################################################################
$MKARY="/home/nltools/bin/mkary";
#----------------------------------------------------------------------
# ץȤ֤Ƥǥ쥯ȥμ
#----------------------------------------------------------------------
$HERE = $0;
$HERE =~ s/[^\/]+$//;
$HERE =~ s/\/+$//;
$HERE = "." if !$HERE;
#----------------------------------------------------------------------
# ץν
#----------------------------------------------------------------------
$OPT{'dir'} = "";
$OPT{'output'} = "MGIND";
# ץ
while ($_ = shift @ARGV) {
    /^\s*$/ && next;
    if (s/^-h//)    { $HELP_MODE = 1; next; }
    if (s/^-o//)    { $OPT{'output'} = shift @ARGV; next; }
    if (s/^-D//)    { $DEBUG_MODE = 1; next; }
    push(@{$OPT{'file'}}, $_);
}
# إפν
if ($HELP_MODE || $#{$OPT{file}} < 0) {
    print STDERR "mgind : Merge Index Files for IISA\n";
    print STDERR "   usage: mgind (options..) <files..>\n";
    print STDERR " options:\n";
    print STDERR "   -o ...   : sets output file name [$OPT{'output'}]\n";
    print STDERR "   -help    : shows this help\n"; 
    print STDERR " <files..> = [@$OPT{'dir'}]\n";
    exit(1);
}
$files = "@{$OPT{file}}";
`$HERE/mgind0 -o $OPT{output} $files | $HERE/indc -S $OPT{output}`;
`$MKARY -so $OPT{output}.ix`;
