# -*- make -*- # (C) 2013 by Eugeniy Mikhailov, # Processing of pandoc files CLEAN_TARGETS += clean_md REAL_CLEAN_TARGETS += real_clean_md dest_dir_md ?= $(dest_dir) destination_dirs += $(dest_dir_md) md_files = $(wildcard *.md) tex_from_md = $(md_files:%.md=%.tex) pdf_from_md = $(md_files:%.md=%.pdf) html_from_md = $(md_files:%.md=%.html) md_src_dest_targets = $(md_files:%=$(dest_dir_md)/%) md_fig_dest_targets = $(md_fig_files:%=$(dest_dir_md)/%) tex_from_md_dest_targets = $(tex_from_md:%=$(dest_dir_md)/%) pdf_from_md_dest_targets = $(pdf_from_md:%=$(dest_dir_md)/%) html_from_md_dest_targets = $(html_from_md:%=$(dest_dir_md)/%) # to disable preprocessor use #PANDOC_PREPROCESSOR_CMD ?= cat #PANDOC_PREPROCESSOR_OPTIONS ?= # preprocessor on PANDOC_PREPROCESSOR_CMD ?= gpp PANDOC_PREPROCESSOR_OPTIONS ?= -U "" "" "(" "," ")" "(" ")" "\#" "\\" -M "<\#" "\n" " " " " "\n" "(" ")" PANDOC_PREPROCESSOR ?= $(PANDOC_PREPROCESSOR_CMD) $(PANDOC_PREPROCESSOR_OPTIONS) PANDOC_CMD := pandoc PANDOC_COMMON_OPTIONS ?= --standalone --smart PANDOC := $(PANDOC_CMD) $(PANDOC_COMMON_OPTIONS) PANDOC_DATA_DIR ?= $(CONFIG_DIR) PANDOC_META_DIR ?= $(CONFIG_DIR) PANDOC_CSS_DIR ?= $(TOPDIR)/css_styles PANDOC_CSS ?= PANDOC_TEMPLATE ?= ifneq ($(strip $(PANDOC_DATA_DIR)),) PANDOC += --data-dir=$(PANDOC_DATA_DIR) endif ifneq ($(strip $(PANDOC_TEMPLATE)),) PANDOC += --template=$(PANDOC_TEMPLATE) endif # chose default name for css if it is not define ifeq ($(strip $(PANDOC_CSS)),) ifneq ($(strip $(PANDOC_TEMPLATE)),) # non empty template name PANDOC_CSS = evmik_pandoc_$(PANDOC_TEMPLATE).css else # empty template name #PANDOC_CSS = evmik_pandoc.css PANDOC_CSS = evmik_pandoc_$(PANDOC_TEMPLATE).css endif endif PANDOC_HTML_METADATA ?= cat - PANDOC_TEX_METADATA ?= cat - $(PANDOC_META_DIR)/tex_metadata.yaml PANDOC_PDF_METADATA ?= $(PANDOC_TEX_METADATA) PANDOC_HTML_OPTIONS ?= --section-divs --toc PANDOC_TEX_OPTIONS ?= --latex-engine=pdflatex PANDOC_PDF_OPTIONS ?= --latex-engine=pdflatex ifneq ($(strip $(PANDOC_CSS)),) PANDOC_HTML_OPTIONS += --css=$(PANDOC_CSS_DIR)/$(PANDOC_CSS) endif html_md: $(html_from_md) pdf_tex: $(pdf_from_independent_tex) pdf_md: $(pdf_from_md) tex_md: $(tex_from_md) $(html_from_md): %.html : %.md $(md_fig_files) $(md_configs) $(md_includes) $(PANDOC_PREPROCESSOR) $< | $(PANDOC_HTML_METADATA) | $(PANDOC) -t html5 $(PANDOC_HTML_OPTIONS) -o $@ $(tex_from_md): %.tex : %.md $(md_fig_files) $(md_configs) $(md_includes) $(PANDOC_PREPROCESSOR) $< | $(PANDOC_TEX_METADATA) | $(PANDOC) -t latex $(PANDOC_TEX_OPTIONS) -o $@ $(pdf_from_md): %.pdf : %.md $(md_fig_files) $(md_configs) $(md_includes) $(PANDOC_PREPROCESSOR) $< | $(PANDOC_PDF_METADATA) | $(PANDOC) $(PANDOC_PDF_OPTIONS) -o $@ install_md_src: $(md_src_dest_targets) install_md_fig_files $(md_src_dest_targets): $(dest_dir_md)/% : % | $(dest_dir_md) ifneq ($(strip $(md_files)),) $(INSTALL) -m 0644 '$<' '$@' endif install_md_fig_files: $(md_fig_dest_targets) $(md_fig_dest_targets): $(dest_dir_md)/% : % | $(dest_dir_md) ifneq ($(strip $(md_fig_files)),) $(INSTALL) -m 0644 '$<' '$@' endif install_html_md: $(html_from_md_dest_targets) install_md_fig_files $(html_from_md_dest_targets): $(dest_dir_md)/% : % | $(dest_dir_md) ifneq ($(strip $(html_from_md)),) $(INSTALL) -m 0644 '$<' '$@' endif install_pdf_md: $(pdf_from_md_dest_targets) $(pdf_from_md_dest_targets): $(dest_dir_md)/% : % | $(dest_dir_md) ifneq ($(strip $(pdf_from_md)),) $(INSTALL) -m 0644 '$<' '$@' endif clean_md: clean_md_aux real_clean_md: clean_md_tex clean_md_aux ifneq ($(strip $(pdf_from_md)),) rm -f $(pdf_from_md) endif ifneq ($(strip $(html_from_md)),) rm -f $(html_from_md) endif clean_md_tex: ifneq ($(strip $(tex_from_md)),) rm -f $(tex_from_md) endif clean_md_aux: ifneq ($(strip $(tex_from_md)),) rm -f $(tex_from_md:%.tex=%.dvi) rm -f $(tex_from_md:%.tex=%.log) rm -f $(tex_from_md:%.tex=%.aux) rm -f $(tex_from_md:%.tex=%.nav) rm -f $(tex_from_md:%.tex=%.out) rm -f $(tex_from_md:%.tex=%.snm) rm -f $(tex_from_md:%.tex=%.toc) rm -f $(tex_from_md:%.tex=%.vrb) rm -f $(tex_from_md:%.tex=%.blg) rm -f $(tex_from_md:%.tex=%.bbl) rm -f missfont.log rm -f *Notes.bib endif