# Uses pdfjoin from the pdfjam package

NAME=aapnestandarder

all: folder-$(NAME).pdf
folder-$(NAME).pdf: folder-$(NAME)-side1.pdf folder-$(NAME)-side2.pdf
	pdfjoin --outfile $@ $^
	pdf90 --outfile $@.1.pdf $@
	pdf90 --outfile $@.2.pdf $@.1.pdf
	pdf90 --outfile $@.1.pdf $@.2.pdf
	mv $@.1.pdf $@
	rm $^ $@.2.pdf

.svg.pdf:
	inkscape -z -p '| gs -q -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfwrite -sPAPERSIZE=a4 "-sOutputFile=$@" -' $^


# Proposed build rule from Karl Ove Hufthammer (RT #465).  The --export-embed-fonts argument
# is missing in inkscape v0.44.1, and when generated without it the æøå letters are missing.
# There is also some strange placement problems with the text.
INKSCAPEOPTS=-z # --export-embed-fonts
.svg.ps:
	inkscape $(INKSCAPEOPTS) --export-ps=$@ $^
alternative: folder-$(NAME)-side1.ps folder-$(NAME)-side2.ps
	gs -q -dBATCH -sPAPERSIZE=a4 -dAutoRotatePages=/All -dNOPAUSE -dSAFER \
		-dPDFSETTINGS=/prepress -sDEVICE=pdfwrite -sPAPERSIZE=a4 \
		-sOutputFile=folder-$(NAME).pdf $^
	rm $^

.SUFFIXES: .svg .pdf .ps
