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
20 EBOOKS=$(EPUB) $(MOBI) $(PDB) $(LRF) $(FB2)
21 # To build only epub books:
24 # Formats we are compiling to
25 FORMATS=$(subst $(BASENAME).,,$(EBOOKS))
32 XMLFILE=$(patsubst %.epub,$(RELXMLDIR)/%.xml,$(BOOK))
34 # XSL files the ePubs depend on. If these are modified the
35 # ePub file needs to be regenerated
36 XSLFILES=$(RELXSLDIR)/epub-opf-metadata.xsl $(RELXSLDIR)/epub-xhtml.xsl \
37 $(RELXSLDIR)/epub-ncx.xsl $(RELXSLDIR)/epub-opf-spine.xsl
39 # Generate the ePub file from the XML file
41 $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB): $(XMLFILE) $(EPUBSCRIPT) $(XSLFILES)
42 cd $(AONROOTDIR) && perl $(EPUBSCRIPT) --language=$(BLANG) --font-files=$(AONROOTDIR)/fontfiles/ $(BASENAME)
44 $(EPUB): $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB)
45 cp -p $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB) .
46 # Regenerate to include the covers properly within the Ebook
47 ebook-convert $(EPUB) regen_$(EPUB)
48 mv regen_$(EPUB) $(EPUB)
49 -rm -f cover.jpg $(BASENAME).opf
52 # Convert to other formats. For a full list of format that we can convert to using
53 # Calibre see http://manual.calibre-ebook.com/cli/ebook-convert.html
55 # Generate the mobi file from the ePub (Mobipocket format)
60 # Generate the pdb file from the ePub (eReader / Palm Media format)
64 # Generate the lrf file from the ePub (Broadband eBooks (BBeB) format)
68 # Generate the lit file from the ePub (Microsoft LIT format for Microsoft Reader)
72 # Generate the pdf file from the ePub
76 # Generate the snb file from the ePub
80 # Generate the pml file from the ePub
84 # Generate the fb2 file from the ePub (Fictionbook format used by BeBook, PocketBook, Cybook, Papyre and others)
89 # Alternative build for the ePub format using open source tools instead
92 #DOCBOOK_XSL=/usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl
93 #$(BOOK): $(XMLFILE) $(DOCBOOK_XSL)
94 # if [ -x /usr/bin/dbtoepub ] ; then \
95 # dbtoepub -o $(BOOK) $(XMLFILE) >$(BOOK).log 2>&1; \
97 # xsltproc $(DOCBOOK_XSL) $< >$(BOOK).log 2>&1; \
98 # echo "application/epub+zip" > mimetype ; \
99 # zip -0Xq $@ mimetype; \
100 # zip -Xr9D $@ META-INF/* OEBPS/* ; \
103 # Embed font in dbtoepub using -f
106 java -jar epubcheck.jar $<
109 # Final installation step of generate ebooks
110 install: $(INSTALLDIR) $(EBOOKS)
111 @for format in $(FORMATS); do \
112 PUBLISHDIR="$(INSTALLDIR)/$$format/$(SERIES)" ; \
113 file=$(BASENAME).$$format ; \
114 [ ! -e "$$PUBLISHDIR" ] && \
115 mkdir -p "$$PUBLISHDIR" ; \
116 echo "Copying $$file to $$PUBLISHDIR" ; \
117 cp -p $$file $$PUBLISHDIR && \
118 chmod 664 $$PUBLISHDIR/$$file ; \
126 -rm -f $(EBOOKS) $(EPUB).log regen_$(EPUB) cover.jpg $(BASENAME).opf
129 -rm -rf $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/
131 .PHONY: all install publish clean distclean epub mobi