3 AONROOTREL := ../../../
4 AONROOTDIR = $(realpath $(AONROOTREL))
5 # Base directory we will install into
6 INSTALLDIR := $(AONROOTDIR)/../PUBLISH/$(BLANG)/
7 # Relative location of the XML files
8 RELXMLDIR := $(AONROOTDIR)/$(BLANG)/xml/
9 # Relative location of the scripts
10 RELSCRIPT := $(AONROOTDIR)/common/scripts
11 # Relative location of the xsl files
12 RELXSLDIR := $(AONROOTDIR)/common/xsl
13 EPUBSCRIPT := $(RELSCRIPT)/gbtoepub.pl
14 COVERIMAGE := $(AONROOTDIR)/$(BLANG)/jpeg/$(SERIES)/$(BASENAME)/skins/ebook/cover.jpg
21 EBOOKS=$(EPUB) $(MOBI) $(PDB) $(LRF) $(FB2)
22 # To build only epub books:
25 # Formats we are compiling to
26 FORMATS=$(subst $(BASENAME).,,$(EBOOKS))
33 XMLFILE=$(patsubst %.epub,$(RELXMLDIR)/%.xml,$(BOOK))
35 # XSL files the ePubs depend on. If these are modified the
36 # ePub file needs to be regenerated
37 XSLFILES=$(RELXSLDIR)/epub-opf-metadata.xsl $(RELXSLDIR)/epub-xhtml.xsl \
38 $(RELXSLDIR)/epub-ncx.xsl $(RELXSLDIR)/epub-opf-spine.xsl
40 # Generate the ePub file from the XML file
42 $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB): $(XMLFILE) $(EPUBSCRIPT) $(XSLFILES)
43 # Use this when using Souvenir fonts (cannot be distributed in Project Aon's SVN repository)
44 # make sure the font is available in the fontfiles directory *one level before* the SVN repo
45 # cd $(AONROOTDIR) && perl $(EPUBSCRIPT) --language=$(BLANG) --font-files=$(AONROOTDIR)/../fontfiles/ $(BASENAME)
46 # Use this when using the fonts provided in the Carlito font (distributed with an Open Font license)
47 # which is available in the Project Aon's SVN repository
48 cd $(AONROOTDIR) && perl $(EPUBSCRIPT) --language=$(BLANG) --font-files=$(AONROOTDIR)/common/fonts/ $(BASENAME)
50 $(EPUB): $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB)
51 cp -p $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB) .
52 # Regenerate to include the covers properly within the Ebook and fix the EPUB
53 ebook-convert $(EPUB) regen_$(EPUB) --cover $(COVERIMAGE)
54 mv regen_$(EPUB) $(EPUB)
55 -rm -f cover.jpg $(BASENAME).opf
58 # Convert to other formats. For a full list of format that we can convert to using
59 # Calibre see http://manual.calibre-ebook.com/cli/ebook-convert.html
61 # Generate the mobi file from the ePub (Mobipocket format)
66 # Generate the pdb file from the ePub (eReader / Palm Media format)
70 # Generate the lrf file from the ePub (Broadband eBooks (BBeB) format)
74 # Generate the lit file from the ePub (Microsoft LIT format for Microsoft Reader)
78 # Generate the pdf file from the ePub
82 # Generate the snb file from the ePub
86 # Generate the pml file from the ePub
90 # Generate the fb2 file from the ePub (Fictionbook format used by BeBook, PocketBook, Cybook, Papyre and others)
95 # Alternative build for the ePub format using open source tools instead
98 #DOCBOOK_XSL=/usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl
99 #$(BOOK): $(XMLFILE) $(DOCBOOK_XSL)
100 # if [ -x /usr/bin/dbtoepub ] ; then \
101 # dbtoepub -o $(BOOK) $(XMLFILE) >$(BOOK).log 2>&1; \
103 # xsltproc $(DOCBOOK_XSL) $< >$(BOOK).log 2>&1; \
104 # echo "application/epub+zip" > mimetype ; \
105 # zip -0Xq $@ mimetype; \
106 # zip -Xr9D $@ META-INF/* OEBPS/* ; \
109 # Embed font in dbtoepub using -f
112 java -jar epubcheck.jar $<
115 # Final installation step of generate ebooks
116 install: $(INSTALLDIR) $(EBOOKS)
117 @for format in $(FORMATS); do \
118 PUBLISHDIR="$(INSTALLDIR)/$$format/$(SERIES)" ; \
119 file=$(BASENAME).$$format ; \
120 [ ! -e "$$PUBLISHDIR" ] && \
121 mkdir -p "$$PUBLISHDIR" ; \
122 echo "Copying $$file to $$PUBLISHDIR" ; \
123 cp -p $$file $$PUBLISHDIR && \
124 chmod 664 $$PUBLISHDIR/$$file ; \
132 -rm -f $(EBOOKS) $(EPUB).log regen_$(EPUB) cover.jpg $(BASENAME).opf
135 -rm -rf $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/
137 .PHONY: all install publish clean distclean epub mobi