xref: /freebsd/share/mk/bsd.info.mk (revision d48a2d23039536ab9f92f88a72c27b9895796abf)
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/}
128.else
129IFILES=	${IFILENS}
130.endif
131.if !defined(_SKIP_BUILD)
132all: ${IFILES}
133.endif
134
135.for x in ${IFILENS}
136${x:S/$/${ICOMPRESS_EXT}/}:	${x}
137	${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
138.endfor
139
140.for x in ${INFO}
141INSTALLINFODIRS+= ${x:S/$/-install/}
142${x:S/$/-install/}:
143.if !empty(.MAKEFLAGS:M-j)
144	lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
145	${INSTALLINFO} ${INSTALLINFOFLAGS} \
146	    --defsection=${INFOSECTION} \
147	    --defentry=${INFOENTRY_${x}} \
148	    ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
149.else
150	${INSTALLINFO} ${INSTALLINFOFLAGS} \
151	    --defsection=${INFOSECTION} \
152	    --defentry=${INFOENTRY_${x}} \
153	    ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
154.endif
155.endfor
156
157.PHONY: ${INSTALLINFODIRS}
158
159.if defined(SRCS)
160CLEANFILES+=	${INFO}.texi
161${INFO}.texi: ${SRCS}
162	cat ${.ALLSRC} > ${.TARGET}
163.endif
164
165# tex garbage
166.if !empty(FORMATS:Mps) || !empty(FORMATS:Mdvi) || !empty(FORMATS:Mlatin1)
167.for _f in aux cp fn ky log out pg toc tp vr dvi
168CLEANFILES+=	${INFO:S/$/.${_f}/} ${INFO:S/$/-la.${_f}/}
169.endfor
170CLEANFILES+=	${INFO:S/$/-la.texi/}
171.endif
172
173.if !empty(FORMATS:Mhtml)
174CLEANFILES+=	${INFO:S/$/.info.*.html/} ${INFO:S/$/.info/}
175.endif
176
177.if defined(INFO)
178install: ${INSTALLINFODIRS}
179.if !empty(IFILES:N*.html)
180	${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
181		${IFILES:N*.html} ${DESTDIR}${INFODIR}/
182.endif
183.if !empty(FORMATS:Mhtml)
184	${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
185		${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR}/
186.endif
187.else
188# The indirection in the following is to avoid the null install rule
189# "install:" from being overridden by the implicit .sh rule if there
190# happens to be a source file named install.sh.  This assumes that there
191# is no source file named __null_install.sh.
192install: __null_install
193__null_install:
194.endif
195
196.include <bsd.obj.mk>
197