File: Makefile

package info (click to toggle)
gforge 4.5.14-22etch13
  • links: PTS
  • area: main
  • in suites: etch
  • size: 13,004 kB
  • ctags: 11,918
  • sloc: php: 36,047; sql: 29,050; sh: 10,538; perl: 6,496; xml: 3,810; makefile: 341; python: 263; ansic: 256
file content (151 lines) | stat: -rw-r--r-- 5,138 bytes parent folder | download | duplicates (2)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
SRC = docbook/
TARGET = build/
XSL = xsl/
DOCBOOK_XSL = ${XSL}docbook/
DB2LATEX_XSL = ${XSL}db2latex/
#DEVNULL = >>/tmp/debug 2>&1
DEVNULL = &> /dev/null

BOOKS=gforge_manual
ARTICLES=administration_guide user_guide contribution_guide installation_guide

all: clean html html-chunk pdf

html: validate prepare
	##
	# Generating HTML output
	#
	@for book in ${BOOKS}; do \
		echo '# . Generating HTML output for book '$$book; \
		xsltproc --xinclude --output ${TARGET}$$book/$$book.plain.html ${XSL}book_html.xsl ${SRC}$$book.xml; \
		tar -czf ${TARGET}$$book/$$book.plain.tar.gz ${TARGET}$$book/$$book.plain.html; \
	done;

	@for article in ${ARTICLES}; do \
		echo '# . Generating HTML output for article '$$article; \
		xsltproc --xinclude --output ${TARGET}$$article/$$article.plain.html ${XSL}article_html.xsl ${SRC}$$article/$$article.xml; \
		tar -czf ${TARGET}$$article/$$article.plain.tar.gz ${TARGET}$$article/$$article.plain.html; \
	done;
	#
	# Done
	##

html-chunk: validate prepare
	##
	# Generating HTML chunked output
	#
	@for book in ${BOOKS}; do \
		echo '# . Generating HTML chunked output for book '$$book; \
		test -d ${TARGET}$$book/$$book || mkdir ${TARGET}$$book/$$book.chunk; \
		xsltproc --xinclude --stringparam base.dir ${TARGET}$$book/$$book.chunk/ ${XSL}book_html_chunk.xsl ${SRC}$$book.xml ${DEVNULL}; \
		tar -czf ${TARGET}$$book/$$book.chunk.tar.gz ${TARGET}$$book/$$book.chunk; \
	done;

	@for article in ${ARTICLES}; do \
		echo '# . Generating HTML chunked output for article '$$article; \
		test -d ${TARGET}$$article/$$article || mkdir ${TARGET}$$article/$$article.chunk; \
		xsltproc --xinclude --stringparam base.dir ${TARGET}$$article/$$article.chunk/ ${XSL}article_html_chunk.xsl ${SRC}$$article/$$article.xml ${DEVNULL}; \
		tar -czf ${TARGET}$$article/$$article.chunk.tar.gz ${TARGET}$$article/$$article.chunk; \
	done;
	#
	# Done
	##

pdf: validate prepare
	##
	# Generating PDF output
	#
	@for book in ${BOOKS}; do \
		echo '# . Generating PDF output for book '$$book; \
		xsltproc --xinclude --output ${TARGET}$$book/$$book.tex ${XSL}book_pdf.xsl ${SRC}$$book.xml ${DEVNULL}; \
		(cd ${TARGET}$$book; pdflatex -interaction=batchmode $$book.tex ${DEVNULL};); \
		(cd ${TARGET}$$book; pdflatex -interaction=batchmode $$book.tex ${DEVNULL};); \
		(cd ${TARGET}$$book; pdflatex -interaction=batchmode $$book.tex ${DEVNULL};); \
		(cd ${TARGET}$$book; rm -f *.aux *.glo *.idx *.log *.out *.tex *.toc ${DEVNULL};); \
	done;

	@for article in ${ARTICLES}; do \
		echo '# . Generating PDF output for article '$$article; \
		xsltproc --xinclude --output ${TARGET}$$article/$$article.tex ${XSL}article_pdf.xsl ${SRC}$$article/$$article.xml ${DEVNULL}; \
		(cd ${TARGET}$$article; pdflatex -interaction=batchmode $$article.tex ${DEVNULL};); \
		(cd ${TARGET}$$article; pdflatex -interaction=batchmode $$article.tex ${DEVNULL};); \
		(cd ${TARGET}$$article; pdflatex -interaction=batchmode $$article.tex ${DEVNULL};); \
		(cd ${TARGET}$$article; rm -f *.aux *.glo *.idx *.log *.out *.tex *.toc ${DEVNULL};); \
	done;
	#
	# Done
	##

prepare:
	##
	# Preparing build environment
	#
	@test -d ${TARGET} || mkdir ${TARGET};
	@for book in ${BOOKS}; do \
		test -d ${TARGET}$$book || mkdir ${TARGET}$$book; \
	done;
	@for article in ${ARTICLES}; do \
		test -d ${TARGET}$$article || mkdir ${TARGET}$$article; \
	done;
	# Done
	##

validate:
	##
	# Validating documents
	#
	@for book in ${BOOKS}; do \
		if (xmllint --xinclude --noout --postvalid ${SRC}$$book.xml ${DEVNULL}); then \
			echo '# . Validating book '$$book' : [ OK ]'; \
		else \
			echo '# . Validating book '$$book' : [ ERROR ]'; \
			echo '#'; \
			echo '# ERROR : please check your docbook documents using xmllint first'; \
			echo '##'; \
			exit 1; \
		fi; \
	done;
	@for article in ${ARTICLES}; do \
		if (xmllint --xinclude --noout --postvalid ${SRC}$$article/$$article.xml ${DEVNULL}); then \
			echo '# . Validating article '$$article' : [ OK ]'; \
		else \
			echo '# . Validating article '$$article' : [ ERROR ]'; \
			echo '#'; \
			echo '# ERROR : please check your docbook documents using xmllint first'; \
			echo '##'; \
			exit 1; \
		fi; \
	done;
	#
	# Done
	##

clean:
	##
	# Cleaning build environment
	#
	@-rm -rf $(TARGET)*
	# Done
	##
	@[ -L xsl/docbook ] && rm xsl/docbook || true
	@[ -L xsl/db2latex/xsl ] && rm xsl/db2latex/xsl || true
	@[ -d xsl/db2latex ] && rmdir xsl/db2latex || true


debian: debianhtml debianpdf

debianhtml:
	@echo "=====> Intalling necessary packages"
	@sudo apt-get install docbook-xml docbook-xsl libxml2-utils xsltproc
	@echo "=====> Link to docbook"
	@[ ! -L xsl/docbook ] && ln -s /usr/share/xml/docbook/stylesheet/nwalsh xsl/docbook || echo "docbook link already done"
	@make html

debianpdf:
	@echo "=====> Intalling necessary packages"
	@sudo apt-get install db2latex-xsl tetex-extra latex-ucs
	@echo "Making db2latex dir"
	@[ ! -d xsl/db2latex ] && mkdir xsl/db2latex || echo "db2latex dir already done"
	@echo "=====> Link to docbook"
	@[ ! -L xsl/db2latex/xsl ] && ln -s /usr/share/xml/docbook/stylesheet/db2latex/latex xsl/db2latex/xsl || echo "docbook link already done"
	@make pdf