DOC = clement-s2r-dra821.tex

PICTURES = \
	common/logo-penguins.pdf \
	common/logo-square.pdf \
	common/bootlin-logo.pdf \
	graphics/sequence-j7200.pdf \
	graphics/s2r_j7200_suspend_sequence.pdf \
	graphics/s2r_j7200_resume_sequence.pdf \
	graphics/s2r_j7200_suspend_sequence-Linux.pdf \
	graphics/s2r_j7200_resume_sequence-Linux.pdf \
	graphics/s2r_j7200_suspend_sequence-TFA.pdf \
	graphics/s2r_j7200_resume_sequence-TFA.pdf \
	graphics/s2r_j7200_suspend_sequence-TFA2.pdf \
	graphics/s2r_j7200_resume_sequence-TFA2.pdf \
	graphics/s2r_j7200_suspend_sequence-DM.pdf \
	graphics/s2r_j7200_resume_sequence-DM.pdf \
	graphics/s2r_j7200_resume_sequence-SPL.pdf

INKSCAPE_IS_NEW = $(shell inkscape --version | grep -q "^Inkscape 1" && echo YES)

ifeq ($(INKSCAPE_IS_NEW),YES)
INKSCAPE_PDF_OPT = -o
else
INKSCAPE_PDF_OPT = -A
endif

XELATEX_OPT = -shell-escape

# '-8bit' or '--enable-8bit-chars' to avoid tab replaced by ^^I.
# Some web forum tells about '--enable-8bit-chars' instead of '-8bit' because
# '-8bit' seems not supported on all xelatex versions but '--enable-8bit-chars'
# is not supported by my xelatex ...
XELATEX_OPT_8BIT = $(shell xelatex --help | grep -q '^-8bit ' && echo y)
ifeq ($(XELATEX_OPT_8BIT),y)
XELATEX_OPT += -8bit
else
$(error Please check your xelatex supported option and update me ...)
endif

all: $(PICTURES)
	$(PDFLATEX_ENV) xelatex $(XELATEX_OPT) $(DOC)

%.svg: ../msc/%.signalling
	msc-gen $< -T svg -o $@


%.pdf: %.svg
	inkscape -D $(INKSCAPE_PDF_OPT) $@ $<

%.pdf: %.eps
	epstopdf --outfile=$@ $^

%.eps: %.dia
	dia -e $@ -t eps $^

clean:
	$(RM) -r common/*.pdf *.pdf *.pyg *.snm *.toc *.vrb *.aux *.nav *.out *.dia~ *.log _minted* $(PICTURES)
