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