all:	GG.pdf GG.png;

GG.pdf:	GG.tex GG1.fig GG2.fig QRCode.png GGMarked.pdf figs/*.pstex figs/*.pstex_t \
		DemoPages.pdf \
		../../Projects/Killam-2017/Summary.pdf \
		../../Projects/Killam-2017/Detailed.pdf;
	fig2dev -L pstex GG1.fig GG1.pstex
	fig2dev -L pstex_t -p GG1.pstex GG1.fig GG1.pstex_t
	fig2dev -L pstex GG2.fig GG2.pstex
	fig2dev -L pstex_t -p GG2.pstex GG2.fig GG2.pstex_t
	latex GG.tex
	latex GG.tex
	dvips GG.dvi -t letter -o GG.ps
	ps2pdf GG.ps GG.pdf
#	cpdf -combine-pages GGMarked.pdf GG.pdf -o GG.pdf
	cpdf ../../Projects/Killam-2017/Summary.pdf ../../Projects/Killam-2017/Detailed.pdf -o Killam.pdf
	cpdf -crop "0.5in 0.5in 7.5in 10in" Killam.pdf -o Killam.pdf
	pdfnup Killam.pdf --nup 2x1 --outfile Killam.pdf
	cpdf -add-text "A research proposal I am now writing - I really mean what I write, so I may as well advertise it. Comments are welcome!" -topleft 15 Killam.pdf -o Killam.pdf
	cpdf -upright Killam.pdf -o Killam.pdf
	cpdf -rotateby 270 Killam.pdf -o Killam.pdf
	cpdf -scale-to-fit usletterlandscape Killam.pdf -o Killam.pdf
	cpdf GG.pdf DemoPages.pdf Killam.pdf -o GG.pdf
	rm -f GG.aux GG.dvi GG.log GG.ps GG?.pstex GG?.pstex_t GG.out GG?.fig.bak Killam.pdf

GG.png:	GG.pdf;
	convert -density 300 -scene 1 'GG.pdf[0-3]' -background white GG.png
	montage -geometry +0+0 -background white -tile 2x2 GG-1.png GG-2.png GG-3.png GG-4.png GG.png
	convert -geometry 800x800 -gamma 0.75 GG.png GG_800.jpg
	rm -f GG-?.png

QRCode.png:	;
	qrencode -o QRCode.png -s 1 -m 1 'drorbn.net/NCSU-1604'

GGBare.pdf:	GG.tex GG1Bare.fig GG2Bare.fig;
	fig2dev -L pstex GG1Bare.fig GG1.bare.pstex
	fig2dev -L pstex_t -p GG1.bare.pstex GG1Bare.fig GG1.bare.pstex_t
	fig2dev -L pstex GG2Bare.fig GG2.bare.pstex
	fig2dev -L pstex_t -p GG2.bare.pstex GG2Bare.fig GG2.bare.pstex_t
	sed sX\\\\def\\\\bare{n}X\\\\def\\\\bare{y}X GG.tex > GG.bare.tex
	latex GG.bare.tex
	latex GG.bare.tex
	dvips GG.bare.dvi -t letter -o GG.bare.ps
	ps2pdf GG.bare.ps GGBare.pdf
	rm -f *.bare.*

figs/%.pstex:	figs/%.fig;
	pstex_opts=`awk -F':' '/# pstex_opts/ {print $$2};' figs/$*.fig`;\
	echo $$pstex_opts ;\
	fig2dev -L pstex_t $$pstex_opts -p figs/$*.pstex \
		figs/$*.fig figs/$*.pstex_t ;\
	fig2dev -L pstex -g white $$pstex_opts figs/$*.fig figs/$*.pstex

figs/%.pstex_t: figs/%.pstex;

.PRECIOUS:	figs/%.fig;
figs/%.fig:	;
	cp -i ../empty.fig figs/$*.fig
	cp -i ../empty.pstex figs/$*.pstex
	cp -i ../empty.pstex_t figs/$*.pstex_t
