bsd.info.mk revision 31782
1#	$Id: bsd.info.mk,v 1.46 1997/11/09 15:03:12 wosch 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# 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	??? [Miscellaneous]
44#
45# INFOTMPL	??? [${INFODIR}/dir-tmpl]
46#
47# INSTALLINFO	??? [install-info]
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#	depend:
67#		Dummy target, do nothing.
68#
69#	distribute:
70#		This is a variant of install, which will
71#		put the stuff into the right "distribution".
72#
73#	install:
74#		Install the info files.
75#
76#	maninstall:
77#		Dummy target, do nothing.
78#
79#
80# bsd.obj.mk: cleandir and obj
81
82.if exists(${.CURDIR}/../Makefile.inc)
83.include "${.CURDIR}/../Makefile.inc"
84.endif
85
86MAKEINFO?=	makeinfo
87MAKEINFOFLAGS+=	--no-split # simplify some things, e.g., compression
88SRCDIR?=	${.CURDIR}
89INFODIRFILE?=   dir
90INFOTMPL?=      ${INFODIR}/dir-tmpl
91INSTALLINFO?=   install-info
92INFOSECTION?=   Miscellaneous
93ICOMPRESS_CMD?=	${COMPRESS_CMD}
94ICOMPRESS_EXT?=	${COMPRESS_EXT}
95FORMATS?=	info
96INFO2HTML?=	info2html
97TEX?=		tex
98DVIPS?=		dvips
99DVIPS2ASCII?=	dvips2ascii
100
101.MAIN: all
102
103.SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
104
105.texi.info .texinfo.info:
106	${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \
107		-o ${.TARGET}
108
109.texi.dvi .texinfo.dvi:
110	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
111		${TEX} ${.IMPSRC} </dev/null
112# Run again to reolve cross references.
113	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
114		${TEX} ${.IMPSRC} </dev/null
115
116.texinfo.latin1 .texi.latin1:
117	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
118	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
119		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
120# Run again to reolve cross references.
121	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
122		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
123	${DVIPS} -o /dev/stdout ${.IMPSRC:T:R}-la.dvi | \
124		${DVIPS2ASCII} > ${.TARGET}.new
125	mv -f ${.TARGET}.new ${.TARGET}
126
127.dvi.ps:
128	${DVIPS} -o ${.TARGET} ${.IMPSRC} 	
129
130.info.html:
131	${INFO2HTML} ${.IMPSRC}
132	ln -f ${.TARGET:R}.info.Top.html ${.TARGET} 
133
134.PATH: ${.CURDIR} ${SRCDIR}
135
136.for _f in ${FORMATS}
137IFILENS+=	${INFO:S/$/.${_f}/}
138.endfor
139
140.if !defined(NOINFO)
141CLEANFILES+=	${IFILENS}
142.if !defined(NOINFOCOMPRESS)
143CLEANFILES+=	${IFILENS:S/$/${ICOMPRESS_EXT}/}
144IFILES=	${IFILENS:S/$/${ICOMPRESS_EXT}/:S/.html${ICOMPRESS_EXT}/.html/}
145all: ${IFILES} _SUBDIR
146.else
147IFILES=	${IFILENS}
148all: ${IFILES} _SUBDIR
149.endif
150.else
151all:
152.endif
153
154.for x in ${IFILENS}
155${x:S/$/${ICOMPRESS_EXT}/}:	${x}
156	${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
157.endfor
158
159.for x in ${INFO}
160INSTALLINFODIRS+= ${x:S/$/-install/}
161${x:S/$/-install/}: ${DESTDIR}${INFODIR}/${INFODIRFILE}
162	${INSTALLINFO} --defsection=${INFOSECTION} \
163		       --defentry=${INFOENTRY_${x}} \
164		       ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
165.endfor
166
167.PHONY: ${INSTALLINFODIRS}
168
169# The default is "info" and it can never be "bin"
170DISTRIBUTION?=	info
171.if ${DISTRIBUTION} == "bin"
172DISTRIBUTION=	info
173.endif
174
175.if !target(distribute)
176distribute: _SUBDIR
177.for dist in ${DISTRIBUTION}
178	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
179.endfor
180.endif
181
182.if defined(SRCS)
183CLEANFILES+=	${INFO}.texi
184${INFO}.texi: ${SRCS}
185	cat ${.ALLSRC} > ${.TARGET}
186.endif
187
188depend: _SUBDIR
189
190# tex garbage
191.if ${FORMATS:Mps} || ${FORMATS:Mdvi} || ${FORMATS:Mlatin1}
192.for _f in aux cp fn ky log out pg toc tp vr dvi
193CLEANFILES+=	${INFO:S/$/.${_f}/} ${INFO:S/$/-la.${_f}/}
194.endfor
195CLEANFILES+=	${INFO:S/$/-la.texi/}
196.endif
197
198.if ${FORMATS:Mhtml}
199CLEANFILES+=	${INFO:S/$/.info.*.html/} ${INFO:S/$/.info/}
200.endif
201
202.if !defined(NOINFO) && defined(INFO)
203install: ${INSTALLINFODIRS} _SUBDIR
204.if ${IFILES:N*.html}
205	${INSTALL} ${COPY} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
206		${IFILES:N*.html} ${DESTDIR}${INFODIR}
207.endif
208.if ${FORMATS:Mhtml}
209	${INSTALL} ${COPY} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
210		${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR}
211.endif
212.else
213install:
214.endif
215
216.if !target(maninstall)
217maninstall: _SUBDIR
218.endif
219
220.include <bsd.dep.mk>
221.include <bsd.obj.mk>
222