Makefile 2.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
########################################################################
## 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)
22 23
PDF=$(addprefix pdf/, $(SRC:.md=.pdf))
TEX=$(SRC:.md=.tex)
24 25 26 27 28 29

## Pandoc arguments
OPTIONS=-f markdown --toc --number-sections --smart
TEMPLATE=pandoc.latex 


30 31 32 33
ifneq "$(TEMPLATE)" ""
TEMPLATEARG=--template=$(TEMPLATE)
endif

34 35
## Obtain the version ($ is replaced by $$)
VERSION = $(shell git describe --always --dirty=+ | sed  's;^.*-\([v0-9\.]*\)\([a-z0-9\-+]*\)$$;\1\2;' )
36
DATE	= $(shell date +"%d %b. %Y")
37

38 39 40
#--highlight-style=pygments (the default), kate, monochrome, espresso, haddock, and tango
#-V highlight-bg=true

41 42 43 44 45 46 47 48 49
## Main targets
all: $(PDF)
tex: $(TEX)
pdf: $(PDF)

## Special targets to create directory	
DIR_%:
	mkdir -p $(subst DIR_,,$@)	

50
pdf/%.pdf: %.md Makefile $(TEMPLATE) DIR_pdf
51
	pandoc $(OPTIONS) --latex-engine=xelatex  --listings --highlight-style=haddock $(TEMPLATEARG) \
52
-V lang=english -V fontsize=11pt -V documentclass=article -V bg-color=238,245,240 -V date="$(DATE) - $(VERSION)" -o $@ $<
53

54
%.tex: %.md Makefile $(TEMPLATE) 
55
	@echo "$(VERSION) @ $(notdir $@) $@ < $< ^ $^"
56 57
	pandoc $(OPTIONS) --listings --highlight-style=haddock $(TEMPLATEARG) \
-V lang=english  -V  fontsize=11pt -V documentclass=article -V bg-color=238,245,240 -o $@ $<
58

59 60 61 62
install: $(PDF) 
	mkdir -p ../pdf
	cp  $< ../$(subst .pdf,-$(VERSION).pdf,$<)

63 64 65
.PHONY: clean

clean:
66 67 68
	rm -f pdf/*.pdf *~ *.tex *.log

	
69