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