Makefile revision 2573
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#
2573N/A# $ make book
2573N/A# $ make check
2573N/A# $ make chpt1.pdf
2573N/A# $ make -e IGNORE_ERRORS=true chpt4.pdf
2573N/A# $ make clobber
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 \
2573N/A appendix1.txt \
2573N/A appendix2.txt
2573N/A
2573N/APROTO=../../proto/dev-guide
2573N/ADOCTMP=doctmp
2573N/ADOCTOOLS=doctools
2573N/ATOOLSPATH=$(DOCTOOLS)/lib/python2.6/site-packages
2573N/A
2573N/A# styles are searched under $(TOOLSPATH)/rst2pdf-0.16-py2.6.egg/rst2pdf/styles/
2573N/ASTYLE=serif.style
2573N/A
2573N/ARST2PDF=@PYTHONPATH=$(TOOLSPATH) $(DOCTOOLS)/bin/rst2pdf -s $(STYLE) $(BOOK_OPT)
2573N/A
2573N/A# when building the book, we add options specific to that here
2573N/ABOOK_OPT=
2573N/AEASY_INSTALL=PYTHONPATH=$(TOOLSPATH) /usr/bin/easy_install
2573N/AGPATCH=/usr/bin/gpatch
2573N/A
2573N/A# our version of docutils doesn't work with rst2pdf at the moment, so we need
2573N/A# to apply a patch to that code.
2573N/ACREATEPDF=$(TOOLSPATH)/rst2pdf-0.16-py2.6.egg/rst2pdf/createpdf.py
2573N/A
2573N/Aall: install
2573N/Ainstall: rst2pdf proto book
2573N/A
2573N/A# pull down a local copy of rst2pdf
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
2573N/Aproto: doctmp doctools
2573N/A mkdir -p $(PROTO)
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
2573N/Abook: 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' | \
2573N/A gsed -re 's#\*\*(Appendix [0-9]+)\*\*#`\1`_#g' | \
2573N/A gsed -re 's#\*(Appendix [0-9]+)\*#`\1`_#g' > $(PROTO)/book.txt
2573N/A
2573N/A @# XXX this is ugly, but means we get to reuse the %.pdf target
2573N/A cp $(PROTO)/book.txt book.txt
2573N/A $(MAKE) BOOK_OPT=-b1 $(PROTO)/book.pdf
2573N/A
2573N/A$(PROTO)/%.txt: proto
2573N/A cp $*.txt $(PROTO)
2573N/A
2573N/A$(PROTO)/%.pdf: rst2pdf 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
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