######################################################################## ## Makefile to generate multiple document from the same markdown file ## using pandoc software: ## ## References: ## ## Authors: ## - Benoit Rat (Seven Solutions, www.sevensols.com) ## ## GNU Lesser General Public License Usage ## This file may be used under the terms of the GNU Lesser ## General Public License version 2.1 as published by the Free Software ## Foundation and appearing in the file LICENSE.LGPL included in the ## packaging of this file. Please review the following information to ## ensure the GNU Lesser General Public License version 2.1 requirements ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ######################################################################## ## Obtaining the proper file SRC=$(wildcard *.md) PDF=$(addprefix pdf/, $(SRC:.md=.pdf)) TEX=$(SRC:.md=.tex) ## Pandoc arguments OPTIONS=-s --from markdown+yaml_metadata_block --toc --number-sections --smart TEMPLATE=pandoc.latex ifneq "$(TEMPLATE)" "" TEMPLATEARG=--template=$(TEMPLATE) endif ## Obtain the version ($ is replaced by $$) VERSION = $(shell git describe --always --dirty=+ | sed 's;^.*-\([v0-9\.]*\)\([a-z0-9\-+]*\)$$;\1\2;' ) DATE = $(shell date +"%d %b. %Y") #--highlight-style=pygments (the default), kate, monochrome, espresso, haddock, and tango #-V highlight-bg=true ## Main targets all: $(PDF) tex: $(TEX) pdf: $(PDF) ## Special targets to create directory DIR_%: mkdir -p $(subst DIR_,,$@) pdf/wr-starting-kit.pdf: wr-starting-kit.md Makefile $(TEMPLATE) DIR_pdf pandoc $(OPTIONS) --latex-engine=xelatex --listings --highlight-style=haddock $(TEMPLATEARG) \ -V title="WR Starting Kit" -V subtitle="User Guide" -V author="Seven Solutions" \ -V lang=english -V fontsize=11pt -V documentclass=article -V bg-color=238,245,240 -V date="$(DATE) - $(VERSION)" -o $@ $< pdf/%.pdf: %.md Makefile $(TEMPLATE) DIR_pdf pandoc $(OPTIONS) --latex-engine=xelatex --listings --highlight-style=haddock $(TEMPLATEARG) \ -V lang=english -V fontsize=11pt -V documentclass=article -V bg-color=238,245,240 -V date="$(DATE) - $(VERSION)" -o $@ $< %.tex: %.md Makefile $(TEMPLATE) @echo "$(VERSION) @ $(notdir $@) $@ < $< ^ $^" pandoc $(OPTIONS) --listings --highlight-style=haddock $(TEMPLATEARG) \ -V lang=english -V fontsize=11pt -V documentclass=article -V bg-color=238,245,240 -o $@ $< install: $(PDF) mkdir -p ../pdf cp $< ../$(subst .pdf,-$(VERSION).pdf,$<) .PHONY: clean clean: rm -f pdf/*.pdf *~ *.tex *.log