#
# Makefile for HLaTeX fonts
#
# created by koaunghi.un@zdv.uni-tuebingen.de <1994/08/12>.
#	modified for version 0.93 <1995/11/22>.
#
# 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/mf
# You need at least \HLaTeX-0.93 to use these fonts.
#
# "make" or "make default" will create following fonts,
# which belong to standard HLaTeX font set:
#	wsmj:		wsmjm wsmjmo
#	wsgt:		wsgtm wsgtmo
#	hhmj:		hhmjm hhmjmo
#	hsym:		hsmj
#
# If you want to make additional fonts, you should do "make extra"
# for following fonts. Specifing a target name will make the font.
#	wsgr:		wsgrm wsgrmo
#	wsgs:		wsgs  wsgso
#	wsmg:		wsmg  wsmgo
#	wsol:		wsol  wsolo
#	wsyt:		wsyt  wsyto
#
# "make all" creates all the above fonts.

# 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 binaries "kpsexpand" and
# "texconfig" 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_MAGSTEP="0.5 0.6 0.7 0.8 0.9 1.0 \\magstep0.5 \\magstep1 \
	\\magstep2 \\magstep3 \\magstep4 \\magstep5"
HH_MAGSTEP="\\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 = mkdir -p

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

# The following directory structure is taken from teTeX-0.3.3
# distribution, which is in turn based on tds(TeX Directory Standard).
# Otherwise, 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.

  FONTDIR = `kpsexpand '$$FONTDIR'`
  H_PKDIR = $(FONTDIR)/pk/$(MODE)/korean
  H_MFDIR = $(FONTDIR)/source/korean
 H_TFMDIR = $(FONTDIR)/tfm/korean
TEXCONFIG = `type -path texconfig`

# If you intend to use pre-made bfseries fonts uncomment following line.
# Please note, \HLaTeX is capable of making bfseries fonts on the fly
# via TeX macro.
#	wsmjb wsmjbo
#	wsgtb wsgtbo
#	hhmjb hhmjbo
#	wsgrb wsgrbo

#BF="b bo"

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

one_series="wsgs wsmg wsol wsyt"
two_series="wsmj wsgt wsgr"
hanja="hhmj hhgt"

default: wsmj wsgt hsym hhmj

extra: wsgr wsgs wsmg wsol wsyt

all: default extra

.SILENT:

$(two_series):
	if [ ! -f $@*.mf ] ; then \
	  echo "MetaFont sources for \"$@\" don't exist." ; \
	  echo "Please get the sources first." ; \
	  exit 1; \
	fi ;
	[ -d $(MODE) ] || mkdir $(MODE)
	for i in A B C D E F G H I J ; do \
	  for j in $(WS_MAGSTEP) ; do \
	    for k in m mo $(BF) ; do \
	      mf "\mode:=$(MODE); mag:=$${j}; input $@$${k}$${i}.mf" ; \
	      for l in $@$${k}$${i}.*gf ; do \
		gftopk $${l} $(MODE)/$${l%gf}pk && $(RM) $${l} ; \
	      done ; \
	    done ; \
	  done ; \
	  mv $@*.tfm $(MODE) ; \
	done
	touch $@

$(one_series):
	if [ ! -f $@*.mf ] ; then \
	  echo "MetaFont sources for \"$@\" don't exist." ; \
	  echo "Please get the sources first." ; \
	  exit 1; \
	fi ;
	[ -d $(MODE) ] || mkdir $(MODE)
	for i in A B C D E F G H I J ; do \
	  for j in $(WS_MAGSTEP) ; do \
	    for k in m mo ; do \
	      mf "\mode:=$(MODE); mag:=$${j}; input $@$${k}$${i}.mf" ; \
	      for l in $@$${k}$${i}.*gf ; do \
		gftopk $${l} $(MODE)/$${l%gf}pk && $(RM) $${l} ; \
	      done ; \
	    done ; \
	  done ; \
	  mv $@*.tfm $(MODE) ; \
	done
	touch $@

