# Date: Sat, 06 Apr 96 01:41:30 -0500
# From: Wonkoo Kim <wkim+@pitt.edu>
# To: Koaunghi Un <koaunghi.un@zdv.uni-tuebingen.de>
#
# Dear Koaunghi Un,
#
# Makefile in Fonts/ dir seems to have a bug with font names for
# one_series="wsgs wsmg wsol wsyt" fonts.  For those fonts, * and
# ...
# If the unix shell script cannot handle the problem easily,
# my makefile (attached below) may help.
# Anyway I don't use a unix(-like) shell.  So I modified makefile.
# I use GNU make.
# ...
#
#  --
#  Wonkoo Kim (wkim+@pitt.edu)
#
# Makefile for HLaTeX fonts
# -------------------------
#
# created by koaunghi.un@zdv.uni-tuebingen.de <1994/08/12>.
#	modified for version 0.93 <1995/11/22>.
#	modified with help of Wonkoo Kim <wkim+@pitt.edu> <1995/04/10>.
#	updated for version 0.96 <1997/03/04>
#
# To make PK fonts, you must have the MF files here. If you doesn't
# yet have them, get them by anonymous ftp from the nearest CTAN site.
#	~ftp/tex-archive/fonts/korean/HLaTeX
# You need at least \HLaTeX-0.96 to use these fonts.
#	 common.tar.gz
#	 hanja-gothic.tar.gz
#	 hanja-gungseo.tar.gz
#	 hanja-myoungjo.tar.gz
#	 hsym.tar.gz
#	 jamo.tar.gz
#	 johab.tar.gz
#	 wsbm.tar.gz
#	 wsgr.tar.gz
#	 wsgs.tar.gz
#	 wsgt.tar.gz
#	 wsmg.tar.gz
#	 wsmj.tar.gz
#	 wsol.tar.gz
#	 wspg.tar.gz
#	 wspn.tar.gz
#	 wssm.tar.gz
#	 wsyt.tar.gz
# Unpack these fonts here. This will create subdirectories of
#	source/korean/...
#	tfm/korean/...
#	vf/korean/...
#
# "make" or "make default" will create following fonts. Specifing a
# target name will make the font.
# These belong to standard HLaTeX font set:
#       wsmj:   m mo (b bo) suffixes: 0 - 9
#	wsgt:   m mo (b bo) suffixes: 0 - 9
#	hhmj:   m mo (b bo) prefix: mj0, suffixes: 10 - 29
#	hhgt:   m mo (b bo) prefix: gt0, suffixes: 10 - 29
#	hsmj:   m mo (b bo) prefix: mj0, suffixes: 04 - 07
#	hsgt:   m mo (b bo) prefix: gt0, suffixes: 04 - 07
#	jamo:   m mo        prefixes: jmmj jmgt jmsr jmnv, suffixes: 04 - 07
#				      jmtt,suffix: 10
# Jamo fonts works with virtual fonts, which are pre-made by me. "make
# install" will install the vf/tfm files as well.
#
# If you want to make additional fonts, you should do "make extra"
# for following fonts. Specifing a target name will make the font.
#       wsgr:   m mo (b bo) suffixes: 0 - 9
#	wsgs:   "" o        suffixes: 0 - 9
#       wsmg:   "" o        suffixes: 0 - 9
#	wsol:   "" o        suffixes: 0 - 9
#       wsyt:   "" o        suffixes: 0 - 9
#	wssm:   m mo (b bo) suffixes: 0 - 9
#       wsbm:   m mo        suffixes: 0 - 9
#	wspg:   m mo        suffixes: 0 - 9
#       wspn:   "" i        suffixes: 0 - 9
#	hhgs:   m mo (b bo) prefix: gs0, suffixes: 10 - 29
# "make all" creates all the above fonts.
#
# If you intend to use johab instead wansung fonts, you should do
# "make johab". This will creates following fonts.
#	johab:  m mo        prefixes: mj0 gt0 pn0, suffixes: 01 - 03
# For johab fonts, there are virtual fonts as well, which are made by
# me. Do not forget to install the vf/tfm files. "make install" will
# do this for you.

# If all goes well, install the fonts with "make install".
# "make install" will succeed to do its work, if your TeX system
# corresponds to the tds(TeX Directory Standard) and the binary
# "kpsewhich" or "texhash" are accessible.
# If you want to put the MetaFont sources in the TeX's fonts hierachie,
# install them with "make install-src".

SHELL=/bin/sh

WS_MAG=0.5 0.6 0.7 0.8 0.9 1.0 \\magstep0.5 \\magstep1 \
	\\magstep2 \\magstep3 \\magstep4 \\magstep5
HH_MAG=\\magstep-2 \\magstep-1 \\magstep-0.5 1.0 \\magstep0.5 \
	\\magstep1 \\magstep2 \\magstep3 \\magstep4 \\magstep5

#
# Configure here.
# ---------------
INSTALL = install -c -m 644
RM = rm -f
MKDIR = ./mkinstalldirs

# For valid MODE, see $MFINPUTS/modes.mf
MODE = imagen
#MODE = qmsostf

# This Makefile relies heavely on TDS (TeX Directory Standard).
# If your TeX installation doesn't confirm TDS, it's better to install
# fonts manually instead of saying 'make install' on the command line.
# After installing fonts, it is probably necessary to update "ls-R"
# database for the newly installed fonts.

# For kpathsea version >= 3.0
TEXMF = `kpsewhich -expand-var '$$TEXMF'`
LS_R = `type -path MakeTeXls-R`
# For kpathsea version < 3.0
#TEXMF = `kpsexpand '$$TEXMF'`
#LS_R = `type -path texhash`
# For TeX without kpathsea
#TEXMF = /usr/TeX/texmf
#LS_R =

