Simple Makefile to Compile Latex Document

Below is a simple Makefile that I usually use to compile latex document.

# Makefile to compile latex document
# write the name of your main latex file here (without suffix .tex)
project=

tex=pdflatex
bibtex=bibtex
buildtex=$(tex) $(project).tex

all:
    $(buildtex)
    $(bibtex) $(project) || true
    $(buildtex)
    $(buildtex)

clean-all:
    rm -f *.dvi *.log *.bak *.aux *.bbl *.blg *.idx *.ps *.eps *.pdf *.toc *.out *~

clean:
    rm -f *.log *.bak *.aux *.bbl *.blg *.idx *.toc *.out *~

Just run make to compile and generate pdf file. Then run make clean to clean up all unnecessary files. Alternatively, you can do both things at the same time by running make; make clean

Thanks to: Daniel Kaes

Comments !