bsd.info.mk revision 100872
1# $FreeBSD: head/share/mk/bsd.info.mk 100872 2002-07-29 09:40:17Z ru $
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# DVIPS		A program which convert a TeX DVI file to PostScript [dvips]
15#
16# DVIPS2ASCII	A program to convert a PostScript file which was prior
17#		converted from a TeX DVI file to ascii/latin1 [dvips2ascii]
18#
19# FORMATS 	Indicates which output formats will be generated
20#               (info, dvi, latin1, ps, html).  [info]
21#
22# ICOMPRESS_CMD	Program to compress info files. Output is to
23#		stdout. [${COMPRESS_CMD}]
24#
25# INFO		texinfo files, without suffix.  [set in Makefile] 
26#
27# INFO2HTML	A program for converting GNU info files into HTML files
28#		[info2html]
29#
30# INFODIR	Base path for GNU's hypertext system
31#		called Info (see info(1)). [${SHAREDIR}/info]
32#
33# INFODIRFILE	Top level node/index for info files. [dir]
34#
35# INFOGRP	Info group. [${SHAREGRP}]
36#
37# INFOMODE	Info mode. [${NOBINMODE}]
38#
39# INFOOWN	Info owner. [${SHAREOWN}]
40#
41# INFOSECTION	Default section (if one could not be found in
42#		the Info file). [Miscellaneous]
43#
44# INSTALLINFO	A program for installing directory entries from Info
45#		file in the ${INFODIR}/${INFODIRFILE}. [install-info]
46#
47# INSTALLINFOFLAGS	Options for ${INSTALLINFO} command. [--quiet]
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#	install:
67#		Install the info files.
68#
69#
70# bsd.obj.mk: cleandir and obj
71
72.include <bsd.init.mk>
73
74MAKEINFO?=	makeinfo
75MAKEINFOFLAGS+=	--no-split # simplify some things, e.g., compression
76SRCDIR?=	${.CURDIR}
77INFODIRFILE?=   dir
78INSTALLINFO?=   install-info
79INSTALLINFOFLAGS+=--quiet
80INFOSECTION?=   Miscellaneous
81ICOMPRESS_CMD?=	${COMPRESS_CMD}
82ICOMPRESS_EXT?=	${COMPRESS_EXT}
83FORMATS?=	info
84INFO2HTML?=	info2html
85TEX?=		tex
86DVIPS?=		dvips
87DVIPS2ASCII?=	dvips2ascii
88
89.SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
90
91.texi.info .texinfo.info:
92	${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \
93		-o ${.TARGET}
94
95.texi.dvi .texinfo.dvi:
96	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
97		${TEX} ${.IMPSRC} </dev/null
98# Run again to reolve cross references.
99	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
100		${TEX} ${.IMPSRC} </dev/null
101
102.texinfo.latin1 .texi.latin1:
103	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
104	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
105		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
106# Run again to reolve cross references.
107	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
108		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
109	${DVIPS} -o /dev/stdout ${.IMPSRC:T:R}-la.dvi | \
110		${DVIPS2ASCII} > ${.TARGET}.new
111	mv -f ${.TARGET}.new ${.TARGET}
112
113.dvi.ps:
114	${DVIPS} -o ${.TARGET} ${.IMPSRC} 	
115
116.info.html:
117	${INFO2HTML} ${.IMPSRC}
118	ln -f ${.TARGET:R}.info.Top.html ${.TARGET} 
119
120.PATH: ${.CURDIR} ${SRCDIR}
121
122.for _f in ${FORMATS}
123IFILENS+=	${INFO:S/$/.${_f}/}
124.endfor
125
126.if !defined(NOINFO)
127CLEANFILES+=	${IFILENS}
128.if !defined(NOINFOCOMPRESS)
129CLEANFILES+=	${IFILENS:S/$/${ICOMPRESS_EXT}/}
130IFILES=	${IFILENS:S/$/${ICOMPRESS_EXT}/:S/.html${ICOMPRESS_EXT}/.html/}
131all: ${IFILES}
132.else
133IFILES=	${IFILENS}
134all: ${IFILES}
135.endif
136.else
137all:
138.endif
139
140.for x in ${IFILENS}
141${x:S/$/${ICOMPRESS_EXT}/}:	${x}
142	${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
143.endfor
144
145.for x in ${INFO}
146INSTALLINFODIRS+= ${x:S/$/-install/}
147${x:S/$/-install/}:
148	${INSTALLINFO} ${INSTALLINFOFLAGS} \
149	    --defsection=${INFOSECTION} \
150	    --defentry=${INFOENTRY_${x}} \
151	    ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
152.endfor
153
154.PHONY: ${INSTALLINFODIRS}
155
156.if defined(SRCS)
157CLEANFILES+=	${INFO}.texi
158${INFO}.texi: ${SRCS}
159	cat ${.ALLSRC} > ${.TARGET}
160.endif
161
162# tex garbage
163.if ${FORMATS:Mps} || ${FORMATS:Mdvi} || ${FORMATS:Mlatin1}
164.for _f in aux cp fn ky log out pg toc tp vr dvi
165CLEANFILES+=	${INFO:S/$/.${_f}/} ${INFO:S/$/-la.${_f}/}
166.endfor
167CLEANFILES+=	${INFO:S/$/-la.texi/}
168.endif
169
170.if ${FORMATS:Mhtml}
171CLEANFILES+=	${INFO:S/$/.info.*.html/} ${INFO:S/$/.info/}
172.endif
173
174.if !defined(NOINFO) && defined(INFO)
175install: ${INSTALLINFODIRS}
176.if ${IFILES:N*.html}
177	${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
178		${IFILES:N*.html} ${DESTDIR}${INFODIR}
179.endif
180.if ${FORMATS:Mhtml}
181	${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
182		${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR}
183.endif
184.else
185# The indirection in the following is to avoid the null install rule
186# "install:" from being overridden by the implicit .sh rule if there
187# happens to be a source file named install.sh.  This assumes that there
188# is no source file named __null_install.sh.
189install: __null_install
190__null_install:
191.endif
192
193.include <bsd.obj.mk>
194