summaryrefslogtreecommitdiff
path: root/dvb-spec/sgml/Makefile
blob: 9471e4b9872d6ae2da9cc793e2b43a585ef402e8 (plain)
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
SHELL=/bin/bash

SGMLS = \
	dvbapi.sgml \
	intro.sgml \
	frontend.sgml \
	demux.sgml \
	video.sgml \
	audio.sgml \
	ca.sgml \
	net.sgml \
	kdapi.sgml \
	examples.sgml \
	fdl.sgml \
	entities.sgml \

PDFPICS = \
	dvbstb.pdf \

GIFPICS = \
	dvbstb.png \

# Some Jade warnings for authors.
WARN =
#WARN = -w all -w duplicate -w net

# Stylesheet customization.
	# docbook/db2 syntax
CUSTOM_HTML = --dsl custom.dsl\#html
CUSTOM_PRINT = --dsl custom.dsl\#print
	# xmlto syntax
CUSTOM_HTML_XMLTO = -m custom.xsl
CUSTOM_PRINT_XMLTO = -m custom.xsl

all: html-single

html: html-build.stamp

html-single: html-single-build.stamp

pdf: pdf-build.stamp

man: man-build.stamp

man_install: man-build.stamp
	install -d /usr/local/man/man2
	install -b man/* /usr/local/man/man2

entities.sgml: Makefile
	echo "<!-- Generated file! Do not edit. -->" >$@
	echo -e "\n<!-- Subsections -->" >>$@
	for file in $(SGMLS) ; do \
	  entity=`echo "$$file" | sed 's/.sgml//;s/\./-/g'` ; \
	  if ! echo "$$file" | \
	    grep -q -E -e '^(func|vidioc|pixfmt)-' ; then \
	      echo "<!ENTITY sub-$$entity SYSTEM \"$$file\">" >>$@ ; \
	 fi ; \
	done

# Jade can auto-generate a list-of-tables, which includes all structs,
# but we only want data types, all types, and sorted please.
indices.sgml: Makefile
	echo "<!-- Generated file! Do not edit. -->" >$@
	echo -e "\n<index><title>List of Types</title>" >>$@
	for ident in $(TYPES) ; do \
	  id=`echo $$ident | tr _ -` ; \
	  echo "<indexentry><primaryie><link" \
	    "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
	done
	for ident in $(ENUMS) ; do \
	  echo "<indexentry><primaryie>enum&nbsp;<link" \
	    "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
	done
	for ident in $(STRUCTS) ; do \
	  id=`echo $$ident | tr _ -` ; \
	  echo "<indexentry><primaryie>struct&nbsp;<link" \
	    "linkend='$$id'>$$ident</link></primaryie></indexentry>" >>$@ ; \
	done
	echo "</index>" >>$@

# HTML version.
html-build.stamp: Makefile $(SGMLS) $(GIFPICS)
	rm -rf dvbapi
	if which xmlto >/dev/null ; then \
	  xmlto xhtml $(WARN) $(CUSTOM_HTML_XMLTO) -o dvbapi dvbapi.sgml ; \
	elif which docbook2html >/dev/null ; then \
	  export DCL="--dcl `find /usr/share/sgml -name xml.dcl |head -1`"; \
	  docbook2html $(WARN) $$DCL $(CUSTOM_HTML) --output dvbapi dvbapi.sgml ; \
	else \
	  export DCL="--dcl `find /usr/share/sgml -name xml.dcl |head -1`"; \
	  db2html $(WARN) $$DCL $(CUSTOM_HTML) --output dvbapi dvbapi.sgml ; \
	fi
	cp $(GIFPICS) dvbapi/
	cd dvbapi ; \
	test -e index.html || ln -s book1.htm index.html ; \
	test -e capture-example.html || \
	  ln -s `grep -l getopt_long *.htm` capture-example.html
	chmod a+rX -R dvbapi
	touch html-build.stamp

# For online version. When you have a dial-up connection a single file
# is more convenient than clicking through dozens of pages.
html-single-build.stamp: Makefile $(SGMLS) $(GIFPICS)
	rm -rf dvbapi-single
	if which xmlto >/dev/null ; then \
	  xmlto html-nochunks $(WARN) $(CUSTOM_HTML_XMLTO) -o dvbapi-single dvbapi.sgml ; \
	elif which docbook2html >/dev/null ; then \
	  export DCL="--dcl `find /usr/share/sgml -name xml.dcl |head -1`"; \
	  docbook2html $$DCL $(WARN) $(CUSTOM_HTML) --nochunks \
	    --output dvbapi-single dvbapi.sgml ; \
	else \
	  export DCL="--dcl `find /usr/share/sgml -name xml.dcl |head -1`"; \
	  db2html $$DCL $(WARN) $(CUSTOM_HTML) --nochunks \
	    --output dvbapi-single dvbapi.sgml ; \
	fi
	cp $(GIFPICS) dvbapi-single/
	chmod a+rX -R dvbapi-single
	touch html-single-build.stamp

# For printing.
pdf-build.stamp: Makefile $(SGMLS) $(PDFPICS)
	if which db2pdf >/dev/null ; then \
	  export DCL="--dcl `find /usr/share/sgml -name xml.dcl|head -1`"; \
	  db2pdf $$DCL $(WARN) $(CUSTOM_PRINT) dvbapi.sgml ; \
	elif which xmlto >/dev/null ; then \
	  xmlto pdf $(WARN) $(CUSTOM_HTML_XMLTO) -o dvbapi-single dvbapi.sgml ; \
	else \
	  export DCL="--dcl `find /usr/share/sgml -name xml.dcl |head -1`"; \
	  docbook2pdf $$DCL $(WARN) $(CUSTOM_PRINT) dvbapi.sgml ; \
	fi
	touch pdf-build.stamp


# For man
man-build.stamp: Makefile $(SGMLS) $(PDFPICS)
	xmlto man $(WARN) $(CUSTOM_HTML_XMLTO) -o man dvbapi.sgml

distclean clean:
	rm -f *.stamp
	rm -f indices.sgml entities.sgml