From 1fa47c2996897834c924801b5fabd5c10052270b Mon Sep 17 00:00:00 2001 From: Tong Hui Date: Wed, 28 Sep 2016 19:39:27 +0800 Subject: add pdf and html support --- Makefile | 57 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 14 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 68c179a..8158b6d 100755 --- a/Makefile +++ b/Makefile @@ -3,11 +3,13 @@ BOOKNAME = fsfs-zh TITLE = ebook/title.txt METADATA = ebook/metadata.xml TOC = --toc --toc-depth=2 --epub-chapter-level=2 -CHAPTERS = docs/foreword-trans.md \ +LATEX_CLASS = book +TEMPLATE=./pdf +PREFACES = docs/foreword-trans.md \ docs/foreword-v3.md \ docs/foreword-v1.md \ - docs/preface-v3.md \ - docs/free-sw.md \ + docs/preface-v3.md +CHAPTERS = docs/free-sw.md \ docs/thegnuproject.md \ docs/initial-announcement.md \ docs/free-software-even-more-important.md \ @@ -54,37 +56,64 @@ CHAPTERS = docs/foreword-trans.md \ docs/social-inertia.md \ docs/freedom-or-power.md \ docs/imperfection-isnt-oppression.md \ - docs/surveillance-vs-democracy.md \ - docs/appendix-a.md \ + docs/surveillance-vs-democracy.md +APPENDIXS = docs/appendix-a.md \ docs/appendix-b.md \ docs/appendix-c.md \ all: book -book: epub html +book: epub html pdf clean: - rm -r site rm $(BOOKNAME).* + rm -r site + rm *.tex *.aux *.fot *.toc *.log *.out + rm -fr fs-translations + rm *.png epub: $(BOOKNAME).epub html: $(BOOKNAME).html -#pdf: $(BUILD)/$(BOOKNAME).pdf +pdf: $(BOOKNAME).pdf -$(BOOKNAME).epub: $(TITLE) $(CHAPTERS) +$(BOOKNAME).epub: $(TITLE) $(PREFACES) $(CHAPTERS) $(APPENDIXS) cp -r docs/fs-translations/ . cp docs/*.png . pandoc $(TOC) -S --epub-metadata=$(METADATA) -o $@ $^ rm -fr fs-translations rm *.png -$(BOOKNAME).html: $(CHAPTERS) - pandoc $(TOC) --standalone --to=html5 -o $@ $^ - mkdocs --clean +$(BOOKNAME).html: $(PREFACES) $(CHAPTERS) $(APPENDIXS) + pandoc $(TOC) --standalone --to=html5 -o $@ $^ + mkdocs build --clean + +$(BOOKNAME).pdf: $(TITLE) $(PREFACES) $(CHAPTERS) $(APPENDIXS) + multimarkdown -t latex ${TEMPLATE}/meta.txt ${PREFACES} -o preface.tex + multimarkdown -t latex ${TEMPLATE}/meta.txt ${CHAPTERS} -o chapters.tex + multimarkdown -t latex ${TEMPLATE}/meta.txt ${APPENDIXS} -o appendix.tex + ${call pdfgen} +# pandoc $(TOC) --latex-engine=xelatex -V documentclass=$(LATEX_CLASS) --template=$(TEMPLATE) -o $@ $^ + rm -fr fs-translations + rm *.png + +define pdfgen + cp -r docs/fs-translations/ . + cp docs/*.png . + cp ${TEMPLATE}/template.tex fsfs-zh.tex + + xelatex fsfs-zh.tex + xelatex fsfs-zh.tex + xelatex fsfs-zh.tex + + @echo "PDF Compiled!" + + rm *.tex *.aux *.fot *.toc *.log *.out + + @echo + @echo "Done!" +endef -#$(BUILD)/$(BOOKNAME).pdf: $(TITLE) $(CHAPTERS) -# pandoc $(TOC) --latex-engine=xelatex -V documentclass=$(LATEX_CLASS) -o $@ $^ .PHONY: all book clean epub html -- cgit v1.2.3