source: trunk/doc-new/Makefile @ 145057

Last change on this file since 145057 was 140263, checked in by raimue@…, 4 years ago

doc-new: Remove outdated man page directory

Update Makefile, move referenced prefix hierarchy to guide.

  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1# $Id: Makefile 140263 2015-09-15 16:58:39Z raimue@macports.org $
2
3# Makefile to generate the MacPorts HTML guide pages.
4# The ports 'docbook-xsl', 'docbook-xml' and 'libxslt' have to be installed.
5# For the guide-dblatex target, the 'dblatex' port is also required.
6
7# If your MacPorts isn't installed in /opt/local you have to change PREFIX
8# here.
9
10UNAME := $(shell uname)
11
12# Prefix of the MacPorts installation.
13PREFIX = /opt/local
14ifeq ($(UNAME), Linux)
15PREFIX = /usr
16endif
17
18# Command abstraction variables.
19MKDIR    = /bin/mkdir
20CP       = /bin/cp
21RM       = /bin/rm
22LN       = /bin/ln
23SED      = /usr/bin/sed
24ifeq ($(UNAME), Linux)
25SED      = /bin/sed
26endif
27TCLSH    = /usr/bin/tclsh
28XSLTPROC = $(PREFIX)/bin/xsltproc
29XMLLINT  = $(PREFIX)/bin/xmllint
30DBLATEX  = $(PREFIX)/bin/dblatex
31
32# Data directories.
33GUIDE = guide
34# Source directories.
35GUIDE_SRC = $(GUIDE)/xml
36# Result directories.
37GUIDE_RESULT         = $(GUIDE)/html
38GUIDE_RESULT_CHUNK   = $(GUIDE_RESULT)/chunked
39GUIDE_RESULT_DBLATEX = $(GUIDE)/dblatex
40
41# Path to the DocBook XSL files.
42DOCBOOK         = $(PREFIX)/share/xsl/docbook-xsl
43ifeq ($(UNAME), Linux)
44DOCBOOK         = /usr/local/share/xsl/docbook-xsl
45endif
46GUIDE_XSL       = $(GUIDE)/resources/single-page.xsl
47GUIDE_XSL_CHUNK = $(GUIDE)/resources/chunk.xsl
48
49# DocBook HTML stylesheet for the guide.
50STYLESHEET = docbook.css
51
52.PHONY: all guide guide-chunked guide-dblatex clean validate
53
54all: guide guide-chunked
55
56# Generate the HTML guide using DocBook from the XML sources in $(GUIDE_SRC).
57guide:
58        $(MKDIR) -p $(GUIDE_RESULT)
59        $(CP) $(GUIDE)/resources/$(STYLESHEET) $(GUIDE_RESULT)/$(STYLESHEET)
60        $(CP) $(GUIDE)/resources/images/* $(GUIDE_RESULT)/
61        $(CP) $(GUIDE)/resources/*.js $(GUIDE_RESULT)/
62ifeq ($(UNAME), Linux)
63        $(LN) -sfn $(DOCBOOK) $(GUIDE)/resources/xsl
64else
65        $(LN) -sfh $(DOCBOOK) $(GUIDE)/resources/xsl
66endif
67        $(XSLTPROC) --xinclude \
68            --output $(GUIDE_RESULT)/index.html \
69            $(GUIDE_XSL) $(GUIDE_SRC)/guide.xml
70        # Convert all sections (h1-h9) to a link so it's easy to link to them.
71        # If someone knows a better way to do this please change it.
72ifeq ($(UNAME), Linux)
73        $(SED) -i -r -e \
74            's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
75            $(GUIDE_RESULT)/index.html
76else
77        $(SED) -i "" -E \
78            's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
79            $(GUIDE_RESULT)/index.html
80endif
81
82# Generate the chunked HTML guide with one section per file.
83guide-chunked:
84        $(MKDIR) -p $(GUIDE_RESULT_CHUNK)
85        $(CP) $(GUIDE)/resources/$(STYLESHEET) $(GUIDE_RESULT_CHUNK)/$(STYLESHEET)
86        $(CP) $(GUIDE)/resources/images/* $(GUIDE_RESULT_CHUNK)/
87ifeq ($(UNAME), Linux)
88        $(LN) -sfn $(DOCBOOK) $(GUIDE)/resources/xsl
89else
90        $(LN) -sfh $(DOCBOOK) $(GUIDE)/resources/xsl
91endif
92        $(XSLTPROC) --xinclude \
93            --output $(GUIDE_RESULT_CHUNK)/index.html \
94            $(GUIDE_XSL_CHUNK) $(GUIDE_SRC)/guide.xml
95        # Convert all sections (h1-h9) to a link so it's easy to link to them.
96        # If someone knows a better way to do this please change it.
97ifeq ($(UNAME), Linux)
98        $(SED) -i -r -e \
99            's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
100            $(GUIDE_RESULT_CHUNK)/*.html
101else
102        $(SED) -i "" -E \
103            's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
104            $(GUIDE_RESULT_CHUNK)/*.html
105endif
106        # Add the table of contents to every junked HTML file.
107        # If someone knows a better way to do this please change it.
108        $(TCLSH) toc-for-chunked.tcl $(GUIDE_RESULT_CHUNK)
109
110# Generate the guide as a PDF.
111guide-dblatex: SUFFIX = pdf
112guide-dblatex:
113        $(MKDIR) -p $(GUIDE_RESULT_DBLATEX)
114        $(DBLATEX) \
115                --fig-path="$(GUIDE)/resources/images" \
116                --type="$(SUFFIX)" \
117                --param='toc.section.depth=2' \
118                --param='doc.section.depth=3' \
119                --output="$(GUIDE_RESULT_DBLATEX)/macports-guide.$(SUFFIX)" \
120        $(GUIDE_SRC)/guide.xml
121
122# Remove all temporary files generated by guide:.
123clean:
124        $(RM) -rf $(GUIDE)/resources/xsl
125        $(RM) -rf $(GUIDE_RESULT)
126        $(RM) -rf $(GUIDE_RESULT_DBLATEX)
127        $(RM) -f  guide.tmp.xml
128
129# Validate the XML files for the guide.
130validate:
131        $(XMLLINT) --xinclude --loaddtd --postvalid --noout $(GUIDE_SRC)/guide.xml
Note: See TracBrowser for help on using the repository browser.