 # $Id$
 #
 # This file is part of the RHexLib Robot Control Software
 #
 #  The contents of this file are subject to the RHexLib Public
 # License Version 2.0 (the "License"); you may not use this file
 # except in compliance with the License. To obtain a copy of the
 # License, please contact <ulucs+rhexlib@cs.cmu.edu>.
 #
 #  Software distributed under the License is distributed on an "AS
 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 # implied. See the License for the specific language governing
 # rights and limitations under the License.
 #
 #  The Original Code is RHexLib Robot Control Software.
 #
 #  The Initial Developer of the Original Code is
 #    The Regents of the University of Michigan.
 #
 #  Portions created by 
 #    Regents of the University of Michigan
 # are Copyright (C) 2003.  All Rights Reserved.
 #
 #  Contributor(s): Uluc Saranli.
 #
 #  Alternatively, the contents of this file may be used under the
 # terms of the GNU Public license (the "GPL License"), in which
 # case the provisions of the GNU Public License are applicable
 # instead of those above.  If you wish to allow use of your version
 # of this file only under the terms of the GPL License and not to
 # allow others to use your version of this file under the RHexLib
 # Public License, indicate your decision by deleting the provisions
 # above and replace them with the notice and other provisions
 # required by the GPL License.  If you do not delete the provisions
 # above, a recipient may use your version of this file under either
 # the RHexLib Public License or the GPL License."
 #
 # Uluc Saranli <ulucs+rhexlib@cs.cmu.edu>

 ######################################################################
 # $Id$
 #
 # The Makefile for the Module Manager
 #
 # Created       : Uluc Saranli, 07/12/2001
 # Last Modified : Uluc Saranli, 07/12/2001
 #
 ######################################################################

 # ***********************************************************
 # ** This Makefile was originally created by Richard Groff **
 # ***********************************************************
 #
 # - By convention, we have a main tex file $(FILE).tex, from which 
 # various sections of the manual are input.  
 #
 # - "make spell" will run "ispell -t" on # $(FILE).tex and on all files
 # inputed in $(FILE).tex which have the .tex suffix explicitly
 # written out.
 #
 # - In latex, \input{file.tex} and \input{file} will both input the
 # file.tex, but only the first will cause "make spell" to spell check
 # file.tex.  Thus, we input files I don't want to spell check, such as
 # macros, with \input{file}, but sections of papers with
 # \input{file.tex}
 #
 # - The TITLE variable provides the name for the generated postscript file
 # - The GRAPHICSDIR variable should be a : separated list of directories to 
 # search for latex files
 # - DVIVIEW and DVIPS specify the preferences for the dvi viewer and
 # dvi-postscript conversion, respectively.

TITLE   = RHexManual
FILE	= body
TEXINPUTS = 

# commands
RM  = rm
LATEX = latex
BIBTEX = bibtex
MAKEINDEX = makeindex
DVIPS = dvips -t letter
DVIVIEW = xdvi -p 600 -s 8 -k
DISTILL = distill
#

all:
	@echo "Usage for Latex make file:"
	@echo "make dvi   --   run latex on $(FILE).tex, produce $(FILE).dvi"
	@echo "make full  --   run latex, bibtex, latex, latex on $(FILE).tex"
	@echo "make ps    --   Do 'make full' on $(FILE).tex and then 'dvips'"
	@echo "                to produce $(TITLE).ps"
	@echo "make view  --   start the dvi viewer, \"$(DVIVIEW)\" to look"
	@echo "                at $(FILE).dvi" 
	@echo "make spell --   run 'ispell -t' on $(FILE).tex and all *.tex"
	@echo "                files \\input-ed from $(FILE).tex" 
	@echo "make bib   --   run bibtex on $(FILE).tex"
	@echo "make clean --   remove all temp files"

dvi:
	sh -c '\
	       export TEXINPUTS=.:$(TEXINPUTS):      ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex   '

bib:
	bibtex $(FILE)

full:
	sh -c '\
	       export TEXINPUTS=.:$(TEXINPUTS):       ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; \
	       $(BIBTEX) $(FILE)                          ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; \
	       $(MAKEINDEX) $(FILE)                       ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; '


ps:
	sh -c '\
	       export TEXINPUTS=.:$(TEXINPUTS):       ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; \
	       $(BIBTEX) $(FILE)                          ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; \
	       $(MAKEINDEX) $(FILE)                       ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; \
	       $(DVIPS) -o $(TITLE).ps $(FILE).dvi       ; '
	@echo Wrote file $(TITLE).ps  

pdf:
	sh -c '\
	       export TEXINPUTS=.:$(TEXINPUTS):       ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; \
	       $(BIBTEX) $(FILE)                          ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; \
	       $(MAKEINDEX) $(FILE)                       ; \
	       $(LATEX) \\nonstopmode\\input $(FILE).tex  ; \
	       $(DVIPS) -Ppdf -o $(TITLE)_pdf.ps $(FILE).dvi       ; '
	@echo Wrote file $(TITLE)_pdf.ps
	$(DISTILL) $(TITLE)_pdf.ps $(TITLE).pdf  

$(FILE).dvi: 
	make full

clean:
	@$(RM) *%  *~ *.dvi *.idx *.aux *.bbl *.blg *.ilg *.ind *.lof *.log *.lot *.lof *.toc *.loa 2> /dev/null ; true 

realclean:
	@$(RM) *%  *~ *.dvi $(TITLE).ps $(TITLE)_pdf.ps *.idx *.aux *.bbl *.blg *.ilg *.ind *.lof *.log *.lot *.lof *.toc *.loa 2> /dev/null ; true 

view: $(FILE).dvi
	sh -c '\
	       export TEXINPUTS=.:$(TEXINPUTS):      ; \
	       $(DVIVIEW) $(FILE).dvi &'	

spell:
	ispell -t $(FILE).tex `grep '\.tex' $(FILE).tex | sed 's/.*\\input{\(.*\)\.tex}/\1.tex/'`










