# For UNIX systems
# Usage:
# make <file name(s) with the .dvi suffix (source is .s or .itx)>
#---------------------------------------------------
# Suggested usage:
# Copy this makefile.unx to makefile, edit it as required, and then:
#	cd to the directory containing the .s or .itx file,
#	cd hindi/0
#		then run:
#	make -f ../../makefile 1.ps
#		or
#	make -f ../makefile bhagvad.ps
#		etc....
#
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#									%
# The following is for archiver's purposes only:		   	%
# When doing a distribution release, need to use makefile.dist.		%
# Use the following procedure:						%
#									%
# 1. Edit makefile.unx (this file) to make sure that we are only doing	%
# ITRANS, latex, and then dvips.  All other actions should be commented	%
# out.  This means that the dvips is uncommented and that the lines	%
#       #gs $*.ps							%
#       #-$(RM) $*.ps							%
# are properly commented out in the .s.ps section and that the line	%
#       #-$(RM) $*.ps							%
# 2. Edit isitx.hdr appropriately for ftp or www distribution		%
#    is commented out in the .itx.ps and the .tex.ps sections.		%
# 3. make -f makefile.dist						%
#                 	 						%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#
# Edit this file as required, to point to the files on your system.
#
.SUFFIXES: .s .itx .ips .tex .dvi .ps .c # needed on SGI machines atleast

# Edit the following according to your ITRANS setup.  Right now it is
# set up for my machine (chandra).  
#
SHELL=/bin/sh
ITHOME=$(HOME)/ITRANS
ITRANS=$(ITHOME)/src/itrans
ISHDR=$(ITHOME)/isongs/isitx.hdr
ISONGCAT=$(ITHOME)/isongs/isongcat

#----
# Be sure to set your environment variable ITRANSPATH correctly.
# ITRANSPATH should contain a list of directories where ITRANS can find
# the *.ifm files (dvng_is.ifm, etc)
# My ITRANSPATH is set to:
# ITRANSPATH=.:$HOME/ITRANS/lib:$HOME/ITRANS/devnag:$HOME/ITRANS/isongs
#----
# Another important environemnt variable is TEXINPUTS -- TeX/LaTeX uses
# it to locate all its input files, and in this case, it needs to find
# idevn.tex, so make sure TEXINPUTS contains the name of the directory
# where idevn.tex can be found.
#----

RM=/bin/rm

# -----------------------------------------------------------------
# not used, direct PostScript mode is not possible from version 1.3 onwards..
# IPSFILES= $(HOME)/ITRANS/lib/devnac.ps $(HOME)/ITRANS/lib/itrans.pro
# -----------------------------------------------------------
# Rules to convert a .s file to .itx to .tex to .dvi to .ps
# Note that the rules delete all the temporary files---
# I directly send the output file to the printer or the screen---
# modify these lines as required, if you need to look at the temp files.

.s.ps:
	cat $(ISHDR) $*.s > $*.itx
	echo "\\end{document}" >> $*.itx
	$(ITRANS) -i $*.itx -o $*.tex
	-$(RM) $*.itx
	latex $*
	-$(RM) $*.tex
	-$(RM) $*.log
	-$(RM) $*.aux
	xdvi $*
	#dvips $* -o $*.ps
	-$(RM) $*.dvi
	gs $*.ps
	#xpsview $*.ps
	#lp $*.ps
	-$(RM) $*.ps

.itx.ps:
	$(ITRANS) -i $*.itx -o $*.tex
	latex $*
	-$(RM) $*.tex
	-$(RM) $*.log
	-$(RM) $*.aux
	xdvi $*
	#dvips $* -o $*.ps
	-$(RM) $*.dvi
	#xpsview $*.ps
	#lp $*.ps
	#-$(RM) $*.ps

.tex.ps:
	latex $*
	-$(RM) $*.log
	-$(RM) $*.aux
	xdvi $*
	#dvips $* -o $*.ps
	-$(RM) $*.dvi
	#xpsview $*.ps
	#lp $*.ps
	#-$(RM) $*.ps

# -----------------------------------------------------------
# Rules to convert a .s file to .ips to .ps
# To get these rules to activate, move them to the beginning of this file.
#***
# not used, direct PostScript mode is not possible from version 1.3 onwards..
#***

.s.ips:
	cat isips.hdr $*.s > $*.ips
	$(ITRANS) -P -i $*.ips -o tmp.ps
	-$(RM) $*.ips
	cat $(IPSFILES) tmp.ps > $*.ps
	@$(RM) tmp.ps
	#xpsview $*.ps
	#lp $*.ps
	#$(RM) $*.ps

# -----------------------------------------------------------
# Targets

help:
	@echo Type "make [filename].ps" to convert a .s or .itx or .tex file
	@echo      The above will create a .dvi file and .ps file,
	@echo      depending on how you have edited this makefile.
	@echo ----------------

#  make filename.ips not supported...
#	@echo Type "make [filename].ips" to create a .ips file from a song.
#	@echo      The above will also create a .ps file for printing,
#	@echo      depending on how you have edited this makefile.
#	@echo      NOTE: see isips.hdr on changes that may be necessary to
#	@echo      print songs in .ips files.

# allsongs file creation --- first run "make allsongs.s", and then
# run "make allsongs.dvi" to create the dvi file containing all the
# songs in a single file - isongcat is used here, so that multiple songs
# can fit on a single page.

# allsongs file creation --- first run "make allsongs", and then
# run "make h100-199.dvi", etc to create the dvi file containing all the
# songs in a single file - isongcat is used here, so that multiple songs
# can fit on a single page.
# To make allsongs, you must be in the hindi directory, so the command
# is: make -f ../makefile allsongs

allsongs:
	$(ISONGCAT)   1  99 > h001-099.s
	$(ISONGCAT) 100 199 > h100-199.s
	$(ISONGCAT) 200 299 > h200-299.s
	$(ISONGCAT) 300 399 > h300-399.s
	$(ISONGCAT) 400 499 > h400-499.s
	$(ISONGCAT) 500 599 > h500-599.s
	$(ISONGCAT) 600 699 > h600-699.s
	$(ISONGCAT) 700 799 > h700-799.s

isongcat: isongcat.c
	$(CC) -o isongcat isongcat.c
