bsd.info.mk revision 42901
1#	$Id: bsd.info.mk,v 1.53 1999/01/20 05:48:19 markm 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#	distribute:
67#		This is a variant of install, which will
68#		put the stuff into the right "distribution".
69#
70#	install:
71#		Install the info files.
72#
73#	maninstall:
74#		Dummy target, do nothing.
75#
76#
77# bsd.obj.mk: cleandir and obj
78
79.if !target(__initialized__)
80__initialized__:
81.if exists(${.CURDIR}/../Makefile.inc)
82.include "${.CURDIR}/../Makefile.inc"
83.endif
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
96GREP?=		grep
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.texi.info .texinfo.info:
107	${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \
108		-o ${.TARGET}
109
110.texi.dvi .texinfo.dvi:
111	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
112		${TEX} ${.IMPSRC} </dev/null
113# Run again to reolve cross references.
114	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
115		${TEX} ${.IMPSRC} </dev/null
116
117.texinfo.latin1 .texi.latin1:
118	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
119	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
120		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
121# Run again to reolve cross references.
122	env TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
123		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
124	${DVIPS} -o /dev/stdout ${.IMPSRC:T:R}-la.dvi | \
125		${DVIPS2ASCII} > ${.TARGET}.new
126	mv -f ${.TARGET}.new ${.TARGET}
127
128.dvi.ps:
129	${DVIPS} -o ${.TARGET} ${.IMPSRC} 	
130
131.info.html:
132	${INFO2HTML} ${.IMPSRC}
133	ln -f ${.TARGET:R}.info.Top.html ${.TARGET} 
134
135.PATH: ${.CURDIR} ${SRCDIR}
136
137.for _f in ${FORMATS}
138IFILENS+=	${INFO:S/$/.${_f}/}
139.endfor
140
141.if !defined(NOINFO)
142CLEANFILES+=	${IFILENS}
143.if !defined(NOINFOCOMPRESS)
144CLEANFILES+=	${IFILENS:S/$/${ICOMPRESS_EXT}/}
145IFILES=	${IFILENS:S/$/${ICOMPRESS_EXT}/:S/.html${ICOMPRESS_EXT}/.html/}
146all: ${IFILES} _SUBDIR
147.else
148IFILES=	${IFILENS}
149all: ${IFILES} _SUBDIR
150.endif
151.else
152all:
153.endif
154
155.for x in ${IFILENS}
156${x:S/$/${ICOMPRESS_EXT}/}:	${x}
157	${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
158.endfor
159
160.for x in ${INFO}
161INSTALLINFODIRS+= ${x:S/$/-install/}
162${x:S/$/-install/}: ${DESTDIR}${INFODIR}/${INFODIRFILE}
163	-__section=`${GREP} "^INFO-DIR-SECTION" ${x}.info`; \
164	__entry=`${GREP} "^START-INFO-DIR-ENTRY" ${x}.info`; \
165	if [ ! -z "$$__section" ]; then \
166		if [ ! -z "$$__entry" ]; then \
167			${INSTALLINFO}  ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}; \
168		else \
169			${INSTALLINFO}  --entry=${INFOENTRY_${x}} \
170				${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}; \
171		fi \
172	else \
173		if [ ! -z "$$__entry" ]; then \
174			${INSTALLINFO}  --section=${INFOSECTION} \
175				${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}; \
176		else \
177			${INSTALLINFO}  --section=${INFOSECTION} \
178       				--entry=${INFOENTRY_${x}} \
179				${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}; \
180		fi \
181	fi
182.endfor
183
184.PHONY: ${INSTALLINFODIRS}
185
186DISTRIBUTION?=	bin
187
188.if !target(distribute)
189distribute: _SUBDIR
190.for dist in ${DISTRIBUTION}
191	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${dist} SHARED=copies
192.endfor
193.endif
194
195.if defined(SRCS)
196CLEANFILES+=	${INFO}.texi
197${INFO}.texi: ${SRCS}
198	cat ${.ALLSRC} > ${.TARGET}
199.endif
200
201# tex garbage
202.if ${FORMATS:Mps} || ${FORMATS:Mdvi} || ${FORMATS:Mlatin1}
203.for _f in aux cp fn ky log out pg toc tp vr dvi
204CLEANFILES+=	${INFO:S/$/.${_f}/} ${INFO:S/$/-la.${_f}/}
205.endfor
206CLEANFILES+=	${INFO:S/$/-la.texi/}
207.endif
208
209.if ${FORMATS:Mhtml}
210CLEANFILES+=	${INFO:S/$/.info.*.html/} ${INFO:S/$/.info/}
211.endif
212
213.if !defined(NOINFO) && defined(INFO)
214install: ${INSTALLINFODIRS} _SUBDIR
215.if ${IFILES:N*.html}
216	${INSTALL} ${COPY} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
217		${IFILES:N*.html} ${DESTDIR}${INFODIR}
218.endif
219.if ${FORMATS:Mhtml}
220	${INSTALL} ${COPY} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
221		${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR}
222.endif
223.else
224install:
225.endif
226
227.if !target(maninstall)
228maninstall: _SUBDIR
229.endif
230
231.if !target(regress)
232regress:
233.endif
234
235.include <bsd.obj.mk>
236