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
16 # -------------------------------- BEGIN FONT SELECTION -----------------------------------------------------------
17 # Location of the font files, this is adjustable here in order to make it possible to run
18 # the build scripts as not all developers might have the Souvernir fonts.
20 # Option 1 (to be used for the Lone wolf and Grey star series) - Souvenir font
21 # ---------------------------------------------------------------------------
22 # Use this when buidling Lone Wolf books, using Souvenir fonts and make sure
23 # the font is available in the directory you configure here. Note that the
24 # fontfiles are *not* available in Project Aon's SVN repository as they are not
25 # under a free license. For more information see /common/fonts/README.txt
27 # If using this configure, please make sure the following fonts are available in this directory:
28 # SouvenirStd-DemiItalic.otf SouvenirStd-Demi.otf SouvenirStd-LightItalic.otf SouvenirStd-Light.otf
31 FONTDIR := $(AONROOTDIR)/../fontfiles/
34 FONTDIR := $(AONROOTDIR)/../fontfiles/
37 FONTDIR := $(AONROOTDIR)/../fontfiles/
40 # Option 2 (to be used for Freway Warrior series builds) - Carlito font
41 # ---------------------------------------------------------------------
42 # Use this when running builds of the Freeway Warrior series using the Carlito
43 # fonts. This will build the documents using the fonts available in the SVN
44 # repository which (at the time of this writting) are the Carlito font, which
45 # is distributed with an Open Font license.
48 FONTDIR := $(AONROOTDIR)/common/fonts/
50 # --------------------------------- END FONT SELECTION -----------------------------------------------------------
53 $(info FONTDIR is not defined, defauling to AONROOTDIR/common/fonts/)
54 FONTDIR := $(AONROOTDIR)/common/fonts/
57 # Sanity checks before going further
59 $(error WARNING: Book series is not defined, please define variable 'SERIES')
62 $(error WARNING: Book language is not defined, please define variable 'BLANG')
65 $(error WARNING: Book basic name is not defined, please define variable 'BASENAME')
74 EBOOKS=$(EPUB) $(MOBI) $(PDB) $(LRF) $(FB2)
75 # To build only epub books:
78 # Formats we are compiling to
79 FORMATS=$(subst $(BASENAME).,,$(EBOOKS))
86 XMLFILE=$(patsubst %.epub,$(RELXMLDIR)/%.xml,$(BOOK))
88 # XSL files the ePubs depend on. If these are modified the
89 # ePub file needs to be regenerated
90 XSLFILES=$(RELXSLDIR)/epub-opf-metadata.xsl $(RELXSLDIR)/epub-xhtml.xsl \
91 $(RELXSLDIR)/epub-ncx.xsl $(RELXSLDIR)/epub-opf-spine.xsl
93 # Generate the ePub file from the XML file
95 $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB): $(XMLFILE) $(EPUBSCRIPT) $(XSLFILES)
96 cd $(AONROOTDIR) && perl $(EPUBSCRIPT) --language=$(BLANG) --font-files=$(FONTDIR) $(BASENAME)
98 $(EPUB): $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB)
99 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
100 cp -p $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB) .
101 # Regenerate to include the covers properly within the Ebook and fix the EPUB
102 ebook-convert $(EPUB) regen_$(EPUB) --cover $(COVERIMAGE)
103 mv regen_$(EPUB) $(EPUB)
104 -rm -f cover.jpg $(BASENAME).opf
107 # Convert to other formats. For a full list of format that we can convert to using
108 # Calibre see http://manual.calibre-ebook.com/cli/ebook-convert.html
110 # Generate the mobi file from the ePub (Mobipocket format)
113 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
116 # Generate the pdb file from the ePub (eReader / Palm Media format)
118 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
121 # Generate the lrf file from the ePub (Broadband eBooks (BBeB) format)
123 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
126 # Generate the lit file from the ePub (Microsoft LIT format for Microsoft Reader)
128 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
131 # Generate the pdf file from the ePub
133 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
136 # Generate the snb file from the ePub
138 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
141 # Generate the pml file from the ePub
143 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
146 # Generate the fb2 file from the ePub (Fictionbook format used by BeBook, PocketBook, Cybook, Papyre and others)
148 @[ -x `which ebook-convert` ] || { echo "ERROR: Cannot find 'ebook-convert', please install Calibre" >&2; exit 1; }
152 # Alternative build for the ePub format using open source tools instead
154 # Sample Makefile code:
156 #DOCBOOK_XSL=/usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl
157 #$(EPUB): $(XMLFILE) $(DOCBOOK_XSL)
158 # @[ -x `which dbtoepub` ] || { echo "ERROR: Cannot find 'dbtoepub', please install this package" >&2; exit 1; }
159 # if [ -x /usr/bin/dbtoepub ] ; then \
160 # dbtoepub -o $(EPUB) $(XMLFILE) >$(BOOK).log 2>&1; \
162 # xsltproc $(DOCBOOK_XSL) $< >$(BOOK).log 2>&1; \
163 # echo "application/epub+zip" > mimetype ; \
164 # zip -0Xq $@ mimetype; \
165 # zip -Xr9D $@ META-INF/* OEBPS/* ; \
168 # Embed font in dbtoepub using -f
171 java -jar epubcheck.jar $<
174 # Final installation step of generate ebooks
175 install: $(INSTALLDIR) $(EBOOKS)
176 @for format in $(FORMATS); do \
177 PUBLISHDIR="$(INSTALLDIR)/$$format/$(SERIES)" ; \
178 file=$(BASENAME).$$format ; \
179 [ ! -e "$$PUBLISHDIR" ] && \
180 mkdir -p "$$PUBLISHDIR" ; \
181 echo "Copying $$file to $$PUBLISHDIR" ; \
182 cp -p $$file $$PUBLISHDIR && \
183 chmod 664 $$PUBLISHDIR/$$file ; \
191 -rm -f $(EBOOKS) $(EPUB).log regen_$(EPUB) cover.jpg $(BASENAME).opf
194 -rm -rf $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/
196 .PHONY: all install publish clean distclean epub mobi ebook-convert