FONTDIR = ${TEXMF}/fonts

# If you intend to use pre-made bfseries fonts uncomment following line.

#BF=b bo

# In this case, you may use option "hardbold" in your HLaTeX document.
# Please note, \HLaTeX is capable of making bfseries fonts on the fly
# via TeX macro.

###
### End of user configurations
### --------------------------

wsmj := $(addprefix wsmj, $(foreach v, m mo $(BF), \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wsgt := $(addprefix wsgt, $(foreach v, m mo $(BF), \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wsgr := $(addprefix wsgr, $(foreach v, m mo $(BF), \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wssm := $(addprefix wssm, $(foreach v, m mo $(BF), \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))

wsgs := $(addprefix wsgs, $(foreach v, "" o, \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wsmg := $(addprefix wsmg, $(foreach v, "" o, \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wsol := $(addprefix wsol, $(foreach v, "" o, \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wsyt := $(addprefix wsyt, $(foreach v, "" o, \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wspn := $(addprefix wspn, $(foreach v, "" i, \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wsbm := $(addprefix wsbm, $(foreach v, m mo, \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))
wspg := $(addprefix wspg, $(foreach v, m mo, \
        $(addprefix $v, 0 1 2 3 4 5 6 7 8 9)))

hhmj := $(addprefix mj0, $(foreach v, m mo $(BF), $(addprefix $v, \
        10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29)))
hhgt := $(addprefix gt0, $(foreach v, m mo $(BF), $(addprefix $v, \
        10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29)))
hhgs := $(addprefix gs0, $(foreach v, m mo, $(addprefix $v, \
        10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29)))

hsmj := $(addprefix mj0, $(foreach v, m mo $(BF), \
	$(addprefix $v, 04 05 06 07)))
hsgt := $(addprefix gt0, $(foreach v, m mo $(BF), \
	$(addprefix $v, 04 05 06 07)))

jamo := $(addprefix jm, $(foreach v, mj gt nv sr, \
	$(addprefix $v, 01 o01)))
jmtt := $(addprefix jmtt, 10 o10)

johab := $(foreach v, mj0 gt0 pn0, $(addprefix $v, \
	$(foreach w, m mo, $(addprefix $w, 01 02 03))))

ws_all := $(wsgs) $(wsmg) $(wsol) $(wsyt) $(wsmj) $(wsgt) $(wsgr) $(wsbm) \
	$(wspg) $(wspn) $(wssm)
hh_all := $(hhmj) $(hhgt) $(hhgs)
hs_all := $(hsmj) $(hsgt)
johab_all := $(johab)
jamo_all  := $(jamo) $(jmtt)


default: wsmj wsgt hsmj hsgt hhmj hhgt
extra:  wsgr wsgs wsmg wsol wsyt wsbm wspg wspn wssm hhgs jamo jmtt

all:    default extra

wsmj:   $(wsmj)
wsgt:   $(wsgt)
wsgr:   $(wsgr)
wssm:	$(wssm)
wsgs:   $(wsgs)
wsmg:   $(wsmg)
wsol:   $(wsol)
wsyt:   $(wsyt)
wsbm:	$(wsbm)
wspg:	$(wspg)
wspn:	$(wspn)
hsmj:   $(hsmj)
hsgt:	$(hsgt)
hhmj:	$(hhmj)
hhgt:   $(hhgt)
hhgs:	$(hhgs)
jamo:	$(jamo)
jmtt:	$(jmtt)
johab:	$(johab)

.SILENT:

$(ws_all): dummy
	@echo $@
	./runmf $@ $(MODE) \
	  `echo $@ | sed -e 's/\(....\).*$$/\1/'` $(WS_MAG)

$(hh_all): dummy
	@echo $@
	@(case $@ in \
	mj*) outdir=myoungjo ;; \
	gt*) outdir=gothic ;; \
	gs*) outdir=gungseo ;; \
	esac; \
	./runmf $@ $(MODE) $${outdir} $(HH_MAG); )

$(hs_all) $(johab_all): dummy
	@echo $@
	@(case $@ in \
	mj*) outdir=myoungjo ;; \
	gt*) outdir=gothic ;; \
	pn*) outdir=pen ;; \
	esac; \
	./runmf $@ $(MODE) $${outdir} $(WS_MAG); )

$(jamo_all): dummy
	@echo $@
	./runmf $@ $(MODE) jamo $(WS_MAG)

dummy: ;
.PHONY: dummy

install:
	if [ -z $(FONTDIR) ] ; then \
	   echo "FONTDIR is not set properly." ; \
	   echo "Please install PK/TFM/(VF) fonts manually." ; \
	   exit 1; \
	fi ; \
	for dir in pk tfm vf ; do \
	   if [ -d $${dir} ] ; then \
	      echo "Copying $${dir} to $(FONTDIR)..." ; \
	      tar -cf - $${dir} | (cd $(FONTDIR) ; umask 022 ; tar -xvf -) ; \
	   fi ; \
	done ; \
	[ ! -z $(LS_R) ] && $(LS_R)

install-src:
	if [ -z $(FONTDIR) ] ; then \
	   echo "FONTDIR is not set properly." ; \
	   echo "Please install MF fonts manually." ; \
	   exit 1; \
	fi ; \
	if [ -d source ] ; then \
	   echo "Copying source to $(FONTDIR)..." ; \
	   tar -cf - source | (cd $(FONTDIR) ; umask 022 ; tar -xvf -) ; \
	fi ; \
	[ ! -z $(LS_R) ] && $(LS_R)

clean:
	$(RM) -r pk tfm
	$(RM) *.log *.tfm *gf *pk #*# *~
