150476Speter# $FreeBSD: releng/10.3/share/mk/bsd.info.mk 245752 2013-01-21 22:40:39Z brooks $
221612Swosch#
321612Swosch# The include file <bsd.info.mk> handles installing GNU (tech)info files.
421612Swosch# Texinfo is a documentation system that uses a single source
521612Swosch# file to produce both on-line information and printed output.
621612Swosch#
721612Swosch#
821612Swosch# +++ variables +++
921612Swosch#
1021612Swosch# CLEANFILES	Additional files to remove for the clean and cleandir targets.
1121612Swosch#
1221612Swosch# DESTDIR	Change the tree where the info files gets installed. [not set]
1321612Swosch#
1430350Swosch# DVIPS		A program which convert a TeX DVI file to PostScript [dvips]
1530350Swosch#
1630350Swosch# DVIPS2ASCII	A program to convert a PostScript file which was prior
1730350Swosch#		converted from a TeX DVI file to ascii/latin1 [dvips2ascii]
1830350Swosch#
1930046Swosch# FORMATS 	Indicates which output formats will be generated
2030350Swosch#               (info, dvi, latin1, ps, html).  [info]
2130046Swosch#
2223546Swosch# ICOMPRESS_CMD	Program to compress info files. Output is to
2323546Swosch#		stdout. [${COMPRESS_CMD}]
2421612Swosch#
25139761Skrion# INFO		texinfo files, without suffix.  [set in Makefile]
2621612Swosch#
2730350Swosch# INFO2HTML	A program for converting GNU info files into HTML files
2830350Swosch#		[info2html]
2930350Swosch#
3021612Swosch# INFODIR	Base path for GNU's hypertext system
3121612Swosch#		called Info (see info(1)). [${SHAREDIR}/info]
3221612Swosch#
3321612Swosch# INFODIRFILE	Top level node/index for info files. [dir]
3421612Swosch#
3521612Swosch# INFOGRP	Info group. [${SHAREGRP}]
3621612Swosch#
3721612Swosch# INFOMODE	Info mode. [${NOBINMODE}]
3821612Swosch#
3921612Swosch# INFOOWN	Info owner. [${SHAREOWN}]
4021612Swosch#
4156537Sru# INFOSECTION	Default section (if one could not be found in
4256537Sru#		the Info file). [Miscellaneous]
4321612Swosch#
4456537Sru# INSTALLINFO	A program for installing directory entries from Info
4556537Sru#		file in the ${INFODIR}/${INFODIRFILE}. [install-info]
4621612Swosch#
4756537Sru# INSTALLINFOFLAGS	Options for ${INSTALLINFO} command. [--quiet]
4821612Swosch#
4921612Swosch# INSTALLINFODIRS	???
5021612Swosch#
5121612Swosch# MAKEINFO	A program for converting GNU Texinfo files into Info
5221612Swosch#		file. [makeinfo]
5321612Swosch#
5421612Swosch# MAKEINFOFLAGS		Options for ${MAKEINFO} command. [--no-split]
5521612Swosch#
56139106Sru# NO_INFOCOMPRESS	If you do not want info files be
5721612Swosch#			compressed when they are installed. [not set]
5821612Swosch#
5930350Swosch# TEX		A program for converting tex files into dvi files [tex]
6021612Swosch#
6130350Swosch#
6221612Swosch# +++ targets +++
6321612Swosch#
6421612Swosch#	install:
6521612Swosch#		Install the info files.
6621612Swosch#
6721612Swosch#
6821612Swosch# bsd.obj.mk: cleandir and obj
695531Sjkh
7094940Sru.include <bsd.init.mk>
7124704Sbde
725345SbdeMAKEINFO?=	makeinfo
7313973SmppMAKEINFOFLAGS+=	--no-split # simplify some things, e.g., compression
7421588SpeterSRCDIR?=	${.CURDIR}
7521502SjmacdINFODIRFILE?=   dir
7621502SjmacdINSTALLINFO?=   install-info
7756537SruINSTALLINFOFLAGS+=--quiet
7821502SjmacdINFOSECTION?=   Miscellaneous
7923762SpeterICOMPRESS_CMD?=	${COMPRESS_CMD}
8023762SpeterICOMPRESS_EXT?=	${COMPRESS_EXT}
8130046SwoschFORMATS?=	info
8230350SwoschINFO2HTML?=	info2html
8330350SwoschTEX?=		tex
8430350SwoschDVIPS?=		dvips
8530350SwoschDVIPS2ASCII?=	dvips2ascii
865345Sbde
8730350Swosch.SUFFIXES: ${ICOMPRESS_EXT} .info .texi .texinfo .dvi .ps .latin1 .html
8823763Speter
8930105Swosch.texi.info .texinfo.info:
9024380Speter	${MAKEINFO} ${MAKEINFOFLAGS} -I ${.CURDIR} -I ${SRCDIR} ${.IMPSRC} \
9130308Swosch		-o ${.TARGET}
9223763Speter
9330105Swosch.texi.dvi .texinfo.dvi:
9492648Sbde	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
9530350Swosch		${TEX} ${.IMPSRC} </dev/null
96115205Sru# Run again to resolve cross references.
9792648Sbde	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
9830350Swosch		${TEX} ${.IMPSRC} </dev/null
9930046Swosch
10030105Swosch.texinfo.latin1 .texi.latin1:
10130105Swosch	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
10292648Sbde	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
10330350Swosch		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
104115205Sru# Run again to resolve cross references.
10592648Sbde	TEXINPUTS=${.CURDIR}:${SRCDIR}:$$TEXINPUTS \
10630350Swosch		${TEX} ${.IMPSRC:T:R}-la.texi </dev/null
10730350Swosch	${DVIPS} -o /dev/stdout ${.IMPSRC:T:R}-la.dvi | \
10830350Swosch		${DVIPS2ASCII} > ${.TARGET}.new
10930105Swosch	mv -f ${.TARGET}.new ${.TARGET}
11030105Swosch
11130046Swosch.dvi.ps:
112142711Sobrien	${DVIPS} -o ${.TARGET} ${.IMPSRC}
11330046Swosch
11430350Swosch.info.html:
11530350Swosch	${INFO2HTML} ${.IMPSRC}
116245752Sbrooks	${INSTALL_LINK} ${.TARGET:R}.info.Top.html ${.TARGET}
11730350Swosch
11821588Speter.PATH: ${.CURDIR} ${SRCDIR}
1195382Sache
12030046Swosch.for _f in ${FORMATS}
12131782SbdeIFILENS+=	${INFO:S/$/.${_f}/}
12230046Swosch.endfor
12321502Sjmacd
124156813Sru.if ${MK_INFO} != "no"
12531782SbdeCLEANFILES+=	${IFILENS}
126139106Sru.if !defined(NO_INFOCOMPRESS)
12731782SbdeCLEANFILES+=	${IFILENS:S/$/${ICOMPRESS_EXT}/}
12831782SbdeIFILES=	${IFILENS:S/$/${ICOMPRESS_EXT}/:S/.html${ICOMPRESS_EXT}/.html/}
12995306Sruall: ${IFILES}
1309725Swollman.else
13121502SjmacdIFILES=	${IFILENS}
13295306Sruall: ${IFILES}
1339725Swollman.endif
13421535Sjmacd.else
13521535Sjmacdall:
13621535Sjmacd.endif
1375382Sache
13831782Sbde.for x in ${IFILENS}
13923546Swosch${x:S/$/${ICOMPRESS_EXT}/}:	${x}
14023546Swosch	${ICOMPRESS_CMD} ${.ALLSRC} > ${.TARGET}
1419725Swollman.endfor
1429725Swollman
14321502Sjmacd.for x in ${INFO}
14421502SjmacdINSTALLINFODIRS+= ${x:S/$/-install/}
14599495Sru${x:S/$/-install/}:
146162793Sru.if !empty(.MAKEFLAGS:M-j)
147152006Sru	lockf -k ${DESTDIR}${INFODIR}/${INFODIRFILE} \
14856537Sru	${INSTALLINFO} ${INSTALLINFOFLAGS} \
14956537Sru	    --defsection=${INFOSECTION} \
15056537Sru	    --defentry=${INFOENTRY_${x}} \
15143430Sbde	    ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
152162793Sru.else
153162793Sru	${INSTALLINFO} ${INSTALLINFOFLAGS} \
154162793Sru	    --defsection=${INFOSECTION} \
155162793Sru	    --defentry=${INFOENTRY_${x}} \
156162793Sru	    ${x}.info ${DESTDIR}${INFODIR}/${INFODIRFILE}
157162793Sru.endif
15821502Sjmacd.endfor
15921502Sjmacd
16021502Sjmacd.PHONY: ${INSTALLINFODIRS}
16121502Sjmacd
1625380Sache.if defined(SRCS)
16330046SwoschCLEANFILES+=	${INFO}.texi
16430046Swosch${INFO}.texi: ${SRCS}
16530251Swosch	cat ${.ALLSRC} > ${.TARGET}
1665380Sache.endif
1675345Sbde
16830105Swosch# tex garbage
169125119Sru.if !empty(FORMATS:Mps) || !empty(FORMATS:Mdvi) || !empty(FORMATS:Mlatin1)
17030105Swosch.for _f in aux cp fn ky log out pg toc tp vr dvi
17131782SbdeCLEANFILES+=	${INFO:S/$/.${_f}/} ${INFO:S/$/-la.${_f}/}
17230105Swosch.endfor
17331782SbdeCLEANFILES+=	${INFO:S/$/-la.texi/}
17430350Swosch.endif
17530105Swosch
176125119Sru.if !empty(FORMATS:Mhtml)
17731782SbdeCLEANFILES+=	${INFO:S/$/.info.*.html/} ${INFO:S/$/.info/}
17830350Swosch.endif
17930105Swosch
180156813Sru.if ${MK_INFO} != "no" && defined(INFO)
18195306Sruinstall: ${INSTALLINFODIRS}
182125119Sru.if !empty(IFILES:N*.html)
183100872Sru	${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
18430350Swosch		${IFILES:N*.html} ${DESTDIR}${INFODIR}
18530350Swosch.endif
186125119Sru.if !empty(FORMATS:Mhtml)
187100872Sru	${INSTALL} -o ${INFOOWN} -g ${INFOGRP} -m ${INFOMODE} \
18831782Sbde		${INFO:S/$/.info.*.html/} ${DESTDIR}${INFODIR}
18930350Swosch.endif
19021535Sjmacd.else
19160597Sbde# The indirection in the following is to avoid the null install rule
19260597Sbde# "install:" from being overridden by the implicit .sh rule if there
19360597Sbde# happens to be a source file named install.sh.  This assumes that there
19460597Sbde# is no source file named __null_install.sh.
19560597Sbdeinstall: __null_install
19660597Sbde__null_install:
19721535Sjmacd.endif
1985380Sache
19916663Sjkh.include <bsd.obj.mk>
200