Skip to content

Instantly share code, notes, and snippets.

@ekaitz-zarraga
Last active March 22, 2016 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekaitz-zarraga/f90f4c9c46a394e2048a to your computer and use it in GitHub Desktop.
Save ekaitz-zarraga/f90f4c9c46a394e2048a to your computer and use it in GitHub Desktop.
Generic Makefile for Markdown documentation
# Copyright © 2015-2016 Ekaitz Zarraga <ekaitzzarraga@gmail.com>
# This work is free. You can redistribute it and/or modify it under the
# terms of the Do What The Fuck You Want To Public License, Version 2,
# as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
# Makefile for easy documentation in HTML and PDF
C = pandoc
# Set default to all
.DEFAULT_GOAL := all
# Numbered sections and subsections
FLAGS = -N
# Add table of contents
FLAGS += --toc
# Standalone output
FLAGS += -s
# Add some flag shit
#FLAGS +=
SECTIONS = $(sort $(wildcard sections/*.md))
# Get all the markdown files from "sections" folder
# sections must be named like 0_intro.md 1_first.md 2_second.md
# to load them in the correct order
# HTML TARGET
#-------------------------------------------------------------------------
TARGET_HTML = Docs.html
.PHONY: html
html: $(TARGET_HTML)
$(TARGET_HTML): $(SECTIONS)
$(C) $(FLAGS) -o $@ $(SECTIONS)
# PDF TARGET
#-------------------------------------------------------------------------
TARGET_PDF = Docs.pdf
# Add PDF related FLAGS
PDF_FLAGS = --latex-engine=xelatex
.PHONY: pdf
pdf: $(TARGET_PDF)
$(TARGET_PDF): $(SECTIONS)
$(C) $(FLAGS) -o $@ $(SECTIONS) $(PDF_FLAGS)
# ALL TARGET
#-------------------------------------------------------------------------
.PHONY: all
all: pdf html
# CLEAN TARGET
#-------------------------------------------------------------------------
.PHONY: clean
clean:
rm -f $(TARGET_PDF) $(TARGET_HTML)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment