public
Description: Git mirror of the MacPorts svn repo
Homepage: http://www.macports.org
Clone URL: git://github.com/kballard/macports.git
Search Repo:
kballard (author)
Fri Apr 25 09:49:08 -0700 2008
commit  cba202f1da82e7a9775df792f5193447afbdcff2
tree    70661c60e631ae7ef728d758a747d04f044bf8b1
parent  d96fe061e892bcdfb1652b3722c6473624f1dd42
macports / doc-new / Makefile
100644 98 lines (82 sloc) 3.261 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# $Id$
 
# 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|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\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|<section|<refsection|g' $(MAN-TMP)/*
  $(SED) -i "" 's|</section>|</refsection>|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