Makefile 823 B

123456789101112131415161718192021222324252627282930313233343536
  1. BUILD = build
  2. BOOKNAME = my-book
  3. TITLE = title.txt
  4. METADATA = metadata.xml
  5. CHAPTERS = ch01.md ch02.md
  6. TOC = --toc --toc-depth=2
  7. COVER_IMAGE = images/cover.jpg
  8. LATEX_CLASS = report
  9. all: book
  10. book: epub html pdf
  11. clean:
  12. rm -r $(BUILD)
  13. epub: $(BUILD)/epub/$(BOOKNAME).epub
  14. html: $(BUILD)/html/$(BOOKNAME).html
  15. pdf: $(BUILD)/pdf/$(BOOKNAME).pdf
  16. $(BUILD)/epub/$(BOOKNAME).epub: $(TITLE) $(CHAPTERS)
  17. mkdir -p $(BUILD)/epub
  18. pandoc $(TOC) -S --epub-metadata=$(METADATA) --epub-cover-image=$(COVER_IMAGE) -o $@ $^
  19. $(BUILD)/html/$(BOOKNAME).html: $(CHAPTERS)
  20. mkdir -p $(BUILD)/html
  21. pandoc $(TOC) --standalone --to=html5 -o $@ $^
  22. $(BUILD)/pdf/$(BOOKNAME).pdf: $(TITLE) $(CHAPTERS)
  23. mkdir -p $(BUILD)/pdf
  24. pandoc $(TOC) --latex-engine=xelatex -V documentclass=$(LATEX_CLASS) -o $@ $^
  25. .PHONY: all book clean epub html pdf