Merge from vendor branch ZLIB:
[dragonfly.git] / share / mk / bsd.info.mk
1 # $FreeBSD: src/share/mk/bsd.info.mk,v 1.57.2.7 2003/05/21 13:00:46 ru Exp $
2 # $DragonFly: src/share/mk/bsd.info.mk,v 1.3 2004/03/22 20:58:15 dillon Exp $
3 #
4 # The include file <bsd.info.mk> handles installing GNU (tech)info files.
5 # Texinfo is a documentation system that uses a single source
6 # file to produce both on-line information and printed output.
7 #
8 #
9 # +++ variables +++
10 #
11 # CLEANFILES    Additional files to remove for the clean and cleandir targets.
12 #
13 # DESTDIR       Change the tree where the info files gets installed. [not set]
14 #
15 # DVIPS         A program which convert a TeX DVI file to PostScript [dvips]
16 #
17 # DVIPS2ASCII   A program to convert a PostScript file which was prior
18 #               converted from a TeX DVI file to ascii/latin1 [dvips2ascii]
19 #
20 # FORMATS       Indicates which output formats will be generated
21 #               (info, dvi, latin1, ps, html).  [info]
22 #
23 # ICOMPRESS_CMD Program to compress info files. Output is to
24 #               stdout. [${COMPRESS_CMD}]
25 #
26 # INFO          texinfo files, without suffix.  [set in Makefile] 
27 #
28 # INFO2HTML     A program for converting GNU info files into HTML files
29 #               [info2html]
30 #
31 # INFODIR       Base path for GNU's hypertext system
32 #               called Info (see info(1)). [${SHAREDIR}/info]
33 #
34 # INFODIRFILE   Top level node/index for info files. [dir]
35 #
36 # INFOGRP       Info group. [${SHAREGRP}]
37 #
38 # INFOMODE      Info mode. [${NOBINMODE}]
39 #
40 # INFOOWN       Info owner. [${SHAREOWN}]
41 #
42 # INFOSECTION   Default section (if one could not be found in
43 #               the Info file). [Miscellaneous]
44 #
45 # INSTALLINFO   A program for installing directory entries from Info
46 #               file in the ${INFODIR}/${INFODIRFILE}. [install-info]
47 #
48 # INSTALLINFOFLAGS      Options for ${INSTALLINFO} command. [--quiet]
49 #
50 # INSTALLINFODIRS       ???
51 #
52 # MAKEINFO      A program for converting GNU Texinfo files into Info
53 #               file. [makeinfo]
54 #
55 # MAKEINFOFLAGS         Options for ${MAKEINFO} command. [--no-split]
56 #
57 # NOINFO        Do not make or install info files. [not set]
58 #
59 # NOINFOCOMPRESS        If you do not want info files be
60 #                       compressed when they are installed. [not set]
61 #
62 # TEX           A program for converting tex files into dvi files [tex]
63 #
64 #
65 # +++ targets +++
66 #
67 #       install:
68 #               Install the info files.
69 #
70 #
71 # bsd.obj.mk: cleandir and obj
72
73 .include <bsd.init.mk>
74
75 MAKEINFO?=      makeinfo
76 MAKEINFOFLAGS+= --no-split # simplify some things, e.g., compression
77 SRCDIR?=        ${.CURDIR}
78 INFODIRFILE?=   dir
79 INSTALLINFO?=   install-info
80 INSTALLINFOFLAGS+=--quiet
81 INFOSECTION?=   Miscellaneous
82 ICOMPRESS_CMD?= ${COMPRESS_CMD}
83 ICOMPRESS_EXT?= ${COMPRESS_EXT}
84 FORMATS?=       info
85 INFO2HTML?=     info2html
86 TEX?=           tex
87 DVIPS?=         dvips
88 DVIPS2ASCII?=   dvips2ascii
89
90 .SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
91
92 .texi.info .texinfo.info:
93         ${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \
94                 -o ${.TARGET}
95
96 .texi.dvi .texinfo.dvi:
97         TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
98                 ${TEX} ${.IMPSRC} </dev/null
99 # Run again to resolve cross references.
100         TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
101                 ${TEX} ${.IMPSRC} </dev/null
102
103 .texinfo.latin1 .texi.latin1:
104         perl -npe 's/(^\s*\\input\s+texinfo\s+)/$$1\n@tex\n\\global\\hsize=120mm\n@end tex\n\n/' ${.IMPSRC} >> ${.IMPSRC:T:R}-la.texi
105         TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
106                 ${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
107 # Run again to resolve cross references.
108         TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
109                 ${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
110         ${DVIPS} -o /dev/stdout ${.IMPSRC:T:R}-la.dvi | \
111                 ${DVIPS2ASCII} > ${.TARGET}.new
112         mv -f ${.TARGET}.new ${.TARGET}
113
114 .dvi.ps:
115         ${DVIPS} -o ${.TARGET} ${.IMPSRC}       
116
117 .info.html:
118         ${INFO2HTML} ${.IMPSRC}
119         ln -f ${.TARGET:R}.info.Top.html ${.TARGET} 
120
121 .PATH: ${.CURDIR} ${SRCDIR}
122
123 .for _f in ${FORMATS}
124 IFILENS+=       ${INFO:S/$/.${_f}/}
125 .endfor
126
127 .if !defined(NOINFO)
128 CLEANFILES+=    ${IFILENS}
129 .if !defined(NOINFOCOMPRESS)
130 CLEANFILES+=    ${IFILENS:S/$/${ICOMPRESS_EXT}/}
131 IFILES= ${IFILENS:S/$/${ICOMPRESS_EXT}/:S/.html${ICOMPRESS_EXT}/.html/}
132 all: ${IFILES}
133 .else
134 IFILES= ${IFILENS}
135 all: ${IFILES}
136 .endif
137 .else
138 all:
139 .endif
140
141 .for x in ${IFILENS}
142 ${x:S/$/${ICOMPRESS_EXT}/}:     ${x}
143         ${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
144 .endfor
145
146 .for x in ${INFO}
147 INSTALLINFODIRS+= ${x:S/$/-install/}
148 ${x:S/$/-install/}:
149         ${INSTALLINFO} ${INSTALLINFOFLAGS} \
150             --defsection=${INFOSECTION} \
151             --defentry=${INFOENTRY_${x}} \
152             ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
153 .endfor
154
155 .ORDER: ${INFO:S/$/-install/}
156 .PHONY: ${INSTALLINFODIRS}
157
158 .if defined(SRCS)
159 CLEANFILES+=    ${INFO}.texi
160 ${INFO}.texi: ${SRCS}
161         cat ${.ALLSRC} > ${.TARGET}
162 .endif
163
164 # tex garbage
165 .if ${FORMATS:Mps} || ${FORMATS:Mdvi} || ${FORMATS:Mlatin1}
166 .for _f in aux cp fn ky log out pg toc tp vr dvi
167 CLEANFILES+=    ${INFO:S/$/.${_f}/} ${INFO:S/$/-la.${_f}/}
168 .endfor
169 CLEANFILES+=    ${INFO:S/$/-la.texi/}
170 .endif
171
172 .if ${FORMATS:Mhtml}
173 CLEANFILES+=    ${INFO:S/$/.info.*.html/} ${INFO:S/$/.info/}
174 .endif
175
176 .if !defined(NOINFO) && defined(INFO)
177 install: ${INSTALLINFODIRS}
178 .if ${IFILES:N*.html}
179         ${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
180                 ${IFILES:N*.html} ${DESTDIR}${INFODIR}
181 .endif
182 .if ${FORMATS:Mhtml}
183         ${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
184                 ${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR}
185 .endif
186 .else
187 # The indirection in the following is to avoid the null install rule
188 # "install:" from being overridden by the implicit .sh rule if there
189 # happens to be a source file named install.sh.  This assumes that there
190 # is no source file named __null_install.sh.
191 install: __null_install
192 __null_install:
193 .endif
194
195 .include <bsd.obj.mk>