# Build variables BASEBDIR=./build BDIR=$(BASEBDIR) TDIR=$(BASEBDIR)/tmp SDIR=./src BNAME=promise-`git show --oneline | head -1 | cut -d" " -f1` CONF=default.cfg SOURCE=main.tex TEMP=templ.tex # Author and metadata # THESE FIELDS MAY NOT CONTAIN ANY SEMICOLONS! TITLE=A Promise PENNAME=Liette Faerchild LEGALNAME=Ren Kararou PRONOUNS=fae/faer STREETADDR=1010 Fake Blvd LASTADDR=Denver, CO EMAIL=ren@kararou.space PHONE=(303)555-4202 all: pdf cleanbuild timestamp timestamp: mkbuild if [ -f $(BDIR)/$(BNAME).epub ]; then mv $(BDIR)/$(BNAME).epub $(BDIR)/$(BNAME)-`date -u +%d%m%y-%H%M`.epub; fi if [ -f $(BDIR)/$(BNAME).pdf ]; then mv $(BDIR)/$(BNAME).pdf $(BDIR)/$(BNAME)-`date -u +%d%m%y-%H%M`.pdf; fi if [ -f $(BDIR)/$(BNAME).docx ]; then mv $(BDIR)/$(BNAME).docx $(BDIR)/$(BNAME)-`date -u +%d%m%y-%H%M`.docx; fi mkbuild: if [ ! -d $(BDIR) ]; then mkdir -p $(BDIR); fi if [ ! -d $(TDIR) ]; then mkdir -p $(TDIR); fi mktemp: mkbuild if [ ! -f $(TDIR)/$(TEMP) ]; then cp $(SDIR)/$(SOURCE) $(TDIR)/$(TEMP); fi wordcount: mktemp # This only works when you've got sed -i "s;WORDCOUNT;`cat $(SDIR)/chapters/*.tex | wc -w`;g" \ $(TDIR)/$(TEMP) repo: mktemp sed -i "s;REPO;`git remote get-url origin`;g" $(TDIR)/$(TEMP) title: mktemp sed -i "s;PROJECT;$(TITLE);g" $(TDIR)/$(TEMP) phone: mktemp sed -i "s;PHONE;$(PHONE);g" $(TDIR)/$(TEMP) pen: mktemp sed -i "s;PENNAME;$(PENNAME);g" $(TDIR)/$(TEMP) # Change the following line's -f# to decide which name to use # LNAME needs to be the family name. sed -i "s;SNAME;`echo $(PENNAME) | cut -d" " -f2`;g" $(TDIR)/$(TEMP) email: mktemp sed -i "s;EMAIL;$(EMAIL);g" $(TDIR)/$(TEMP) 3ppn: mktemp sed -i "s;PRONOUNS;$(PRONOUNS);g" $(TDIR)/$(TEMP) addr: mktemp sed -i "s;STREETADDR;$(STREETADDR);g" $(TDIR)/$(TEMP) sed -i "s;LASTADDR;$(LASTADDR);g" $(TDIR)/$(TEMP) lname: mktemp sed -i "s;LEGALNAME;$(LEGALNAME);g" $(TDIR)/$(TEMP) template: mktemp wordcount repo title phone pen email 3ppn addr lname if [ -f $(TDIR)/$(TEMP) ]; \ then mv $(TDIR)/$(TEMP) $(TDIR)/$(SOURCE); \ else cp $(SDIR)/$(SOURCE) $(TDIR)/$(SOURCE); \ fi pdf: template pdflatex -jobname=$(BNAME) -output-directory=$(BDIR) $(TDIR)/$(SOURCE) epub: template tex4ebook -f epub -c $(SDIR)/$(CONF) -j $(BNAME) $(TDIR)/$(SOURCE) mv $(BNAME).epub $(BDIR) word: template pandoc $(TDIR)/$(SOURCE) -o $(BDIR)/$(BNAME).docx spellcheck: for c in $(SDIR)/chapters/*.tex; do aspell -t -c $${c}; done cleanbuild: rm -rf $(BDIR)/*.log $(BDIR)/*.aux $(BDIR)/*.toc $(BDIR)/$(TEMP) \ $(BDIR)/$(SOURCE) ./*.opf ./*.html ./*.aux ./*.css ./*.dvi \ ./*-epub/ ./*-mobi/ ./*.idv ./*.lg ./*.log ./*.toc ./*.xref \ ./*.4ct ./*.4tc ./*.ncx ./*.tmp $(SDIR)/chapters/*.bak $(TDIR) clean: cleanbuild rm -rf $(BASEBDIR)