#	$NetBSD: Makefile,v 1.12 2005/11/05 21:28:09 mishka Exp $

XMLDOCS+=	index

#
#   Oliver Fromme  <olli@fromme.com>
#
#   Makefile zum Erzeugen eines 3x2-Faltblattes.
#   Siehe die Kommentare am Anfang von leaflet.tex.
#
#   Folgende Ports muessen installiert sein (in Klammern
#   die Version, mit der es getestet ist und funktioniert):
#
#      print/teTeX          (teTeX-1.0.7)
#      print/ghostscript6   (ghostscript-6.50_6)
#      print/psutils-a4     (psutils-a4-1.17_1)
#
#   Um die PDF-Datei am Bildschirm anzusehen, wird eines
#   der folgenden beiden benoetigt:
#
#      print/gv             (gv-3.5.8)
#      print/acroread4      (acroread4-4.05)
#
#   Ich empfehle acroread4, da es eine genauere Darstellung
#   bietet (und bei eingeschaltetem Antialias schneller ist).
#   gv nimmt bei der PDF-Datei ein falsches Format.
#
#   "make"        erzeugt alle Dateien.
#   "make clean"  loescht alle erzeugbaren Dateien.
#   "make view"   zeigt die PDF/PS-Datei an (acroread4 / gv).
#

#LL=leaflet
#LL=depliant
LL=flyer
PSTOPS_FRNT=1L(1h,0.000000w)+2L(1h,0.333333w)+3L(1h,0.666667w)
PSTOPS_BACK=4R(0h,1.000000w)+5R(0h,0.666667w)+0R(0h,0.333333w)
PSTOPS=6:$(PSTOPS_FRNT),$(PSTOPS_BACK)

.SUFFIXES=	.tex .dvi .ps .pdf

all:	flyer.pdf flyer-a4.pdf flugblatt.pdf depliant.pdf ruflyer.pdf \
	flyer.ps.gz flyer-a4.ps.gz flugblatt.ps.gz depliant.ps.gz ruflyer.ps.gz

#####

flyer.pdf: flyer.ps
	ps2pdf -sPAPERSIZE=letter flyer.ps flyer.pdf

flyer-a4.pdf: flyer-a4.ps
	ps2pdf -sPAPERSIZE=a4 flyer-a4.ps flyer-a4.pdf

flugblatt.pdf: flugblatt.ps
	ps2pdf -sPAPERSIZE=a4 flugblatt.ps flugblatt.pdf

depliant.pdf: depliant.ps
	ps2pdf -sPAPERSIZE=a4 depliant.ps depliant.pdf

ruflyer.pdf: ruflyer.ps
	ps2pdf -sPAPERSIZE=a4 ruflyer.ps ruflyer.pdf

flyer.ps: flyer.dvi
	dvips -o flyer.tmp.ps flyer.dvi
	pstops -w11in -h8.5in "$(PSTOPS)" flyer.tmp.ps flyer.ps

flyer-a4.ps: flyer.dvi
	dvips -o flyer-a4.tmp.ps flyer.dvi
	pstops -w29.7cm -h21cm "$(PSTOPS)" flyer-a4.tmp.ps flyer-a4.ps

depliant.ps: depliant.dvi
	dvips -t landscape -o depliant.tmp.ps depliant.dvi
	#	psselect 2,3,4,5,6,1 $(LL).tmp.ps $(LL).tmp2.ps
	#psnup -w21cm -h29.7cm -W9.9cm -H21cm -s1 -3 $(LL).tmp2.ps $(LL).ps
	pstops -w29.7cm -h21cm "$(PSTOPS)" depliant.tmp.ps depliant.ps

flugblatt.ps: flugblatt.dvi
	dvips -t landscape -o flugblatt.tmp.ps flugblatt.dvi
	#	psselect 2,3,4,5,6,1 $(LL).tmp.ps $(LL).tmp2.ps
	#psnup -w21cm -h29.7cm -W9.9cm -H21cm -s1 -3 $(LL).tmp2.ps $(LL).ps
	pstops -w29.7cm -h21cm "$(PSTOPS)" flugblatt.tmp.ps flugblatt.ps

ruflyer.ps: ruflyer.dvi
	dvips -o ruflyer.tmp.ps ruflyer.dvi
	pstops -w29.7cm -h21cm "$(PSTOPS)" ruflyer.tmp.ps ruflyer.ps

flugblatt.dvi: flugblatt.tex netbsd.ps
	latex flugblatt.tex

flyer.dvi: flyer.tex netbsd.ps
	latex flyer.tex

depliant.dvi: depliant.tex netbsd.ps
	latex depliant.tex

ruflyer.dvi: ruflyer.tex netbsd.ps
	latex ruflyer.tex

.for fn in flyer flyer-a4 depliant flugblatt ruflyer
${fn}.ps.gz: ${fn}.ps
	gzip -c ${fn}.ps > ${fn}.ps.gz
.endfor

#####

# unpack the logo graphic
netbsd.ps: netbsd.ps.gz
	gzip -cd netbsd.ps.gz >netbsd.ps

# PAPERSIZE={a4,letter}
# IN={flyer,flugblatt,depliant}.ps
fixps:
	gs -dNOPAUSE -dBATCH \
		-sPAPERSIZE=${PAPERSIZE} \
		-sDEVICE=pswrite \
		-sOutputFile=_fixed.ps ${IN}
	mv _fixed.ps ${IN}

view:
	@if [ -x /usr/local/bin/acroread4 ]; then 	\
		$(MAKE) viewpdf;			\
	elif [ -x /usr/X11R6/bin/gv ]; then 		\
		$(MAKE) viewps;				\
	else						\
		echo "Please install /usr/ports/print/acroread4 first.";  \
	fi

viewdvi: $(LL).dvi
	xdvi -paper 99x210mm $(LL).dvi

viewps: $(LL).ps
	@if [ -x /usr/X11R6/bin/gv ]; then 	\
		echo "gv $(LL).ps";		\
		gv -media a4 -antialias $(LL).ps;			\
	elif [ -x /usr/local/bin/gs ]; then	\
		echo "gs $(LL).ps";		\
		gs -sPAPERSIZE=a4 $(LL).ps;			\
	else					\
		echo "Please install /usr/ports/print/gv first.";	\
	fi

viewpdf: $(LL).pdf
	@if [ -x /usr/local/bin/acroread4 ]; then 	\
		echo "acroread4 $(LL).pdf";		\
		acroread4 $(LL).pdf;			\
	elif [ -x /usr/X11R6/bin/gv ]; then		\
		echo "gv $(LL).pdf";			\
		gv $(LL).pdf;				\
	else						\
		echo "Please install /usr/ports/print/acroread4 first.";  \
	fi

.for i in aux dvi log pdf ps tmp.ps ps.gz
CLEANFILES+=	flugblatt.$i flyer.$i depliant.$i flyer-a4.$i ruflyer.$i
.endfor
CLEANFILES+=	netbsd.ps

.include "../../share/mk/web.site.mk"
