bsd.info.mk revision 31074
1#	$Id: bsd.info.mk,v 1.45 1997/10/12 18:54:34 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# What to do if there's no dir file there.  This is really gross!!!
106${DESTDIR}${INFODIR}/${INFODIRFILE}:
107	@(cd /usr/src/share/info; make install)
108
109.texi.info .texinfo.info:
110	${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \
111		-o ${.TARGET}
112
113.texi.dvi .texinfo.dvi:
114	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
115		${TEX} ${.IMPSRC} </dev/null
116	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
117		${TEX} ${.IMPSRC} </dev/null
118
119.texinfo.latin1 .texi.latin1:
120	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
121	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
122		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
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
139.for _f in ${FORMATS}
140IFILENS+= ${INFO:S/$/.${_f}/g}
141CLEANFILES+=${INFO:S/$/.${_f}*/g}
142.endfor
143
144.if !defined(NOINFO)
145.if !defined(NOINFOCOMPRESS)
146IFILES=	${IFILENS:S/$/${ICOMPRESS_EXT}/g:S/.html${ICOMPRESS_EXT}/.html/g}
147all: ${IFILES} _SUBDIR
148.else
149IFILES=	${IFILENS}
150all: ${IFILES} _SUBDIR
151.endif
152.else
153all:
154.endif
155
156.for _f in ${FORMATS}
157.for x in ${INFO:S/$/.${_f}/g}
158${x:S/$/${ICOMPRESS_EXT}/}:	${x}
159	${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
160.endfor
161.endfor
162
163.for x in ${INFO}
164INSTALLINFODIRS+= ${x:S/$/-install/}
165${x:S/$/-install/}: ${DESTDIR}${INFODIR}/${INFODIRFILE}
166	${INSTALLINFO} --defsection=${INFOSECTION} \
167		       --defentry=${INFOENTRY_${x}} \
168		       ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
169.endfor
170
171.PHONY: ${INSTALLINFODIRS}
172
173# The default is "info" and it can never be "bin"
174DISTRIBUTION?=	info
175.if ${DISTRIBUTION} == "bin"
176DISTRIBUTION=	info
177.endif
178
179.if !target(distribute)
180distribute: _SUBDIR
181.for dist in ${DISTRIBUTION}
182	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
183.endfor
184.endif
185
186.if defined(SRCS)
187CLEANFILES+=	${INFO}.texi
188${INFO}.texi: ${SRCS}
189	cat ${.ALLSRC} > ${.TARGET}
190.endif
191
192depend: _SUBDIR
193	@echo -n
194
195
196# tex garbage
197.if ${FORMATS:Mps} || ${FORMATS:Mdvi} || ${FORMATS:Mlatin1}
198.for _f in aux cp fn ky log out pg toc tp vr dvi
199CLEANFILES+=	${INFO:S/$/.${_f}/g} ${INFO:S/$/-la.${_f}/g}
200.endfor
201CLEANFILES+= ${INFO:S/$/-la.texi/g}
202.endif
203
204.if ${FORMATS:Mhtml}
205CLEANFILES+= ${INFO:S/$/.info.*.html/g} ${INFO:S/$/.info/g}
206.endif
207
208
209.if !defined(NOINFO) && defined(INFO)
210install: ${INSTALLINFODIRS} _SUBDIR
211.if ${IFILES:N*.html}
212	${INSTALL} ${COPY} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
213		${IFILES:N*.html} ${DESTDIR}${INFODIR}
214.endif
215.if ${FORMATS:Mhtml}
216	${INSTALL} ${COPY} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
217		${INFO:S/$/.info.*.html/g} ${DESTDIR}${INFODIR}
218.endif
219.else
220install:
221.endif
222
223.if !target(maninstall)
224maninstall: _SUBDIR
225.endif
226
227.include <bsd.dep.mk>
228.include <bsd.obj.mk>
229