diff --git a/ebook-storybook/Makefile b/ebook-storybook/Makefile new file mode 100644 index 0000000..3481aa8 --- /dev/null +++ b/ebook-storybook/Makefile @@ -0,0 +1,70 @@ +SHELL := /bin/bash +# Inspired by: +# gist by Lincoln Mullen | http://lincolnmullen.com | lincoln@lincolnmullen.com +# and https://gist.github.com/elchinot7/67825dae97c3d628181a +# +# +# Main latex document name +FILE ?= ebook + +#from https://www.gnu.org/software/make/manual/make.html#Phony-Targets +# markdown sources in subdirectory +SUBDIRS = inputs + +MDS := ./$(SUBDIRS:%=%/*.md) +#MDS := $(filter %/, $(wildcard ./$(SUBDIRS)/*.md)) # I don't think this works +# List files to be made by finding all *.md files and appending .tex +#TEXS := $(patsubst %.md,%.md.tex,$(wildcard ./$(SUBDIRS)/*.md.tex)) # I don't think this works +# List files to be made by finding all *.tex files and appending .pdf +#TEXS := ./$(SUBDIRS:%=%/*.md.tex) # This doesn't work +TEXS := $(patsubst %.md,%.md.tex,$(wildcard $(MDS))) +PDFS := $(wildcard *.pdf) + +# differences in specification between MDS and TEXS. not sure which is best. +# previous attempts at specifying TEXS and MDS left in place. + +LATEX = latexmk +PANDOC = pandoc +LATEXFILE = $(FILE).tex +OUTPUTFILE = $(FILE).pdf + + +# compilation options +# panopts - pandoc options, latopts - latexmk options +PANOPTS = --biblatex +LATOPTS = -pdf -e '$$pdflatex=q/xelatex %O %S/' + +.PHONY: clean default + +# The all rule makes the PDF file +all : ebook # $(TEXS) ebook + +# default rule +default : clean all + +# This rule accepts ebook.tex target with corresponding latex include +# sources and makes it using latexmk +ebook : $(LATEXFILE) $(TEXS) + $(LATEX) -c + $(LATEX) $(LATOPTS) $(LATEXFILE) + +# This rule accepts TEX targets with corresponding Markdown +# source, and makes them using pandoc +$(TEXS) : $(MDS) + $(PANDOC) $(PANOPTS) $< -o $@ + +# Remove all PDF outputs and pandoc's .md.tex outputs +clean : + @rm -f *.aux *.log *.out *.pdfsync *.tdo *.end\ + *.table *.gnuplot *.gz *.bbl *.dvi *.fls \ + *.fdb_latexmk *Notes.bib *.blg \ + *.toc ./inputs/*.aux + @rm $(PDFS) + @rm $(TEXS) + +# Remove all PDF and intermediate outputs then build them again +rebuild : clean all + +test : $(TEXS) + echo $(MDS) + echo $(TEXS)