PDFFILES=fi-pdflatex.pdf fi-lualatex.pdf sci-pdflatex.pdf sci-lualatex.pdf \
	ped-pdflatex.pdf ped-lualatex.pdf med-pdflatex.pdf med-lualatex.pdf \
	fss-pdflatex.pdf fss-lualatex.pdf fsps-pdflatex.pdf fsps-lualatex.pdf \
	phil-pdflatex.pdf phil-lualatex.pdf law-pdflatex.pdf law-lualatex.pdf \
	econ-pdflatex.pdf econ-lualatex.pdf
OUTPUT=$(PDFFILES) $(PDFFILES:.pdf=.tex)

.PHONY: all clean
all: $(OUTPUT) clean

# This target extracts TeX files from within a DTX archive
# and removes the autogenerated preambles and postambles.
%-pdflatex.tex %-lualatex.tex: %.ins example.dtx
	xetex $<
	sed -ni '/^%\{3,\}/,/^\\end{document}/p' \
		$(patsubst %-pdflatex.tex,%-,$(subst lua,pdf,$@))*.tex

# This target typesets a pdfLaTeX example.
%-pdflatex.pdf: %-pdflatex.tex
	pdflatex $<
	pdflatex $<

# This target typesets a LuaLaTeX example.
%-lualatex.pdf: %-lualatex.tex
	lualatex $<
	lualatex $<

# This target removes any auxiliary files.
clean:
	rm -f *.aux *.log *.nav *.out *.snm *.toc

# This target removes any auxiliary files
# and the output PDF files.
implode: clean
	rm -f $(OUTPUT)
