bsd.info.mk revision 56537
1# $FreeBSD: head/share/mk/bsd.info.mk 56537 2000-01-24 16:11:19Z ru $
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# DISTRIBUTION	Name of distribution. [info]
15#
16# DVIPS		A program which convert a TeX DVI file to PostScript [dvips]
17#
18# DVIPS2ASCII	A program to convert a PostScript file which was prior
19#		converted from a TeX DVI file to ascii/latin1 [dvips2ascii]
20#
21# FORMATS 	Indicates which output formats will be generated
22#               (info, dvi, latin1, ps, html).  [info]
23#
24# ICOMPRESS_CMD	Program to compress info files. Output is to
25#		stdout. [${COMPRESS_CMD}]
26#
27# INFO		texinfo files, without suffix.  [set in Makefile] 
28#
29# INFO2HTML	A program for converting GNU info files into HTML files
30#		[info2html]
31#
32# INFODIR	Base path for GNU's hypertext system
33#		called Info (see info(1)). [${SHAREDIR}/info]
34#
35# INFODIRFILE	Top level node/index for info files. [dir]
36#
37# INFOGRP	Info group. [${SHAREGRP}]
38#
39# INFOMODE	Info mode. [${NOBINMODE}]
40#
41# INFOOWN	Info owner. [${SHAREOWN}]
42#
43# INFOSECTION	Default section (if one could not be found in
44#		the Info file). [Miscellaneous]
45#
46# INSTALLINFO	A program for installing directory entries from Info
47#		file in the ${INFODIR}/${INFODIRFILE}. [install-info]
48#
49# INSTALLINFOFLAGS	Options for ${INSTALLINFO} command. [--quiet]
50#
51# INSTALLINFODIRS	???
52#
53# MAKEINFO	A program for converting GNU Texinfo files into Info
54#		file. [makeinfo]
55#
56# MAKEINFOFLAGS		Options for ${MAKEINFO} command. [--no-split]
57#
58# NOINFO	Do not make or install info files. [not set]
59#
60# NOINFOCOMPRESS	If you do not want info files be
61#			compressed when they are installed. [not set]
62#
63# TEX		A program for converting tex files into dvi files [tex]
64#
65#
66# +++ targets +++
67#
68#	distribute:
69#		This is a variant of install, which will
70#		put the stuff into the right "distribution".
71#
72#	install:
73#		Install the info files.
74#
75#	maninstall:
76#		Dummy target, do nothing.
77#
78#
79# bsd.obj.mk: cleandir and obj
80
81.if !target(__initialized__)
82__initialized__:
83.if exists(${.CURDIR}/../Makefile.inc)
84.include "${.CURDIR}/../Makefile.inc"
85.endif
86.endif
87
88MAKEINFO?=	makeinfo
89MAKEINFOFLAGS+=	--no-split # simplify some things, e.g., compression
90SRCDIR?=	${.CURDIR}
91INFODIRFILE?=   dir
92INSTALLINFO?=   install-info
93INSTALLINFOFLAGS+=--quiet
94INFOSECTION?=   Miscellaneous
95ICOMPRESS_CMD?=	${COMPRESS_CMD}
96ICOMPRESS_EXT?=	${COMPRESS_EXT}
97FORMATS?=	info
98INFO2HTML?=	info2html
99TEX?=		tex
100DVIPS?=		dvips
101DVIPS2ASCII?=	dvips2ascii
102
103.MAIN: all
104
105.SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
106
107.texi.info .texinfo.info:
108	${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \
109		-o ${.TARGET}
110
111.texi.dvi .texinfo.dvi:
112	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
113		${TEX} ${.IMPSRC} </dev/null
114# Run again to reolve cross references.
115	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
116		${TEX} ${.IMPSRC} </dev/null
117
118.texinfo.latin1 .texi.latin1:
119	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
120	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
121		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
122# Run again to reolve cross references.
123	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
124		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
125	${DVIPS} -o /dev/stdout ${.IMPSRC:T:R}-la.dvi | \
126		${DVIPS2ASCII} > ${.TARGET}.new
127	mv -f ${.TARGET}.new ${.TARGET}
128
129.dvi.ps:
130	${DVIPS} -o ${.TARGET} ${.IMPSRC} 	
131
132.info.html:
133	${INFO2HTML} ${.IMPSRC}
134	ln -f ${.TARGET:R}.info.Top.html ${.TARGET} 
135
136.PATH: ${.CURDIR} ${SRCDIR}
137
138.for _f in ${FORMATS}
139IFILENS+=	${INFO:S/$/.${_f}/}
140.endfor
141
142.if !defined(NOINFO)
143CLEANFILES+=	${IFILENS}
144.if !defined(NOINFOCOMPRESS)
145CLEANFILES+=	${IFILENS:S/$/${ICOMPRESS_EXT}/}
146IFILES=	${IFILENS:S/$/${ICOMPRESS_EXT}/:S/.html${ICOMPRESS_EXT}/.html/}
147all: ${IFILES} _SUBDIR
148.else
149IFILES=	${IFILENS}
150all: ${IFILES} _SUBDIR
151.endif
152.else
153all:
154.endif
155
156.for x in ${IFILENS}
157${x:S/$/${ICOMPRESS_EXT}/}:	${x}
158	${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
159.endfor
160
161.for x in ${INFO}
162INSTALLINFODIRS+= ${x:S/$/-install/}
163${x:S/$/-install/}: ${DESTDIR}${INFODIR}/${INFODIRFILE}
164	${INSTALLINFO} ${INSTALLINFOFLAGS} \
165	    --defsection=${INFOSECTION} \
166	    --defentry=${INFOENTRY_${x}} \
167	    ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
168.endfor
169
170.PHONY: ${INSTALLINFODIRS}
171
172DISTRIBUTION?=	bin
173
174.if !target(distribute)
175distribute: _SUBDIR
176.for dist in ${DISTRIBUTION}
177	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
178.endfor
179.endif
180
181.if defined(SRCS)
182CLEANFILES+=	${INFO}.texi
183${INFO}.texi: ${SRCS}
184	cat ${.ALLSRC} > ${.TARGET}
185.endif
186
187# tex garbage
188.if ${FORMATS:Mps} || ${FORMATS:Mdvi} || ${FORMATS:Mlatin1}
189.for _f in aux cp fn ky log out pg toc tp vr dvi
190CLEANFILES+=	${INFO:S/$/.${_f}/} ${INFO:S/$/-la.${_f}/}
191.endfor
192CLEANFILES+=	${INFO:S/$/-la.texi/}
193.endif
194
195.if ${FORMATS:Mhtml}
196CLEANFILES+=	${INFO:S/$/.info.*.html/} ${INFO:S/$/.info/}
197.endif
198
199.if !defined(NOINFO) && defined(INFO)
200install: ${INSTALLINFODIRS} _SUBDIR
201.if ${IFILES:N*.html}
202	${INSTALL} ${COPY} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
203		${IFILES:N*.html} ${DESTDIR}${INFODIR}
204.endif
205.if ${FORMATS:Mhtml}
206	${INSTALL} ${COPY} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
207		${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR}
208.endif
209.else
210install:
211.endif
212
213.if !target(maninstall)
214maninstall: _SUBDIR
215.endif
216
217.if !target(regress)
218regress:
219.endif
220
221.include <bsd.obj.mk>
222