# Makefile for leim subdirectory in GNU Emacs on the Microsoft W32 API.
# Copyright (C) 1997 Electrotechnical Laboratory, JAPAN.
# Licensed to the Free Software Foundation.

# This file is part of GNU Emacs.

# GNU Emacs 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.
#
# GNU Emacs 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., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.

# 
# Sets up the system dependent macros.
#
!include ..\nt\makefile.def

srcdir=.

# Where to install LEIM files.
INSTALLDIR=$(INSTALL_DIR)\leim

# On Xenix and the IBM RS6000, double-dot gets screwed up.
dot = .

# Which Emacs to use to convert TIT files to Emacs Lisp files,
# byte-compile Emacs Lisp files, and generate the file leim-list.el.
BUILT_EMACS = $(dot)$(dot)\src\$(BLD)\emacs.exe

buildlisppath=$(dot)$(dot)/lisp

# How to run Emacs.
RUN_EMACS = $(BUILT_EMACS) -batch --no-init-file --no-site-file --multibyte

# Subdirectories to be made if $(srcdir) is different from the current
# directory.
SUBDIRS=quail

# Files generated from TIT dictionaries for Chinese GB character set.
TIT_GB=\
	quail/CTLau.el		\
	quail/CCDOSPY.el	\
	quail/Punct.el		\
	quail/PY.el		\
	quail/QJ.el		\
	quail/SW.el		\
	quail/TONEPY.el		\
	quail/ZIRANMA.el

# Files generated from TIT dictionaries for Chinese BIG5 character set.
TIT_BIG5=\
	quail/4Corner.el	\
	quail/ARRAY30.el	\
	quail/CTLauB.el		\
	quail/ECDICT.el		\
	quail/ETZY.el		\
	quail/Punct-b5.el	\
	quail/PY-b5.el		\
	quail/QJ-b5.el		\
	quail/ZOZY.el

CHINESE_TIT=$(TIT_GB) $(TIT_BIG5)

NON_TIT_GB=$(srcdir)/quail/py-punct.el

NON_TIT_BIG5=$(srcdir)/quail/quick-b5.el $(srcdir)/quail/tsang-b5.el \
	     $(srcdir)/quail/pypunct-b5.el

NON_TIT_CNS=$(srcdir)/quail/quick-cns.el $(srcdir)/quail/tsang-cns.el

CHINESE_NON_TIT=$(NON_TIT_GB) $(NON_TIT_BIG5) $(NON_TIT_CNS)

CHINESE_GB=$(TIT_GB) $(NON_TIT_GB)

CHINESE_BIG5=$(TIT_BIG5) $(NON_TIT_BIG5) 

CHINESE_CNS=$(NON_TIT_CNS) 

JAPANESE=$(srcdir)/quail/japanese.el $(srcdir)/skk/skkdic.el

KOREAN=	$(srcdir)/quail/hangul.el	\
	$(srcdir)/quail/hangul3.el	\
	$(srcdir)/quail/hanja.el	\
	$(srcdir)/quail/hanja-jis.el	\
	$(srcdir)/quail/symbol-ksc.el

THAI=$(srcdir)/quail/thai.el

VIETNAMESE=$(srcdir)/quail/viqr.el

LAO=$(srcdir)/quail/lao.el $(srcdir)/quail/lrt.el

INDIAN=$(srcdir)/quail/devanagari.el

TIBETAN=$(srcdir)/quail/tibetan.el

LATIN=$(srcdir)/quail/latin-pre.el $(srcdir)/quail/latin-post.el

SLAVIC= \
	$(srcdir)/quail/czech.el \
	$(srcdir)/quail/slovak.el

GREEK=$(srcdir)/quail/greek.el

RUSSIAN=$(srcdir)/quail/cyrillic.el $(srcdir)/quail/cyril-jis.el

MISC= \
	$(srcdir)/quail/ethiopic.el \
	$(srcdir)/quail/ipa.el \
	$(srcdir)/quail/hebrew.el

CHINESE=$(CHINESE_GB) $(CHINESE_BIG5) $(CHINESE_CNS)
EASTASIA=$(CHINESE) $(JAPANESE) $(KOREAN)
ASIA=$(EASTASIA) $(THAI) $(VIETNAMESE) $(LAO) $(INDIAN) $(TIBETAN)
EUROPEAN=$(LATIN) $(SLAVIC) $(GREEK) $(RUSSIAN)
WORLD=$(ASIA) $(EUROPEAN) $(MISC)

TIT=$(CHINESE_TIT)
NON_TIT=$(CHINESE_NON_TIT) $(JAPANESE) $(KOREAN) $(EUROPEAN) $(MISC)

all: $(BUILT_EMACS) $(SUBDIRS) $(TIT) leim-list.el

# To ensure that we can run Emacs.  This target is ignored (never
# being hit) if a user changes default value of EMACS.
$(dot)$(dot)/src/emacs:
	cd ../src; $(MAKE) $(MFLAGS) emacs

$(SUBDIRS):
	mkdir $@
	echo stamp>stamp-subdir
#	echo (if (fboundp 'normal-top-level-add-subdirs-to-load-path) >subdirs.el
#	echo     (normal-top-level-add-subdirs-to-load-path)) >>subdirs.el

# Rule to generate quail/*.el from CXTERM-DIC/*.tit.
$(TIT):
	if not exist quail $(MAKE) -f makefile.nt quail
	$(RUN_EMACS) -l $(buildlisppath)/international/titdic-cnv \
	    --eval "(batch-titdic-convert t)" -dir quail $(srcdir)/CXTERM-DIC
	$(RUN_EMACS)  -l $(buildlisppath)/international/quail \
	    -f batch-byte-compile $(TIT)

leim-list.el: $(SUBDIRS) $(WORLD)
	$(RUN_EMACS) -l $(buildlisppath)/international/quail \
	    --eval "(update-leim-list-file \".\")"

install: all
	- mkdir $(INSTALLDIR)
	- $(DEL) same-dir.tst
	- $(DEL) $(INSTALLDIR)\same-dir.tst
	echo SameDirTest > $(INSTALLDIR)\same-dir.tst
	if not exist same-dir.tst $(CP) leim-list.el $(INSTALLDIR)
#	if not exist same-dir.tst $(CP) subdirs.el $(INSTALLDIR)
	if not exist same-dir.tst $(CP_DIR) quail $(INSTALLDIR)\quail
	if not exist same-dir.tst $(CP_DIR) skk $(INSTALLDIR)\skk
	- $(DEL) $(INSTALLDIR)\same-dir.tst

clean mostlyclean:
	for %%f in ($(TIT:/=\)) do $(DEL) %%fc
	for %%f in ($(TIT:/=\)) do $(DEL) %%f
	$(DEL) leim-list.el

distclean maintainer-clean:
	if exist stamp-subdir $(DELTREE) $(SUBDIRS)
	$(DEL) stamp-subdir
