#
#   $Id: Makefile.in,v 1.6 2004/04/24 18:56:40 aono Exp $
#

#
# 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 1999, 2000, 2001, 2002, 2004
# 
# 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 of the License, 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

include @top_builddir@/makerule.mk
  top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
 WNNJUTILOBJ = $(top_builddir)/Wnn/jutil

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

       INCLUDES = -I$(top_builddir)
           ATOD = $(WNNJUTILOBJ)/atod
           ATOF = $(WNNJUTILOBJ)/atof
       WNNTOUCH = $(WNNJUTILOBJ)/wnntouch
          HINSI = @HINSI_DATA@
       FZK_FLAG =

LINKS = Version bio.hd chimei.hd computer.hd fzk.attr fzk.con fzk.fzkattr fzk.jirattr  fzk.jircon fzk.master fzk.shuutan jinmei.hd kihon.hd koyuu.hd setsuji.hd special.hd special.u symbol.hd tankan.hd

WNNDICS = bio.u chimei.u computer.u jinmei.u kihon.u koyuu.u setsuji.u symbol.u tankan.u

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

DIC= 	bio.dic 	chimei.dic 	computer.dic 	jinmei.dic 	kihon.dic 	koyuu.dic 	setsuji.dic 	special.dic 	symbol.dic 	tankan.dic

MORE=	kihon.more 	setsuji.more 	jinmei.more 	chimei.more 	koyuu.more 	special.more 	computer.more 	bio.more 	symbol.more 	tankan.more

FZKDATA= 	 full.fzk 	 kougo.fzk 	 std.fzk

VERSION=	Version

DICS = $(DIC) $(FZKDATA)

all:: $(LINKS) $(WNNDICS) $(DICS)

includes:: $(LINKS)

Version:  $(PUBDICPLUSSRC)/Version
	$(RM) $@
	$(LN) $? $@

includes:: Version

depend:: Version

clean::
	$(RM) Version

bio.hd:  $(PUBDICPLUSSRC)/bio.hd
	$(RM) $@
	$(LN) $? $@

includes:: bio.hd

depend:: bio.hd

clean::
	$(RM) bio.hd

# bio.u:  $(PUBDICPLUSSRC)/bio.u
#	$(RM) $@
#	$(LN) $? $@

includes:: bio.u

depend:: bio.u

clean::
	$(RM) bio.u

chimei.hd:  $(PUBDICPLUSSRC)/chimei.hd
	$(RM) $@
	$(LN) $? $@

includes:: chimei.hd

depend:: chimei.hd

clean::
	$(RM) chimei.hd

# chimei.u:  $(PUBDICPLUSSRC)/chimei.u
#	$(RM) $@
#	$(LN) $? $@

includes:: chimei.u

depend:: chimei.u

clean::
	$(RM) chimei.u

computer.hd:  $(PUBDICPLUSSRC)/computer.hd
	$(RM) $@
	$(LN) $? $@

includes:: computer.hd

depend:: computer.hd

clean::
	$(RM) computer.hd

# computer.u:  $(PUBDICPLUSSRC)/computer.u
#	$(RM) $@
#	$(LN) $? $@

includes:: computer.u

depend:: computer.u

clean::
	$(RM) computer.u

fzk.attr:  $(PUBDICPLUSSRC)/fzk.attr
	$(RM) $@
	$(LN) $? $@

includes:: fzk.attr

depend:: fzk.attr

clean::
	$(RM) fzk.attr

fzk.con:  $(PUBDICPLUSSRC)/fzk.con
	$(RM) $@
	$(LN) $? $@

includes:: fzk.con

depend:: fzk.con

clean::
	$(RM) fzk.con

fzk.fzkattr:  $(PUBDICPLUSSRC)/fzk.fzkattr
	$(RM) $@
	$(LN) $? $@

includes:: fzk.fzkattr

depend:: fzk.fzkattr

clean::
	$(RM) fzk.fzkattr

fzk.jirattr:  $(PUBDICPLUSSRC)/fzk.jirattr
	$(RM) $@
	$(LN) $? $@

includes:: fzk.jirattr

depend:: fzk.jirattr

clean::
	$(RM) fzk.jirattr

fzk.jircon:  $(PUBDICPLUSSRC)/fzk.jircon
	$(RM) $@
	$(LN) $? $@

includes:: fzk.jircon

depend:: fzk.jircon

clean::
	$(RM) fzk.jircon

fzk.master:  $(PUBDICPLUSSRC)/fzk.master
	$(RM) $@
	$(LN) $? $@

includes:: fzk.master

depend:: fzk.master

clean::
	$(RM) fzk.master

fzk.shuutan:  $(PUBDICPLUSSRC)/fzk.shuutan
	$(RM) $@
	$(LN) $? $@

includes:: fzk.shuutan

depend:: fzk.shuutan

clean::
	$(RM) fzk.shuutan

jinmei.hd:  $(PUBDICPLUSSRC)/jinmei.hd
	$(RM) $@
	$(LN) $? $@

includes:: jinmei.hd

depend:: jinmei.hd

