#   Original by Oliver Fromme  <olli@fromme.com>
#   Extras for dual language & loads of other stuff by
#	 Julian H. Stacey <jhs @ berklix.org>
#
#   D: Makefile zum Erzeugen eines 3x2-Faltblattes.
#   E: Makefile to create a 3 x 2 folded leaflet
#   D: Siehe die Kommentare am Anfang von leaflet.tex.
#   E: See commentary at beginning of ...
#
#   D: Folgende Ports muessen installiert sein (in Klammern
#   D: die Version, mit der es getestet ist und funktioniert):
#   E: Following (FreeBSD) ports must be installed (in brackets
#   E: the version it was tested & functions with)
#
#	print/teTeX	     (teTeX-1.0.7)
#	print/ghostscript6   (ghostscript-6.50_6)
#		jhs used on FreeBSD-4.7:	print/ghostscript-gnu
#	print/psutils-a4     (psutils-a4-1.17_1)
#	print/dvips2ascii
#	textproc/ispell
#	german/ispell
#
#   E: You must also download, compile, install
#	http://www.berklix.com/jhs/src/bsd/jhs/bin/public/le/le.c
#
#   D: Um die PDF-Datei am Bildschirm anzusehen, wird eines
#     der folgenden beiden benoetigt:
#   E: To see the PDF on screen you'll need one of these.
#
#      print/gv 	    (gv-3.5.8)
#      print/acroread4	    (acroread4-4.05)
#
#   D: Ich empfehle acroread4, da es eine genauere Darstellung
#      bietet (und bei eingeschaltetem Antialias schneller ist).
#      gv nimmt bei der PDF-Datei ein falsches Format.
#   E: I reccomend acroread4, as it give a better presentation,
#      & is fater if antialias enabled
#      gv with PDF give wrong format
#
#   "make"		D: erzeugt alle Dateien.
#			E: Creates all files
#   "make clean"	D: loescht alle erzeugbaren Dateien.
#			E: Deletes all created files
#   "make view" 	D: zeigt die PDF/PS-Datei an (acroread4 / gv).
#			E: Displays the result
#

# .SUFFIXES: .pdf .txt .ps .dvi .tex .m4
# .SUFFIXES: .pdf .txt .dvi .tex .m4
# Now instead use rule in
# http://berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/jhs/share/mk/berklix2.mk

# .ps.pdf:
#	ps2pdf -sPAPERSIZE=a4 ${.IMPSRC} ${.TARGET}
# Now instead use rule in
# http://berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/jhs/share/mk/berklix2.mk

# .dvi.ps:
#	dvips -t landscape -o tmp.${.TARGET} ${.IMPSRC}
#	#	psselect 2,3,4,5,6,1 tmp.${.TARGET} tmp2.${.TARGET}
#	#psnup -w21cm -h29.7cm -W9.9cm -H21cm -s1 -3 tmp2.${.TARGET} ${.TARGET}
#	pstops -w21cm -h29.7cm "$(PSTOPS)" tmp.${.TARGET} ${.TARGET}
# Now instead use rule in
# http://berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/jhs/share/mk/berklix2.mk

# .tex.dvi:
#	latex ${.IMPSRC}
# Now instead use rule in
# http://berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/jhs/share/mk/berklix2.mk

# .ps.txt:
#	dvips2ascii < ${.IMPSRC} > ${.TARGET}
# Now instead use rule in
# http://berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/jhs/share/mk/berklix2.mk

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

# TARGS=	$(LL).english.ps $(LL).german.ps
#	TARGS=	$(LL).english.pdf $(LL).german.pdf $(LL).english.txt $(LL).german.txt

all:	links pdf # ${TARGS}

links:
	-for i in $(LL).english.m4 $(LL).german.m4 ;	\
		do	\
		if test ! -h $$i; then	\
			ln -s ${LL}.m4 $$i	;	\
		else	\
			echo Link already exists: $$i ; \
		fi ;	\
		ls -l $$i ;	\
		done

#	${LL}.english.tex:	${LL}.english.m4 Makefile
#		le -e ${LL}.english.m4			> ${.TARGET}
#		@# m4 -DENGLISH ${LL}.english.m4	> ${.TARGET}
#		@# m4 -DENGLISH ${.IMPSRC}		> ${.TARGET}
#		@# IMPSRC doesnt work for some reason.
#	${LL}.german.tex:	${LL}.german.m4 Makefile
#		le -g ${LL}.german.m4			> ${.TARGET}
#		@# m4 -DGERMAN ${LL}.german.m4		> ${.TARGET}
#		@# m4 -DGERMAN ${.IMPSRC}		> ${.TARGET}
#	
#	# clean:
#	#	@for i in aux dvi log pdf tex ; do	\
#	#		echo rm -f $(LL).english.$$i $(LL).german.$$i;	\
#	#	done |	\
#	#	sh -v
#	#	rm -f tmp.*.ps tmp2.*.ps
#	# Now instead use rule in
#	# http://berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/jhs/share/mk/berklix2.mk
#	
#	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).english.dvi $(LL).german.dvi
#		xdvi -paper 99x210mm ${.IMPSRC}
#	
#	viewps: gv viewps.e viewps.d
#	gv:
#		@if [ -x /usr/X11R6/bin/gv ]; then	\
#			;	\
#		elif [ -x /usr/local/bin/gs ]; then	\
#			;	\
#		else	\
#			echo "Please install /usr/ports/print/gv first.";	\
#		fi
#	
#	viewps.e: $(LL).english.ps
#		@if [ -x /usr/X11R6/bin/gv ]; then	\
#			gv -media a4 -antialias ${.IMPSRC};	\
#		elif [ -x /usr/local/bin/gs ]; then	\
#			gs -sPAPERSIZE=a4 $(LL).ps;	\
#		fi
#	viewps.g: $(LL).german.ps
#		@if [ -x /usr/X11R6/bin/gv ]; then	\
#			gv -media a4 -antialias ${.IMPSRC};	\
#		elif [ -x /usr/local/bin/gs ]; then	\
#			gs -sPAPERSIZE=a4 $(LL).ps;	\
#		fi
#	
#	viewpdf: acro viewpdf.e viewpdf.g
#	acro:
#		@if [ -x /usr/local/bin/acroread4 ]; then	\
#			;	\
#		elif [ -x /usr/X11R6/bin/gv ]; then	\
#			;	\
#		else	\
#			echo "Please install /usr/ports/print/acroread4 first."; \
#		fi
#	viewpdf.e: $(LL).english.pdf
#		@if [ -x /usr/local/bin/acroread4 ]; then	\
#			acroread4 ${.IMPSRC};	\
#		elif [ -x /usr/X11R6/bin/gv ]; then	\
#			gv ${.IMPSRC};	\
#		fi
#	viewpdf.g: $(LL).german.pdf
#		@if [ -x /usr/local/bin/acroread4 ]; then	\
#			acroread4 ${.IMPSRC};	\
#		elif [ -x /usr/X11R6/bin/gv ]; then	\
#			gv ${.IMPSRC};	\
#		fi
#	
#	# just run this occasionally to do spell checks.
#	spell:	spell.e spell.g
#	spell.e:	leaflet.english.txt
#		# Warning this is just to show errors, but you must edit
#		# leaflet.m4 not leaflet.english.txt
#		ispell leaflet.english.txt
#	spell.g:	leaflet.german.txt
#		# Warning this is just to show errors, but you must edit
#		# leaflet.m4 not leaflet.german.txt
#		ispell leaflet.german.txt

.include <berklix.mk>
