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