Skip to content

Instantly share code, notes, and snippets.

@borntyping
Created April 22, 2015 13:45
Show Gist options
  • Select an option

  • Save borntyping/05077df08ffb03aa7b96 to your computer and use it in GitHub Desktop.

Select an option

Save borntyping/05077df08ffb03aa7b96 to your computer and use it in GitHub Desktop.

Revisions

  1. borntyping renamed this gist Apr 22, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. borntyping created this gist Apr 22, 2015.
    52 changes: 52 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    # pdflatex options:
    # -shell-escape is used by the minted package to call pygments
    # -interaction=nonstopmode stops pdflatex waiting for user input on errors
    pdflatex = pdflatex -shell-escape -interaction=nonstopmode report.tex
    pdflatex_warn = $(pdflatex) | grep Warning | grep -v 'float' | sed "s/^LaTeX / /"
    pdflatex_error = $(pdflatex) | grep -e "^!" | sed "s/^! / Error: /"
    pdflatex_quiet = $(pdflatex) >/dev/null

    # Other tools
    texcount = texcount -merge -template="{1}" report.tex
    todos = ack TODO 1-preliminaries 2-chapters 3-appendixes extras

    # Print a nicely formatted message
    message = echo -e "\033[36m`date +%T` \033[0;34m$(1)\033[0m"

    export SHELL:=/bin/bash
    export SHELLOPTS:=pipefail

    report: report.pdf report.txt
    $(call message,"Report is up to date")
    $(call message,"Wordcount: \\033[1\;35m`$(texcount)`")
    $(texcount) > report.wc
    $(todos) >/dev/null && $(call message,"TODO notes: \\033[1\;35m`$(todos) | wc -l`")

    report.pdf: report.tex $(wildcard *-*/*.tex) $(wildcard examples/*) $(wildcard extras/*) extras/report.bib
    $(call message,"Building $@")
    $(call message,"Updated files $?")
    $(call message,"Running pdflatex: $(pdflatex)")
    $(pdflatex_warn) || $(pdflatex_error) || $(pdflatex) >Makefile.log 2>&1
    $(call message,"Running bibtex")
    bibtex report.aux | grep Warning | sed "s/Warning--/ Warning: /" || :
    $(call message,"Running makeglossaries")
    makeglossaries -q report
    $(call message,"Running pdflatex again")
    $(pdflatex_quiet)
    $(pdflatex_quiet)
    $(call message,"Built $@")

    report.txt: $(wildcard 2-chapters/*.tex)
    $(call message,"Running pandoc")
    pandoc -t plain $^ > $@

    extras/report.bib: extras/library.bib
    sed s/abstract/annote/ $^ | tail -n +6 > $@

    clean:
    rm report.{aux,bbl,blg,glg,glo,gls,lof,log,lol,lot,out,toc,xdy} texput.log
    rm Makefile.log extras/glossary.aux extras/layout.aux
    rm -r _minted-report

    .PHONY: report clean
    .SILENT: report report.pdf report.txt extras/report.bib