# FreeWnn is a network-extensible Kana-to-Kanji conversion system.
# This file is part of FreeWnn.
#
# Copyright Kyoto University Research Institute for Mathematical Sciences
#                 1987, 1988, 1989, 1990, 1991, 1992
# Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
# Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
# Copyright FreeWnn Project 2001, 2004
#
# Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.jp>
# Maintainer:  FreeWnn Project   <freewnn@tomo.gr.jp>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Emacs; see the file COPYING.  If not, write to the
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

include @top_builddir@/makerule.mk
  top_srcdir = @top_srcdir@
      srcdir = @srcdir@
top_builddir = @top_builddir@
KWNNJUTILOBJ = $(top_builddir)/kWnn/jutil

INSTALL      = @INSTALL@
INSTALLFLAGS = -o $(WNNOWNER)

        ATOD = $(KWNNJUTILOBJ)/katod
        ATOF = $(KWNNJUTILOBJ)/katof
    WNNTOUCH = $(KWNNJUTILOBJ)/kwnntouch
       HINSI = @KHINSI_DATA@
    FZK_FLAG =

FULL = full.fzk

HINSI_SRC = hinsi.data

FZK_SRCS = fzk.attr fzk.fzkattr fzk.jircon fzk.shuutan 	   fzk.con fzk.jirattr fzk.master

DIC_SRCS = single.u 	hword.u

DICS = single.dic 	hword.dic

ALLTGT = $(FULL) $(DICS)

all:: $(ALLTGT)

.SUFFIXES: .dic .u

.u.dic:
	$(ATOD) -h $(HINSI) $@ < $<

$(DICS): $(HINSI)

$(FULL):: $(FZK_SRCS) fzk.master-.c
	$(CPP) -I$(srcdir) $(FZK_FLAG) fzk.master-.c | egrep -v '^(# |#line |#pragma |$$)' | $(ATOF) -h $(HINSI) $@

# To avoid circular dependency, we don't use 'fzk.master.c'
fzk.master-.c: fzk.master
	$(RM) $@
	$(LN) $? $@

clean::
	$(RM) fzk.master-.c

instserver:: install

install::
	@case '${MFLAGS}' in *[i]*) set +e;; esac;
	@for i in $(KWNNDICDIR); do if [ -d $(DESTDIR)$$i ]; then \
	set +x; else (set -x; $(MKDIRHIER) $(DESTDIR)$$i; \
	chown $(WNNOWNER) $(DESTDIR)$$i); fi \
	done

install:: $(ALLTGT)
	@if [ -d $(DESTDIR)$(KWNNSYSDICDIR) ]; then set +x; \
	else (set -x; $(MKDIRHIER) $(DESTDIR)$(KWNNSYSDICDIR)); fi
	@case '${MFLAGS}' in *[i]*) set +e;; esac;
	@for i in $(ALLTGT); do if [ -f $(DESTDIR)$(KWNNSYSDICDIR)/$$i ]; then \
	set +x; \
	else (set -x; \
	$(INSTALL) -c $(INSTALLFLAGS) $(INSTLIBFLAGS) $$i $(DESTDIR)$(KWNNSYSDICDIR); \
	$(WNNTOUCH) $(DESTDIR)$(KWNNSYSDICDIR)/$$i); fi \
	done

depend::
	@echo "skipping make in my dir"

clean::
	$(RM) $(FULL) $(DICS)
