OMEGA_SUBDIR=omega_hebrew_he8
OMEGA_TARGET_SUBDIR=omegahe8
OMEGA_SUBDIRS=afm tfm type1

METAFONT_FILES = \
	    hebfonts/crml10.mf   hebfonts/crmlsl10.mf hebfonts/deads10.mf \
	    hebfonts/frbx.mf     hebfonts/fr.mf       hebfonts/frruehl.mf \
	    hebfonts/frsl.mf     hebfonts/hcaption.mf hebfonts/hcbase.mf \
	    hebfonts/hclassic.mf hebfonts/hebase.mf   hebfonts/hepunct.mf \
	    hebfonts/jerus10.mf  hebfonts/oldjaf10.mf hebfonts/redis10.mf \
	    hebfonts/redis12.mf  hebfonts/redis17.mf  hebfonts/redis7.mf \
	    hebfonts/redis8.mf   hebfonts/redis9.mf   hebfonts/redisb10.mf \
	    hebfonts/redisfnt.mf hebfonts/redis.mf    hebfonts/rediss10.mf \
	    hebfonts/rediss12.mf hebfonts/rediss8.mf  hebfonts/rediss9.mf \
	    hebfonts/shold10.mf  hebfonts/shscr10.mf  hebfonts/shstk10.mf \
	    hebfonts/telav10.mf

OMEGAFONT_FILES = \
	    omega_hebrew_he8/tfm/OmegaHebrew.tfm \
	    omega_hebrew_he8/type1/OmegaHebrew.pfa \
	    omega_hebrew_he8/type1/OmegaHebrew.t3 \
	    omega_hebrew_he8/afm/OmegaHebrew.afm 

PACKAGE_FILES_LIST= GNUmakefile $(METAFONT_FILES) $(OMEGAFONT_FILES)

ROOT_DIR=..
include $(ROOT_DIR)/ivritex.mk

FONTS_TARGET_DIR=$(TEX_ROOT)/fonts
METAFONTS_TARGET_DIR=$(FONTS_TARGET_DIR)/source/hebrew

PACKAGE=hebfonts
VERSION=1.1a
TAR_BALL_DIR=$(PACKAGE)-$(VERSION)
TAR_BALL=$(TAR_BALL_DIR).tar.gz

do_install: $(PACKAGE_FILES_LIST)
	$(MKDIR) -p $(METAFONTS_TARGET_DIR)
	$(CP) $(METAFONT_FILES) $(METAFONTS_TARGET_DIR)
	for dir in $(OMEGA_SUBDIRS); do \
	  $(MKDIR) -p $(FONTS_TARGET_DIR)/$$dir/$(OMEGA_TARGET_SUBDIR) ; \
	  $(CP) $(OMEGA_SUBDIR)/$$dir/Omega* \
	    $(FONTS_TARGET_DIR)/$$dir/$(OMEGA_TARGET_SUBDIR) ; \
	done
#	cfgfile="`kpsewhich updmap`";                                     \
#	if [ -z "$${cfgfile}" ]; then                                     \
#	  cfgfile=`locate /updmap |grep ^/etc/texmf|head -n 1`;           \
#	fi;                                                               \
#	if [ -f "$${cfgfile}" ] ; then                                    \
#	  if ! grep -q 'ivritex/' $${cfgfile}; then                       \
#	    perl -p -i -e 'if (/^extra_modules/){$$_.= "ivritex/*.map\n"}' \
#	  fi ;                                                            \
#	  cd `dirname $${cfgfile}` && sh $${cfgfile};                     \
#	fi

do_uninstall:
#	cfgfile=`kpsewhich updmap`;                                       \
#	if [ -z "$${cfgfile}" ]; then                                     \
#	  cfgfile=`locate /updmap |grep ^/etc/texmf|head -n 1`;           \
#	fi;                                                               \
#	if [ -f "$${cfgfile}" ] ; then                                    \
#	  if grep -q 'ivritex/' $${cfgfile}; then                         \
#	    perl -p -i -e 'if (/ivritex\//){$$_ = ""}';                    \
#	  fi ;                                                            \
#	  cd `dirname $${cfgfile}` && sh $${cfgfile};                     \
#	fi


pack: $(TAR_BALL)

$(TAR_BALL): $(PACKAGE_FILES_LIST)
	if [ -e $(TAR_BALL_DIR) ] ; then \
	  $(RM) -rf $(TAR_BALL_DIR);     \
	fi
	mkdir $(TAR_BALL_DIR)
	
	# The following code is gnu-make specific. $(^D) is the directory
	# parts of $^ (all the dependencies)
	for dir in $(^D) ; do             \
          mkdir -p $(TAR_BALL_DIR)/$$dir; \
	done
	
	# copy the files
	for file in $^; do                  \
	  cp $$file $(TAR_BALL_DIR)/$$file; \
        done

	$(TAR) cvzf $(TAR_BALL) $(TAR_BALL_DIR)