clean::
	$(RM) jinmei.hd

# jinmei.u:  $(PUBDICPLUSSRC)/jinmei.u
#	$(RM) $@
#	$(LN) $? $@

includes:: jinmei.u

depend:: jinmei.u

clean::
	$(RM) jinmei.u

kihon.hd:  $(PUBDICPLUSSRC)/kihon.hd
	$(RM) $@
	$(LN) $? $@

includes:: kihon.hd

depend:: kihon.hd

clean::
	$(RM) kihon.hd

# kihon.u:  $(PUBDICPLUSSRC)/kihon.u
#	$(RM) $@
#	$(LN) $? $@

includes:: kihon.u

depend:: kihon.u

clean::
	$(RM) kihon.u

koyuu.hd:  $(PUBDICPLUSSRC)/koyuu.hd
	$(RM) $@
	$(LN) $? $@

includes:: koyuu.hd

depend:: koyuu.hd

clean::
	$(RM) koyuu.hd

# koyuu.u:  $(PUBDICPLUSSRC)/koyuu.u
#	$(RM) $@
#	$(LN) $? $@

includes:: koyuu.u

depend:: koyuu.u

clean::
	$(RM) koyuu.u

setsuji.hd:  $(PUBDICPLUSSRC)/setsuji.hd
	$(RM) $@
	$(LN) $? $@

includes:: setsuji.hd

depend:: setsuji.hd

clean::
	$(RM) setsuji.hd

# setsuji.u:  $(PUBDICPLUSSRC)/setsuji.u
#	$(RM) $@
#	$(LN) $? $@

includes:: setsuji.u

depend:: setsuji.u

clean::
	$(RM) setsuji.u

special.hd:  $(PUBDICPLUSSRC)/special.hd
	$(RM) $@
	$(LN) $? $@

includes:: special.hd

depend:: special.hd

clean::
	$(RM) special.hd

special.u:  $(PUBDICPLUSSRC)/special.u
	$(RM) $@
	$(LN) $? $@

includes:: special.u

depend:: special.u

clean::
	$(RM) special.u

symbol.hd:  $(PUBDICPLUSSRC)/symbol.hd
	$(RM) $@
	$(LN) $? $@

includes:: symbol.hd

depend:: symbol.hd

clean::
	$(RM) symbol.hd

# symbol.u:  $(PUBDICPLUSSRC)/symbol.u
#	$(RM) $@
#	$(LN) $? $@

includes:: symbol.u

depend:: symbol.u

clean::
	$(RM) symbol.u

tankan.hd:  $(PUBDICPLUSSRC)/tankan.hd
	$(RM) $@
	$(LN) $? $@

includes:: tankan.hd

depend:: tankan.hd

clean::
	$(RM) tankan.hd

# tankan.u:  $(PUBDICPLUSSRC)/tankan.u
#	$(RM) $@
#	$(LN) $? $@

includes:: tankan.u

depend:: tankan.u

clean::
	$(RM) tankan.u

instserver:: install

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

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

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

install:: $(FZK_SRC)
	@if [ -d $(DESTDIR)$(JWNNFZKSRCDIR) ]; then set +x; \
	else (set -x; $(MKDIRHIER) $(DESTDIR)$(JWNNFZKSRCDIR)); fi
	@for flag in ${MAKEFLAGS} ''; do \
	case "$$flag" in *=*) ;; *[i]*) set +e;; esac; done; \
	for i in $(FZK_SRC); do \
	(set -x; $(INSTALL) $(INSTDATFLAGS) $(LOCAL_INSTFLAGS) $$i $(DESTDIR)$(JWNNFZKSRCDIR)); \
	done

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

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

std.fzk: fzk.master-.c $(FZK_SRC)
	$(CPP) $(FZK_FLAG) fzk.master-.c | egrep -v '^(# |#line |#pragma |$$)' | $(ATOF) -h $(HINSI) $@

full.fzk: $(FZK_SRC)
	$(MAKE) FZK_FLAG=-DKANSAI std.fzk
	$(MV) std.fzk $@

kougo.fzk: $(FZK_SRC)
	$(MAKE) FZK_FLAG=-DKOUGO std.fzk
	$(MV) std.fzk $@

# additional rule from PubdicPlus/Makefile.in : by aono
pod.o: $(PUBDICPLUSSRC)/pod.c
	$(CC) $(CFLAGS) -c $?

pod: pod.o
	$(CC) $(CFLAGS) -o $@ pod.o

$(WNNDICS): pod $(PUBDICPLUSSRC)/pubdic.p
	./pod $(PUBDICPLUSSRC)/pubdic.p -w -1 -k `basename $@ .u` > $@

.SUFFIXES: .hd .u .dic .more

.u.dic:
	cat $*.hd $< | $(ATOD) -p $(VERSION) -P $(VERSION) -h $(HINSI) $@

.hd.more:
	$(ATOD) -h $(HINSI) $@ < $<

$(DIC): $(HINSI)

clean::
	$(RM) -f *.fzk *.dic *.more fzk.master-.c pod $(LINKS)