$(hanja):
	if [ ! -f $@*.mf ] ; then \
	  echo "MetaFont sources for \"$@\" don't exist." ; \
	  echo "Please get the sources first." ; \
	  exit 1; \
	fi ;
	[ -d $(MODE) ] || mkdir $(MODE)
	for i in A B C D E F G H I J K L M N O P Q R S T; do \
	  for j in $(HH_MAGSTEP) ; do \
	    for k in m mo $(BF) ; do \
	      mf "\mode:=$(MODE); mag:=$${j}; input $@$${k}$${i}.mf" ; \
	      for l in $@$${k}$${i}.*gf ; do \
		gftopk $${l} $(MODE)/$${l%gf}pk && $(RM) $${l} ; \
	      done ; \
	    done ; \
	  done ; \
	  mv $@*.tfm $(MODE) ; \
	done
	touch $@

hsym:
	if [ ! -f hsmj*.mf ] ; then \
	  echo "MetaFont sources for \"$@\" don't exist." ; \
	  echo "Please get the sources first." ; \
	  exit 1; \
	fi ;
	[ -d $(MODE) ] || mkdir $(MODE)
	for i in K J ; do \
	  for j in $(WS_MAGSTEP) ; do \
	    for k in m mo $(BF) ; do \
	      mf "\mode:=$(MODE); mag:=$${j}; input hsmj$${k}$${i}.mf" ; \
	      for l in hsmj$${k}$${i}.*gf ; do \
		gftopk $${l} $(MODE)/$${l%gf}pk && $(RM) $${l} ; \
	      done ; \
	    done; \
	  done ; \
	  mv $@*.tfm $(MODE) ; \
	done
	touch $@

install:
	if [ -z $(FONTDIR) ] ; then \
	   echo "FONTDIR is not set properly." ; \
	   echo "Please install PK/TFM fonts manually." ; \
	   exit 1; \
	fi ;
	for i in $(two_series) $(one_series) $(hanja) ; do \
	  if [ -f $${i} ] ; then \
	     [ -d $(H_PKDIR)/$${i} ] || $(MKDIR) $(H_PKDIR)/$${i} ; \
	     [ -d $(H_TFMDIR)/$${i} ] || $(MKDIR) $(H_TFMDIR)/$${i} ; \
	     $(INSTALL) $(MODE)/$${i}*.tfm $(H_TFMDIR)/$${i} ; \
	     $(INSTALL) $(MODE)/$${i}*pk $(H_PKDIR)/$${i} ; \
	  fi ; \
	done ;
	if [ -f hsym ] ; then \
	   [ -d $(H_PKDIR)/hsym ] || $(MKDIR) $(H_PKDIR)/hsym ; \
	   [ -d $(H_TFMDIR)/hsym ] || $(MKDIR) $(H_TFMDIR)/hsym ; \
	   $(INSTALL) $(MODE)/hsmj*.tfm $(H_TFMDIR)/hsym ; \
	   $(INSTALL) $(MODE)/hsmj*pk $(H_PKDIR)/hsym ; \
	fi ;
	[ ! -z $(TEXCONFIG) ] && texconfig rehash

install-src:
	if [ -z $(FONTDIR) ] ; then \
	   echo "FONTDIR is not set properly." ; \
	   echo "Please install MF fonts manually." ; \
	   exit 1; \
	fi ;
	for i in $(two_series) $(one_series) $(hanja) ; do \
	  if [ -f $${i} ] ; then \
	     [ -d $(H_MFDIR)/$${i} ] || $(MKDIR) $(H_MFDIR)/$${i} ; \
	     $(INSTALL) $${i}*.mf $(H_TFMDIR)/$${i} ; \
	  fi ; \
	done ;
	if [ -f hsym ] ; then \
	   [ -d $(H_MFDIR)/hsym ] || $(MKDIR) $(H_MFDIR)/hsym ; \
	   $(INSTALL) hsmj*.tfm sym* $(H_MFDIR)/hsym ; \
	fi ;
	[ ! -z $(TEXCONFIG) ] && texconfig rehash

clean:
	for i in $(two_series) $(one_series) $(hanja) hsym ; do \
	  [ -f $${i} ] && $(RM) $${i} ; \
	done ;
	$(RM) *.log *.tfm *gf *pk #*# *~
