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