xref: /freebsd/share/mk/bsd.info.mk (revision 1f4bcc459a76b7aa664f3fd557684cd0ba6da352)
1# $FreeBSD$
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# NO_INFOCOMPRESS	If you do not want info files be
57#			compressed when they are installed. [not set]
58#
59# TEX		A program for converting tex files into dvi files [tex]
60#
61#
62# +++ targets +++
63#
64#	install:
65#		Install the info files.
66#
67#
68# bsd.obj.mk: cleandir and obj
69
70.include <bsd.init.mk>
71
72MAKEINFO?=	makeinfo
73MAKEINFOFLAGS+=	--no-split # simplify some things, e.g., compression
74SRCDIR?=	${.CURDIR}
75INFODIRFILE?=   dir
76INSTALLINFO?=   install-info
77INSTALLINFOFLAGS+=--quiet
78INFOSECTION?=   Miscellaneous
79ICOMPRESS_CMD?=	${COMPRESS_CMD}
80ICOMPRESS_EXT?=	${COMPRESS_EXT}
81FORMATS?=	info
82INFO2HTML?=	info2html
83TEX?=		tex
84DVIPS?=		dvips
85DVIPS2ASCII?=	dvips2ascii
86
87.SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
88
89.texi.info .texinfo.info:
90	${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \
91		-o ${.TARGET}
92
93.texi.dvi .texinfo.dvi:
94	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
95		${TEX} ${.IMPSRC} </dev/null
96# Run again to resolve cross references.
97	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
98		${TEX} ${.IMPSRC} </dev/null
99
100.texinfo.latin1 .texi.latin1:
101	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
102	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
103		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
104# Run again to resolve cross references.
105	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
106		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
107	${DVIPS} -o /dev/stdout ${.IMPSRC:T:R}-la.dvi | \
108		${DVIPS2ASCII} > ${.TARGET}.new
109	mv -f ${.TARGET}.new ${.TARGET}
110
111.dvi.ps:
112	${DVIPS} -o ${.TARGET} ${.IMPSRC}
113
114.info.html:
115	${INFO2HTML} ${.IMPSRC}
116	${INSTALL_LINK} ${.TARGET:R}.info.Top.html ${.TARGET}
117
118.PATH: ${.CURDIR} ${SRCDIR}
119
120.for _f in ${FORMATS}
121IFILENS+=	${INFO:S/$/.${_f}/}
122.endfor
123
124CLEANFILES+=	${IFILENS}
125.if !defined(NO_INFOCOMPRESS)
126CLEANFILES+=	${IFILENS:S/$/${ICOMPRESS_EXT}/}
127IFILES=	${IFILENS:S/$/${ICOMPRESS_EXT}/:S/.html${ICOMPRESS_EXT}/.html/}
128all: ${IFILES}
129.else
130IFILES=	${IFILENS}
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