source: trunk/doc-new/Makefile @ 37418

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

doc-new: Convert all sections (h1-h9) to links so it's easy to link to subsections which are not in the table of contents.

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