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 cd $(AONROOTDIR) && perl $(EPUBSCRIPT) --language=$(BLANG) --font-files=$(AONROOTDIR)/fontfiles/ $(BASENAME)
45 $(EPUB): $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB)
46 cp -p $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB) .
47 # Regenerate to include the covers properly within the Ebook and fix the EPUB
48 ebook-convert $(EPUB) regen_$(EPUB) --cover $(COVERIMAGE)
49 mv regen_$(EPUB) $(EPUB)
50 -rm -f cover.jpg $(BASENAME).opf
53 # Convert to other formats. For a full list of format that we can convert to using
54 # Calibre see http://manual.calibre-ebook.com/cli/ebook-convert.html
56 # Generate the mobi file from the ePub (Mobipocket format)
61 # Generate the pdb file from the ePub (eReader / Palm Media format)
65 # Generate the lrf file from the ePub (Broadband eBooks (BBeB) format)
69 # Generate the lit file from the ePub (Microsoft LIT format for Microsoft Reader)
73 # Generate the pdf file from the ePub
77 # Generate the snb file from the ePub
81 # Generate the pml file from the ePub
85 # Generate the fb2 file from the ePub (Fictionbook format used by BeBook, PocketBook, Cybook, Papyre and others)
90 # Alternative build for the ePub format using open source tools instead
93 #DOCBOOK_XSL=/usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl
94 #$(BOOK): $(XMLFILE) $(DOCBOOK_XSL)
95 # if [ -x /usr/bin/dbtoepub ] ; then \
96 # dbtoepub -o $(BOOK) $(XMLFILE) >$(BOOK).log 2>&1; \
98 # xsltproc $(DOCBOOK_XSL) $< >$(BOOK).log 2>&1; \
99 # echo "application/epub+zip" > mimetype ; \
100 # zip -0Xq $@ mimetype; \
101 # zip -Xr9D $@ META-INF/* OEBPS/* ; \
104 # Embed font in dbtoepub using -f
107 java -jar epubcheck.jar $<
110 # Final installation step of generate ebooks
111 install: $(INSTALLDIR) $(EBOOKS)
112 @for format in $(FORMATS); do \
113 PUBLISHDIR="$(INSTALLDIR)/$$format/$(SERIES)" ; \
114 file=$(BASENAME).$$format ; \
115 [ ! -e "$$PUBLISHDIR" ] && \
116 mkdir -p "$$PUBLISHDIR" ; \
117 echo "Copying $$file to $$PUBLISHDIR" ; \
118 cp -p $$file $$PUBLISHDIR && \
119 chmod 664 $$PUBLISHDIR/$$file ; \
127 -rm -f $(EBOOKS) $(EPUB).log regen_$(EPUB) cover.jpg $(BASENAME).opf
130 -rm -rf $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/
132 .PHONY: all install publish clean distclean epub mobi