# $Id: Makefile 35199 2008-03-20 13:32:48Z simon@macports.org $
# Makefile to generate the macports html guide and the man pages.
# The ports 'docbook-xsl', 'docbook-xml' and 'libxslt' have to be
# installed.
# If your macports isn't installed in /opt/local you have to change PREFIX
# here and update man/resources/macports.xsl to use your port installation!
# prefix of the macports installation:
PREFIX = /opt/local
# command abstraction variables:
MKDIR = /bin/mkdir
CP = /bin/cp
RM = /bin/rm
SED = /usr/bin/sed
XSLTPROC = $(PREFIX)/bin/xsltproc
XMLLINT = $(PREFIX)/bin/xmllint
# data directories:
GUIDE = guide
MAN = man
# source directories:
GUIDE-SRC = $(GUIDE)/xml
MAN-SRC = $(MAN)/xml
# result directories:
GUIDE-RESULT = $(GUIDE)/html
MAN-RESULT = $(MAN)/man/
# man temporary directory:
MAN-TMP = $(MAN)/tmp
# path to the docbook xsl files:
DOCBOOK = $(PREFIX)/share/xsl/docbook-xsl
GUIDE-XSL = $(DOCBOOK)/xhtml/profile-docbook.xsl
MAN-XSL = $(MAN)/resources/macports.xsl
# docbook html stylesheet for the guide:
STYLESHEET = docbook.css
# additional parameters for the guide:
STRINGPARAMS = --stringparam html.stylesheet $(STYLESHEET) \
--stringparam section.autolabel 1 \
--stringparam toc.section.depth 1 \
--stringparam generate.toc "book toc" \
--stringparam section.label.includes.component.label 1 \
--stringparam profile.condition "noman"
.PHONY: all guide man clean
all: guide man
# Generate the html guide using DocBook from the xml sources in $(GUIDE-SRC).
guide:
$(MKDIR) -p $(GUIDE-RESULT)
$(CP) $(GUIDE)/resources/$(STYLESHEET) $(GUIDE-RESULT)/$(STYLESHEET)
$(CP) $(GUIDE)/resources/images/* $(GUIDE-RESULT)/
$(XSLTPROC) --xinclude $(STRINGPARAMS) --output $(GUIDE-RESULT)/index.html \
$(GUIDE-XSL) $(GUIDE-SRC)/guide.xml
# Convert all sections (h1-h9) to a link so it's easy to link to them.
# If someone knows a better way to do this please change it.
$(SED) -i "" -E \
's|(]*>)([^<]*)()|\1\3\4|g' \
$(GUIDE-RESULT)/index.html
# Generate the man pages using DocBook from the xml source in $(MAN-SRC).
# The portfile-*.xml files in $(GUIDE-SRC) are copied to $(MAN-TMP) and
# modified (section -> refsection) so they can be used as man xml source files
# and then xincluded in the real man xml files in $(MAN-SRC).
man:
$(MKDIR) -p $(MAN-RESULT)
$(MKDIR) -p $(MAN-TMP)
$(CP) $(GUIDE-SRC)/portfile-*.xml $(MAN-TMP)
$(CP) $(GUIDE-SRC)/portgroup-*.xml $(MAN-TMP)
$(SED) -i "" 's|||g' $(MAN-TMP)/*
$(XSLTPROC) --xinclude --output $(MAN-RESULT) $(MAN-XSL) \
$(MAN-SRC)/port.1.xml \
$(MAN-SRC)/portfile.7.xml \
$(MAN-SRC)/portgroup.7.xml \
$(MAN-SRC)/porthier.7.xml
$(RM) -r $(MAN-TMP)
# Remove all temporary files generated by guide: and man:.
clean:
$(RM) -rf $(GUIDE-RESULT)
$(RM) -rf $(MAN-RESULT)
$(RM) -rf $(MAN-TMP)
$(RM) -f guide.tmp.xml
# Validate the xml files for the guide.
# These two steps are necessary as otherwise xmllint complains about missing
# ids.
validate:
$(XMLLINT) --xinclude $(GUIDE-SRC)/guide.xml > guide.tmp.xml
$(XMLLINT) --loaddtd --valid --noout guide.tmp.xml