2573N/A#
2573N/A# CDDL HEADER START
2573N/A#
2573N/A# The contents of this file are subject to the terms of the
2573N/A# Common Development and Distribution License (the "License").
2573N/A# You may not use this file except in compliance with the License.
2573N/A#
2573N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2573N/A# or http://www.opensolaris.org/os/licensing.
2573N/A# See the License for the specific language governing permissions
2573N/A# and limitations under the License.
2573N/A#
2573N/A# When distributing Covered Code, include this CDDL HEADER in each
2573N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2573N/A# If applicable, add the following below this CDDL HEADER, with the
2573N/A# fields enclosed by brackets "[]" replaced with your own identifying
2573N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2573N/A#
2573N/A# CDDL HEADER END
2573N/A#
2573N/A
2573N/A#
2573N/A# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2573N/A#
2573N/A
2573N/A
2573N/A# A simple Makefile to build the dev-guide.
2573N/A# Examples:
2573N/A#
2585N/A# $ make book (makes the pdf using rst2pdf)
2585N/A# $ make xmlbook (makes docbook using rst2docbook)
2585N/A# $ make check (makes pdfs from each book fragment)
2585N/A# $ make chpt1.pdf (makes a single pdf)
2573N/A# $ make -e IGNORE_ERRORS=true chpt4.pdf
2573N/A# $ make clobber
2585N/A#
2585N/A#
2585N/A# Note: in order for the pdf to build, we need to have
2585N/A# library/python-2/python-imaging-26 installed, due to
2585N/A# the png logo we use in macros.txt, referenced by
2585N/A# developer-guide.txt
2585N/A#
2573N/A
2573N/A# set this to make the build to ignore errors in RST documents.
2573N/AIGNORE_ERRORS=
2573N/A
2573N/ABOOK_FRAGMENTS= developer-guide.txt \
2573N/A chpt1.txt \
2573N/A chpt2.txt \
2573N/A chpt3.txt \
2573N/A chpt4.txt \
2573N/A chpt5.txt \
2573N/A chpt6.txt \
2573N/A chpt7.txt \
2573N/A chpt8.txt \
2573N/A chpt9.txt \
2573N/A chpt10.txt \
2573N/A chpt11.txt \
2573N/A chpt12.txt \
2573N/A chpt13.txt \
2573N/A chpt14.txt \
2585N/A appendix-a.txt \
2585N/A appendix-b.txt
2573N/A
2573N/APROTO=../../proto/dev-guide
2573N/ADOCTMP=doctmp
2573N/ADOCTOOLS=doctools
2573N/ATOOLSPATH=$(DOCTOOLS)/lib/python2.6/site-packages
2573N/A
2585N/ARST2PDF=@PYTHONPATH=$(TOOLSPATH) $(DOCTOOLS)/bin/rst2pdf -s $(STYLE) $(BOOK_OPT)
2585N/ASTYLE=dev-guide.style
2585N/A
2585N/A# XXX unused at present - unsure if rst2docbook is correct, or whether we want
2585N/A# to go to the docutils xml, then apply XSLT et al to get to docbook instead.
2585N/A# For now, $RST2DOCBOOK gets used.
2585N/ARST2XML=PYTHONPATH=$(TOOLSPATH) $(DOCTOOLS)/bin/rst2xml.py --no-generator --no-file-insertion
2573N/A
2585N/ARST2DOCBOOK=PYTHONPATH=$(TOOLSPATH) $(DOCTOOLS)/bin/rst2docbook.py \
2585N/A --no-generator --no-file-insertion --doctype=book
2585N/ADOCBOOKRST_URL=http://docutils.sourceforge.net/sandbox/oliverr/docbook
2585N/ADOCBOOKRST_CMD=echo $(DOCBOOKRST_URL) | sed -e 's/http:\/\///g'
2585N/ADOCBOOKRST_PATH=$(DOCBOOKRST_CMD:sh)
2573N/A
2585N/A# when building the pdf book, we add specific options here
2573N/ABOOK_OPT=
2585N/A
2573N/AEASY_INSTALL=PYTHONPATH=$(TOOLSPATH) /usr/bin/easy_install
2573N/AGPATCH=/usr/bin/gpatch
2585N/AWGET=/usr/bin/wget
2573N/A
2573N/A# our version of docutils doesn't work with rst2pdf at the moment, so we need
2585N/A# to apply a patch to that code. We apply a similar patch to docbook.py
2573N/ACREATEPDF=$(TOOLSPATH)/rst2pdf-0.16-py2.6.egg/rst2pdf/createpdf.py
2585N/ADOCBOOKPY=$(TOOLSPATH)/docutils-0.8.1-py2.6.egg/docutils/writers/docbook.py
2585N/A
2585N/AVERSION_CMD=hg identify | awk '{print $1}'
2585N/AVERSION=$(VERSION_CMD:sh)
2585N/ADATE_CMD=date +%F:%R:%S-%Z
2585N/ADATE=$(DATE_CMD:sh)
2585N/A
2585N/AVERSTAMP=$(DATE) $(VERSION)
2573N/A
2573N/Aall: install
2573N/Ainstall: rst2pdf proto book
2573N/A
2585N/A# pull down a local copy of rst2pdf and rst2docbook.py
2585N/Atools: rst2pdf rst2docbook proto
2585N/A
2573N/Arst2pdf: proto
2573N/A @if [ ! -f $(CREATEPDF) ]; then \
2573N/A $(EASY_INSTALL) --prefix=$(DOCTOOLS) rst2pdf; \
2573N/A $(GPATCH) -f -R $(CREATEPDF) < createpdf.patch; \
2573N/A fi
2573N/A
2585N/Arst2docbook: rst2pdf
2585N/A @if [ ! -f $(DOCBOOKPY) ]; then \
2585N/A cd $(DOCTMP) ; \
2585N/A $(WGET) -q -r -np $(DOCBOOKRST_URL); \
2585N/A cd $(DOCBOOKRST_PATH); \
2585N/A python setup.py install --prefix=../../../../../$(DOCTOOLS); \
2585N/A cd ../../../../../ ; \
2585N/A # XXX this is ugly; \
2585N/A cp -r $(TOOLSPATH)/docutils $(TOOLSPATH)/docutils-0.8.1-py2.6.egg ; \
2585N/A rm -rf $(TOOLSPATH)/docutils ; \
2585N/A $(GPATCH) -f -R $(DOCBOOKPY) < docbook.patch; \
2585N/A fi
2585N/A
2573N/Aproto: doctmp doctools
2573N/A mkdir -p $(PROTO)
2585N/A @cp macros.txt $(PROTO)
2585N/A @echo ".. |version| replace:: $(VERSTAMP)" >> $(PROTO)/macros.txt
2573N/A
2573N/Adoctools:
2573N/A mkdir -p $(TOOLSPATH)
2573N/A
2573N/Adoctmp:
2573N/A mkdir $(DOCTMP)
2573N/A
2573N/A# tries to build all fragments, then builds the book itself
2573N/Acheck: $(BOOK_FRAGMENTS:%.txt=$(PROTO)/%.pdf) book
2573N/Acopy: $(BOOK_FRAGMENTS:%.txt=$(PROTO)/%.txt)
2573N/A
2585N/Abook: booktxt
2585N/A $(MAKE) BOOK_OPT=-b1 $(PROTO)/book.pdf
2585N/A
2585N/Axmlbook: booktxt
2585N/A $(MAKE) $(PROTO)/book.xml
2585N/A
2585N/Abooktxt: proto
2573N/A # Convert bold/italic mentions of "Chapter x" into hyperlinks
2573N/A # and concatenate into a single file, to render our book
2573N/A cat $(BOOK_FRAGMENTS) | \
2573N/A gsed -re 's#\*\*(Chapter [0-9]+)\*\*#`\1`_#g' | \
2573N/A gsed -re 's#\*(Chapter [0-9]+)\*#`\1`_#g' | \
2585N/A gsed -re 's#\*\*(Appendix [AB])\*\*#`\1`_#g' | \
2585N/A gsed -re 's#\*(Appendix [AB])\*#`\1`_#g' > $(PROTO)/book.txt
2573N/A
2585N/A @# XXX this is ugly, but means we get to reuse the %.pdf & %.xml targets
2573N/A cp $(PROTO)/book.txt book.txt
2573N/A
2573N/A$(PROTO)/%.txt: proto
2573N/A cp $*.txt $(PROTO)
2585N/A @cat $(PROTO)/macros.txt >> $(PROTO)/$*.txt
2573N/A
2585N/A$(PROTO)/%.pdf: tools proto $(PROTO)/%.txt
2573N/A @print "creating $(PROTO)/$*.pdf"
2573N/A $(RST2PDF) -o $@ $(PROTO)/$*.txt 2> $(DOCTMP)/$*.rst-output.txt
2573N/A @if [ -s $(DOCTMP)/$*.rst-output.txt ]; then \
2573N/A print "Errors/warnings found in $*.txt"; \
2573N/A cat $(DOCTMP)/$*.rst-output.txt; \
2573N/A if [ -z "$(IGNORE_ERRORS)" ]; then \
2573N/A rm $(DOCTMP)/$*.rst-output.txt; \
2573N/A exit 1;\
2573N/A fi; \
2573N/A fi;
2573N/A
2585N/A$(PROTO)/%.xml: tools proto $(PROTO)/%.txt
2585N/A @print "creating $(PROTO)/$*.xml"
2585N/A $(RST2DOCBOOK) $(PROTO)/$*.txt $@
2585N/A
2573N/A# convenience targets to build a single fragment
2573N/A%.txt: $(PROTO)/%.txt
2573N/A%.pdf: $(PROTO)/%.txt $(PROTO)/%.pdf
2573N/A
2573N/Aclean:
2573N/A rm -rf $(PROTO) $(DOCTMP)
2573N/A
2573N/Aclobber: clean
2573N/A rm -rf $(DOCTOOLS)
2573N/A