Skip to content

Instantly share code, notes, and snippets.

@crazyboycjr
Last active January 4, 2020 08:40
Show Gist options
  • Save crazyboycjr/2d1f300232d8434643578e6975dcb048 to your computer and use it in GitHub Desktop.
Save crazyboycjr/2d1f300232d8434643578e6975dcb048 to your computer and use it in GitHub Desktop.
A Makefile for LaTex
.PHONY: all clean dist print
M = sop
P = $M
default : $P.pdf
$P.dvi : $(wildcard *.tex *.bib figs/*.eps)
latex $P < /dev/null || $(RM) $@
bibtex $P < /dev/null || $(RM) $@
latex $P < /dev/null || $(RM) $@
latex $P < /dev/null || $(RM) $@
$P.pdf : $(wildcard *.tex *.bib figs/*)
xelatex --shell-escape -jobname=$P $M
echo '\citation{}' >> $M.aux
bibtex $M
xelatex --shell-escape -jobname=$P $M
xelatex --shell-escape -jobname=$P $M
$P.ps : $P.dvi
dvips -tletter -Ppdf $P.dvi -o $P.ps
$P.ps.gz: $P.ps
$(RM) $P.ps.gz
gzip -9 < $P.ps > $P.ps.gz
print: $P.ps
dist: $P.ps.gz
clean:
$(RM) $P.log $P.aux $P.bbl $P.blg $P.out $P.dvi $P.ps $P.ps.gz texput.log
PACKAGE = main
PDF = ${PACKAGE}.pdf
all: ${PDF}
%.pdf: %.tex
xelatex $<
- bibtex $*
xelatex $<
xelatex $<
while ( grep -q '^LaTeX Warning: Label(s) may have changed' $*.log) \
do xelatex $<; done
clean:
$(RM) $(PACKAGE).cls *.log *.aux \
*.cfg *.glo *.idx *.toc \
*.ilg *.ind *.out *.lof \
*.lot *.bbl *.blg *.gls *.cut *.hd \
*.dvi *.ps *.thm *.tgz *.zip *.rpi
distclean: clean
$(RM) $(PDF)
#
# Archive for the distribution. Includes typeset documentation
#
archive: all clean
tar -C .. -czvf ../$(PACKAGE).tgz --exclude '*~' --exclude '*.tgz' --exclude '*.zip' --exclude CVS --exclude '.git*' $(PACKAGE); mv ../$(PACKAGE).tgz .
zip: all clean
zip -r $(PACKAGE).zip * -x '*~' -x '*.tgz' -x '*.zip' -x CVS -x 'CVS/*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment