source: trunk/doc-new/Makefile @ 38335

Last change on this file since 38335 was 38335, checked in by simon@…, 11 years ago

doc-new: Minor consistency documentation change to Makefile.

  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1# $Id: Makefile 38335 2008-07-16 09:57:27Z simon@macports.org $
2
3# Makefile to generate the macports html guide and the man pages.
4# The ports 'docbook-xsl', 'docbook-xml' and 'libxslt' have to be installed.
5
6# If your macports isn't installed in /opt/local you have to change PREFIX
7# here.
8
9
10# Prefix of the macports installation.
11PREFIX = /opt/local
12
13# Command abstraction variables.
14MKDIR    = /bin/mkdir
15CP       = /bin/cp
16RM       = /bin/rm
17SED      = /usr/bin/sed
18XSLTPROC = $(PREFIX)/bin/xsltproc
19XMLLINT  = $(PREFIX)/bin/xmllint
20
21# Data directories.
22GUIDE = guide
23MAN   = man
24# Source directories.
25GUIDE-SRC = $(GUIDE)/xml
26MAN-SRC   = $(MAN)/xml
27# Result directories.
28GUIDE-RESULT = $(GUIDE)/html
29MAN-RESULT   = $(MAN)/man/
30# Man temporary directory.
31MAN-TMP = $(MAN)/tmp
32
33# Path to the docbook xsl files.
34DOCBOOK   = $(PREFIX)/share/xsl/docbook-xsl
35GUIDE-XSL = $(DOCBOOK)/xhtml/profile-docbook.xsl
36MAN-XSL   = $(MAN)/resources/macports.xsl
37
38# Docbook html stylesheet for the guide.
39STYLESHEET = docbook.css
40# Additional parameters for the guide.
41STRINGPARAMS = --stringparam html.stylesheet $(STYLESHEET) \
42                     --stringparam section.autolabel 1 \
43                     --stringparam toc.section.depth 1 \
44                     --stringparam generate.toc "book toc" \
45                     --stringparam section.label.includes.component.label 1 \
46                     --stringparam profile.condition "noman"
47
48
49.PHONY: all guide man clean
50
51all: guide man
52
53# Generate the html guide using DocBook from the xml sources in $(GUIDE-SRC).
54guide:
55        $(MKDIR) -p $(GUIDE-RESULT)
56        $(CP) $(GUIDE)/resources/$(STYLESHEET) $(GUIDE-RESULT)/$(STYLESHEET)
57        $(CP) $(GUIDE)/resources/images/* $(GUIDE-RESULT)/
58        $(XSLTPROC) --xinclude $(STRINGPARAMS) --output $(GUIDE-RESULT)/index.html \
59            $(GUIDE-XSL) $(GUIDE-SRC)/guide.xml
60        # Convert all sections (h1-h9) to a link so it's easy to link to them.
61        # If someone knows a better way to do this please change it.
62        $(SED) -i "" -E \
63            's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
64            $(GUIDE-RESULT)/index.html
65
66# Generate the man pages using DocBook from the xml source in $(MAN-SRC).
67# The portfile-*.xml files in $(GUIDE-SRC) are copied to $(MAN-TMP) and
68# modified (section -> refsection) so they can be used as man xml source files
69# and then xincluded in the real man xml files in $(MAN-SRC).
70man: $(MAN-XSL)
71        $(MKDIR) -p $(MAN-RESULT)
72        $(MKDIR) -p $(MAN-TMP)
73        $(CP) $(GUIDE-SRC)/portfile-*.xml $(MAN-TMP)
74        $(CP) $(GUIDE-SRC)/portgroup-*.xml $(MAN-TMP)
75        $(SED) -i "" 's|<section|<refsection|g' $(MAN-TMP)/*
76        $(SED) -i "" 's|</section>|</refsection>|g' $(MAN-TMP)/*
77        $(XSLTPROC) --xinclude --output $(MAN-RESULT) $(MAN-XSL) \
78            $(MAN-SRC)/port.1.xml \
79            $(MAN-SRC)/portfile.7.xml \
80            $(MAN-SRC)/portgroup.7.xml \
81            $(MAN-SRC)/porthier.7.xml
82        $(RM) -r $(MAN-TMP)
83
84# Create XSL from template for man pages.
85$(MAN-XSL):
86        $(SED) 's:@PREFIX@:$(PREFIX):' $@.in > $@
87
88# Remove all temporary files generated by guide: and man:.
89clean:
90        $(RM) -rf $(GUIDE-RESULT)
91        $(RM) -rf $(MAN-RESULT)
92        $(RM) -rf $(MAN-TMP)
93        $(RM) -rf $(MAN-XSL)
94        $(RM) -f  guide.tmp.xml
95
96# Validate the xml files for the guide.
97# These two steps are necessary as otherwise xmllint complains about missing
98# ids.
99validate:
100        $(XMLLINT) --xinclude $(GUIDE-SRC)/guide.xml > guide.tmp.xml
101        $(XMLLINT) --loaddtd --valid --noout guide.tmp.xml
Note: See TracBrowser for help on using the repository browser.