# JLdL 24Jun02.
#	Copyright (C) 2000-2002 by Jorge L. deLyra.
# Mail: <delyra@latt.if.usp.br>. Web: "http://latt.if.usp.br".
# Este programa pode ser copiado e/ou distribuído livremente.
# Ver os termos e condições nos arquivos do sub-diretório web/.
# This program may be copied and/or distributed freely. See the
# _ terms and conditions in the files in the web/ subdirectory.
#
# Makefile for the FMA215 course material.

#
# A symbol for this makefile and all its includes.
MFI = \
Makefile \
DefinePS \
DefineDVI \
DefineHTML \
DefineWPS \
DefineWHTML \
DefineRULES \
DefineDEPS

#
# Symbols for extra dependencies.
DEP01 =
DEP02 =
DEP03 = lista-verbatim01.tex
DEP04 = lista-verbatim01.tex
DEP05 =
DEP06 =
DEP07 =
DEP08 = aula-08-tabular01.tex
DEP09 = aula-09.TeX \
        aula-09-verbatim01.tex aula-09-verbatim02.tex \
        aula-09-verbatim03.tex aula-09-verbatim04.tex \
        aula-09-verbatim05.tex aula-09-verbatim06.tex \
        aula-09-verbatim07.tex aula-09-verbatim08.tex \
        aula-09-verbatim09.tex aula-09-verbatim10.tex \
        aula-09-verbatim11.tex aula-09-verbatim12.tex \
        aula-09-verbatim13.tex
DEP10 = aula-10-verbatim01.tex aula-10-verbatim02.tex
DEP11 = aula-11-verbatim01.tex aula-11-verbatim02.tex \
        aula-11-verbatim03.tex aula-11-verbatim04.tex \
        aula-11-verbatim05.tex aula-11-verbatim06.tex \
        aula-11-verbatim07.tex aula-11-verbatim08.tex \
        aula-11-verbatim09.tex aula-11-verbatim10.tex \
        aula-11-verbatim11.tex aula-11-verbatim12.tex \
        aula-11-verbatim13.tex aula-11-verbatim14.tex \
        aula-11-verbatim15.tex
DEP12 = aula-12-verbatim01.tex aula-12-verbatim02.tex \
        aula-12-verbatim03.tex aula-12-verbatim04.tex \
        aula-12-verbatim05.tex aula-12-verbatim06.tex \
        aula-12-verbatim07.tex aula-12-verbatim08.tex \
        aula-12-verbatim09.tex aula-12-verbatim10.tex \
        aula-12-verbatim11.tex
DEP13 = aula-13-verbatim01.tex aula-13-verbatim02.tex \
        aula-13-verbatim03.tex aula-13-verbatim04.tex \
        aula-13-verbatim05.tex aula-13-verbatim06.tex \
        aula-13-verbatim07.tex aula-13-verbatim08.tex \
        aula-13-verbatim09.tex aula-13-verbatim10.tex \
        aula-13-verbatim11.tex aula-13-verbatim12.tex \
        aula-13-verbatim13.tex
DEP14 = 
DEP15 = 
DEP16 = aula-16-verbatim01.tex aula-16-verbatim02.tex \
        aula-16-verbatim03.tex aula-16-verbatim04.tex \
        aula-16-verbatim05.tex aula-16-verbatim06.tex \
        aula-16-verbatim07.tex aula-16-verbatim08.tex \
        aula-16-verbatim09.tex aula-16-verbatim10.tex \
        aula-16-verbatim11.tex aula-16-verbatim12.tex

#
# Symbol for the web-area directory.
W = /var/www/fma215
A = $(W)/apostilas

#
# Symbol for all the local PS files.
include DefinePS

#
# Symbol for all the local DVI files.
include DefineDVI

#
# Symbol for all the local HTML files.
include DefineHTML

#
# Symbol for all the web-area PS files.
include DefineWPS

#
# Symbol for all the web-area HTML files.
include DefineWHTML

#
# The default target: everything but the web area.
all: ps dvi html

#
# Rule for making the book form.
curso.tex: $(DVI) curso-doit
	./curso-doit

#
# Target for all the PS files.
ps: $(PS)

#
# Target for all the DVI files.
dvi: $(DVI)

#
# Target for all the HTML files.
html: $(HTML)

#
# Target for the web area.
web: $(WPS) $(WHTML) tar Index GPL

#
# Target for the index file.
Index: $(A)/Index_port.html $(A)/observacoes.html $(W)/topicos.html

