-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile.chapter
37 lines (31 loc) · 1.54 KB
/
Makefile.chapter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Build Chapter
CHAPTER_NUMBER=$(shell pwd | gawk '{ match($$0, "chapter-([0-9]*)", arr); print arr[1]}')
BOOK_ID=$(shell cat ../BOOK_ID)
LIVEBOOK_URL=$(shell cat ../LIVEBOOK_URL)
CHAPTER_NAME=chapter-$(CHAPTER_NUMBER)
CHAPTER_TITLE="$(shell xpath $(CHAPTER_NAME).xml 'string(/book/chapter/title)' 2> /dev/null)"
OS=$(shell uname)
all: docbook pdf
docbook:
@echo Making $(CHAPTER_NAME) in Manning DocBook
runghc ../manning.hs < $(CHAPTER_NAME).md > $(CHAPTER_NAME).xml
xsltproc --novalid --stringparam chapternum $(CHAPTER_NUMBER) -o $(CHAPTER_NAME).xml ../docbook2manning.xslt $(CHAPTER_NAME).xml
sed -i "" -e 's/xmlns=""//g' $(CHAPTER_NAME).xml
@echo Validating Chapter
xmllint --noout --schema ../manning-book.xsd $(CHAPTER_NAME).xml
bash -c "cd ../validator/; java -cp .:AAValidator.jar:svnkit.jar:servlet.jar:maven-embedder-2.0.4-dep.jar:maven-2.0.9-uber.jar AAValidator ../$(CHAPTER_NAME)/$(CHAPTER_NAME).xml"
rm temp.xml
rm ../validator/c:\\sw\\text.txt
pdf:
@echo Making $(CHAPTER_NAME) in PDF
ifeq ($(OS), Darwin)
../AAMakePDF/AAMakePDFMac.sh $(CHAPTER_NAME).xml $(CHAPTER_NAME).pdf ../AAMakePDF/
else
../AAMakePDF/AAMakePDF.sh $(CHAPTER_NAME).xml $(CHAPTER_NAME).pdf ../AAMakePDF/
endif
@rm -f $(CHAPTER_NAME).xml.temp.xml
publish: docbook
zip $(CHAPTER_NAME).zip $(CHAPTER_NAME).xml *.png *.gif *.jpg *.svg
# curl -v -F bookId=$(BOOK_ID) -F chapterNumber=$(CHAPTER_NUMBER) -F chapterName=$(CHAPTER_TITLE) \
# -F chapterType=1 -F partId=-1 -F manuscriptLocation=$(CHAPTER_NAME).xml -F filesToAdd=@$(CHAPTER_NAME).zip \
# $(LIVEBOOK_URL)