tueda / makefile4latex

A GNU Makefile for typesetting LaTeX documents.
MIT License
26 stars 3 forks source link

Placing *-eps-converted-to.pdf into BUILDDIR #29

Closed tueda closed 3 years ago

tueda commented 3 years ago

For EPS files, pdflatex performs automatic epstopdf conversion and generates *-eps-converted-to.pdf files in the current working directory. It would be nice if they could be put in BUILDDIR.

tueda commented 3 years ago

The following seems to work, at least on Linux:

export TEXINPUTS := .:$(BUILDDIR):$(TEXINPUTS):

.tex.pdf:
    @$(init_toolchain)
    @$(call switch,$(typeset_mode), \
        dvips, \
            $(call typeset,$(latex)) && \
            $(call exec,$(dvips) $(build_prefix)$*.dvi -o $(build_prefix)$*.ps) && \
            $(call exec,$(ps2pdf) $(build_prefix)$*.ps), \
        dvips_convbkmk, \
            $(call typeset,$(latex)) && \
            $(call exec,$(dvips) $(build_prefix)$*.dvi -o $(build_prefix)$*.ps) && \
            $(call exec,$(convbkmk) $(build_prefix)$*.ps) && \
            mv $(build_prefix)$*-convbkmk.ps $(build_prefix)$*.ps && \
            $(call exec,$(ps2pdf) $(build_prefix)$*.ps), \
        dvipdf, \
            $(call typeset,$(latex)) && \
            $(call exec,$(dvipdf) $(build_prefix)$*.dvi), \
        pdflatex, \
            $(call typeset,$(latex)) && \
            $(mv_target) && \
            $(mv_eps_converted_to_pdf), \
    )

mv_eps_converted_to_pdf = $(if $(BUILDDIR),{ mv *-eps-converted-to.pdf $(BUILDDIR) >/dev/null 2>&1 || :; },:)