# users of this file: define MAIN, and SEM like this
# SEM = ws03
# MAIN = compilerbau

REMOTE = kain.imn.htwk-leipzig.de
WWW = $(HOME)/public_html/edu/$(SEM)/$(MAIN)/folien

TARGETS = main.pdf main.8.pdf folien.pdf skript.pdf

ifndef DVIPSOPTS
DVIPSOPTS = -t landscape
endif

ifndef L2HOPTS
L2HOPTS = -html_version 4.0,math,table,latin1,unicode
endif

all : $(TARGETS)

.PHONY : *.tex

%.dvi : %.tex
	- TEXINPUTS=$(TEXINPUTS) latex "\\nonstopmode\\input $<"

%.ps : %.dvi
	dvips $(DVIPSOPTS) $< -o $@

%.pdf : %.tex
	- TEXINPUTS=$(TEXINPUTS) pdflatex "\\nonstopmode\\input $<"
	- TEXINPUTS=$(TEXINPUTS) pdflatex "\\nonstopmode\\input $<"

# %.pdf : %.ps
#	ps2pdf $< 

# %.ps : %.pdf
#	pdftops $< $@

%.8.ps : %.ps
	psnup -s0.33 -8 -l $< $@

%.8.pdf : %.pdf
	pdfjam --nup 2x4 --frame true --noautoscale false --delta '0.2cm 0.3cm' --scale 0.95 $< -o $@


# NOTE: typically needs .latex2html-init file in working dir
# to get the proper TEXINPUTS setting

www : $(TARGETS)
	TEXINPUTS=$(TEXINPUTS) latex2html $(L2HOPTS) main
	rsync -varuz . $(REMOTE):$(WWW)
	# scp -rv . $(REMOTE):$(WWW)