#
# Target for the GPL license.
GPL: $(A)/GPL_engl.html $(A)/GPL_port.html

#
# Define the "tar" target and its rules.
include DefineRULES

#
# Define some extra dependencies.
include DefineDEPS

#
# Clean it up.
clean:
	rm -f *~ *.aux *.log *.toc *.lof *.lot *.idx

#
# Really clean it up.
veryclean: clean
	rm -f $(PS) $(DVI) $(HTML)

#
# Really clean it _all_ up.
verycleanindeed: veryclean
	rm -f $(WPS) $(WHTML) aula-??/*

#
# Make the macro and dependency files.
dep: PS DVI HTML WPS WHTML DEPS RULES

#
# Rule for refreshing the PS macro file.
PS:
	aulas=`ls aula-??.tex | cut -d. -f1 | tail +2` ; \
	echo "PS = \\" > Define$@ ; \
	for aula in $$aulas ; do \
		echo "$$aula.ps \\"       >> Define$@ ; \
	done

#
# Rule for refreshing the DVI macro file.
DVI:
	aulas=`ls aula-??.tex | cut -d. -f1 | tail +2` ; \
	echo "DVI = \\" > Define$@ ; \
	for aula in $$aulas ; do \
		echo "$$aula.dvi \\"       >> Define$@ ; \
	done

#
# Rule for refreshing the DVI macro file.
HTML:
	aulas=`ls aula-??.tex | cut -d. -f1 | tail +2` ; \
	echo "HTML = \\" > Define$@ ; \
	for aula in $$aulas ; do \
		echo "$$aula/index.html \\"       >> Define$@ ; \
	done

#
# Rule for refreshing the WPS macro file.
WPS:
	aulas=`ls aula-??.tex | cut -d. -f1 | tail +2` ; \
	echo "WPS = \\" > Define$@ ; \
	for aula in $$aulas ; do \
		echo '$$'"(A)/$$aula.ps \\"       >> Define$@ ; \
	done

#
# Rule for refreshing the WHTML macro file.
WHTML:
	aulas=`ls aula-??.tex | cut -d. -f1 | tail +2` ; \
	echo "WHTML = \\" > Define$@ ; \
	for aula in $$aulas ; do \
		echo '$$'"(A)/$$aula/index.html \\"       >> Define$@ ; \
	done

#
# Rule for refreshing the extra dependencies file.
DEPS:
	digs=`ls aula-??.tex | cut -d. -f1 | cut -d- -f2 | tail +2` ; \
	cat /dev/null > Define$@ ; \
	for dig in $$digs ; do \
		echo "aula-$$dig.dvi: "'$$'"(DEP$$dig)" >> Define$@ ; \
	done

#
# Rule for refreshing the rules file.
RULES:
	digs=`ls aula-??.tex | cut -d. -f1 | cut -d- -f2 | tail +2` ; \
	echo tar: > Define$@ ; \
	for dig in $$digs ; do \
		echo -n "	tar -czhvf "'$$'"(A)/aula-"	>> Define$@ ;\
		echo -n "$$dig.tgz aula-$$dig.tex "		>> Define$@ ;\
		echo    '$$'"(MFI) "'$$'"(DEP$$dig)"		>> Define$@ ;\
	done

#
# Special rule for aula-09, to avoid trouble with latex2html.
aula-09.tex: aula-09.TeX
	cat $< | sed -e 's/|[^|]*|/\\verb&/g' | \
	sed -e 's/\\MakeShortVerb{\\|}//g' > $@

#
# Special rule for a file in the main web area.
$(W)/topicos.html: web/topicos.html
	cp -f $< $@

#
# Pattern rule for HTML files in the web area.
$(A)/%.html: web/%.html
	cp -f $< $@

#
# Pattern rule for making DVI files out of LaTeX files.
%.dvi: %.tex
	Latex $<

#
# Pattern rule for making PS files out of DVI files.
%.ps: %.dvi
	dvips -o $@ $<

#
# Pattern rule for making HTML files out of DVI files.
%/index.html: %.dvi
	latex2html -up_url ../ -up_title "Up" $*

#
# Pattern rule for making the web-area PS files.
$(A)/%.ps: %.ps
	cp -f $< $@
#
# Pattern rule for making the web-area HTML files.
$(A)/%/index.html: %/index.html
	tar -cpf - $* | tar -C $(A)/ -xpvf -

