1*0a6a1f1dSLionel Sambuc# $NetBSD: bsd.doc.mk,v 1.68 2015/08/04 08:36:14 dholland Exp $ 251ffecc1SBen Gras# @(#)bsd.doc.mk 8.1 (Berkeley) 8/14/93 351ffecc1SBen Gras 451ffecc1SBen Gras.include <bsd.init.mk> 551ffecc1SBen Gras 6*0a6a1f1dSLionel Sambuc# The makefile should set these: 7*0a6a1f1dSLionel Sambuc# SECTION one of usd, smm, or psd (lower-case) 8*0a6a1f1dSLionel Sambuc# ARTICLE name of this document 9*0a6a1f1dSLionel Sambuc# SRCS roff source files 10*0a6a1f1dSLionel Sambuc# DEPSRCS additional roff source files implicitly included 11*0a6a1f1dSLionel Sambuc# MACROS name(s) of roff macro packages, including the -m 12*0a6a1f1dSLionel Sambuc# ROFF_PIC set to "yes" to use pic(1) 13*0a6a1f1dSLionel Sambuc# ROFF_EQN set to "yes" to use eqn(1) 14*0a6a1f1dSLionel Sambuc# ROFF_TBL set to "yes" to use tbl(1) 15*0a6a1f1dSLionel Sambuc# ROFF_REFER set to "yes" to use refer(1) 16*0a6a1f1dSLionel Sambuc# EXTRAHTMLFILES additional files emitted as part of HTML build 17*0a6a1f1dSLionel Sambuc# 18*0a6a1f1dSLionel Sambuc# PAGES unknown (XXX) 19*0a6a1f1dSLionel Sambuc# EXTRA extra files to install (XXX) 20*0a6a1f1dSLionel Sambuc# 21*0a6a1f1dSLionel Sambuc# If there are multiple docs to be generated, set these: 22*0a6a1f1dSLionel Sambuc# SUBARTICLES= name1 name2 ... 23*0a6a1f1dSLionel Sambuc# SRCS.name1= roff source files 24*0a6a1f1dSLionel Sambuc# SRCS.name2= more roff source files 25*0a6a1f1dSLionel Sambuc# SRCS. : = : 26*0a6a1f1dSLionel Sambuc# DEPSRCS.name1= additional included roff source files 27*0a6a1f1dSLionel Sambuc# DEPSRCS.name2= more additional included roff source files 28*0a6a1f1dSLionel Sambuc# DEPSRCS. : = : 29*0a6a1f1dSLionel Sambuc# 30*0a6a1f1dSLionel Sambuc# I'm hoping that MACROS and ROFF_* can be uniform across all 31*0a6a1f1dSLionel Sambuc# subarticles. 3251ffecc1SBen Gras 33*0a6a1f1dSLionel Sambuc 34*0a6a1f1dSLionel Sambuc# Old bsd.doc.mk files tend to invoke tbl and other preprocessors 35*0a6a1f1dSLionel Sambuc# directly; they should be changed to set ROFF_* instead. 36*0a6a1f1dSLionel Sambuc# 37*0a6a1f1dSLionel Sambuc# Also they set e.g. DIR=usd/72.mydocument; this should be changed 38*0a6a1f1dSLionel Sambuc# to SECTION=usd and ARTICLE=mydocument. The article numbers are 39*0a6a1f1dSLionel Sambuc# no longer present in the file system and do not need to be known 40*0a6a1f1dSLionel Sambuc# at build time. 41*0a6a1f1dSLionel Sambuc# 42*0a6a1f1dSLionel Sambuc 43*0a6a1f1dSLionel Sambuc# 20130908 dholland: Make sure all makefiles have been converted to the 44*0a6a1f1dSLionel Sambuc# new scheme. 45*0a6a1f1dSLionel Sambuc.if !defined(SECTION) 46*0a6a1f1dSLionel Sambuc.error "bsd.doc.mk: SECTION must be defined" 47*0a6a1f1dSLionel Sambuc.endif 48*0a6a1f1dSLionel Sambuc.if target(paper.ps) 49*0a6a1f1dSLionel Sambuc.error "bsd.doc.mk: target(paper.ps) is true -- this is not allowed" 5051ffecc1SBen Gras.endif 5151ffecc1SBen Gras 52*0a6a1f1dSLionel Sambuc# 20130908 dholland: right now we cannot generate pdf from roff sources, 53*0a6a1f1dSLionel Sambuc# so build compressed postscript instead. XXX. (and: yech) 54*0a6a1f1dSLionel SambucTOOL_ROFF_PDF?=false "No roff pdf support" 55*0a6a1f1dSLionel SambucPRINTABLE=ps.gz 56*0a6a1f1dSLionel Sambuc#PRINTABLE=ps 57*0a6a1f1dSLionel Sambuc#PRINTABLE=pdf 5851ffecc1SBen Gras 59*0a6a1f1dSLionel Sambuc# If there aren't subarticles, we generate one doc that has the same 60*0a6a1f1dSLionel Sambuc# name as the top-level article. 61*0a6a1f1dSLionel SambucSUBARTICLES?=${ARTICLE} 62*0a6a1f1dSLionel SambucSRCS.${ARTICLE}?=${SRCS} 63*0a6a1f1dSLionel SambucDEPSRCS.${ARTICLE}?=${DEPSRCS} 6451ffecc1SBen Gras 65*0a6a1f1dSLionel Sambuc##### Build 66*0a6a1f1dSLionel Sambuc 67*0a6a1f1dSLionel Sambuc.for SA in ${SUBARTICLES} 6851ffecc1SBen Gras.if ${MKDOC} != "no" 69*0a6a1f1dSLionel Sambucrealall: ${SA}.txt 70*0a6a1f1dSLionel Sambucrealall: ${SA}.${PRINTABLE} 71*0a6a1f1dSLionel Sambuc.if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no" 72*0a6a1f1dSLionel Sambucrealall: ${SA}.html 7351ffecc1SBen Gras.endif 7451ffecc1SBen Gras.endif 75*0a6a1f1dSLionel Sambuc.endfor # SUBARTICLES 7651ffecc1SBen Gras 77*0a6a1f1dSLionel Sambuc.if defined(ROFF_PIC) && ${ROFF_PIC} != "no" 78*0a6a1f1dSLionel SambucROFFFLAGS+=-p 79*0a6a1f1dSLionel Sambuc.endif 80*0a6a1f1dSLionel Sambuc.if defined(ROFF_EQN) && ${ROFF_EQN} != "no" 81*0a6a1f1dSLionel SambucROFFFLAGS+=-e 82*0a6a1f1dSLionel Sambuc.endif 83*0a6a1f1dSLionel Sambuc.if defined(ROFF_TBL) && ${ROFF_TBL} != "no" 84*0a6a1f1dSLionel SambucROFFFLAGS+=-t 85*0a6a1f1dSLionel Sambuc.endif 86*0a6a1f1dSLionel Sambuc.if defined(ROFF_REFER) && ${ROFF_REFER} != "no" 87*0a6a1f1dSLionel SambucROFFFLAGS+=-R 88*0a6a1f1dSLionel Sambuc.endif 89*0a6a1f1dSLionel SambucROFFFLAGS+=-I${.CURDIR} 90*0a6a1f1dSLionel Sambuc 91*0a6a1f1dSLionel Sambuc.for SA in ${SUBARTICLES} 92*0a6a1f1dSLionel Sambuc 93*0a6a1f1dSLionel Sambuc# 94*0a6a1f1dSLionel Sambuc# Find the sources. 95*0a6a1f1dSLionel Sambuc# 96*0a6a1f1dSLionel Sambuc# We can't use .IMPSRC in the rules because they aren't suffix rules 97*0a6a1f1dSLionel Sambuc# (they could be for some docs, but not others) and we can't use 98*0a6a1f1dSLionel Sambuc# .ALLSRC because that includes DEPSRCS. 99*0a6a1f1dSLionel Sambuc# 100*0a6a1f1dSLionel Sambuc# As far as I know, the only ways to get the path discovered via .PATH 101*0a6a1f1dSLionel Sambuc# are those two magic variables or the P modifier. 102*0a6a1f1dSLionel Sambuc# 103*0a6a1f1dSLionel Sambuc# For some reason the P modifier finds the path to a variable name, 104*0a6a1f1dSLionel Sambuc# not the path to a word in a variable. 105*0a6a1f1dSLionel Sambuc# 106*0a6a1f1dSLionel Sambuc 107*0a6a1f1dSLionel Sambuc.for S in ${SRCS.${SA}} 108*0a6a1f1dSLionel SambucSRCS2.${SA}+=${${S}:P} 109*0a6a1f1dSLionel Sambuc.endfor 110*0a6a1f1dSLionel Sambuc.for S in ${DEPSRCS.${SA}} 111*0a6a1f1dSLionel SambucDEPSRCS2.${SA}+=${${S}:P} 11251ffecc1SBen Gras.endfor 11351ffecc1SBen Gras 114*0a6a1f1dSLionel Sambuc# 115*0a6a1f1dSLionel Sambuc# Note: we use TOOL_ROFF_DOCASCII because TOOL_ROFF_ASCII invokes 116*0a6a1f1dSLionel Sambuc# the nroff wrapper instead of groff directly, and that doesn't 117*0a6a1f1dSLionel Sambuc# understand -I. 118*0a6a1f1dSLionel Sambuc# 119*0a6a1f1dSLionel Sambuc# We use TOOL_ROFF_DOCHTML because TOOL_ROFF_HTML uses -mdoc2html, 120*0a6a1f1dSLionel Sambuc# which is great if it works but doesn't work with at least some of 121*0a6a1f1dSLionel Sambuc# the non-mdoc docs. (e.g. the curses one) TOOL_ROFF_DOCHTML uses 122*0a6a1f1dSLionel Sambuc# groff -Thtml, which produces fairly blah output but works with these 123*0a6a1f1dSLionel Sambuc# docs. It might end up being necessary to choose one or the other on 124*0a6a1f1dSLionel Sambuc# a per-document basis... sigh. 125*0a6a1f1dSLionel Sambuc# 12651ffecc1SBen Gras 127*0a6a1f1dSLionel Sambuc${SA}.txt: ${SRCS2.${SA}} ${DEPSRCS2.${SA}} 128*0a6a1f1dSLionel Sambuc ${_MKTARGET_FORMAT} 129*0a6a1f1dSLionel Sambuc ${TOOL_ROFF_DOCASCII} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \ 130*0a6a1f1dSLionel Sambuc > ${.TARGET} 13151ffecc1SBen Gras 132*0a6a1f1dSLionel Sambuc${SA}.ps: ${SRCS2.${SA}} ${DEPSRCS2.${SA}} 133*0a6a1f1dSLionel Sambuc ${_MKTARGET_FORMAT} 134*0a6a1f1dSLionel Sambuc ${TOOL_ROFF_PS} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \ 135*0a6a1f1dSLionel Sambuc | ${TOOL_SED} -e '/^%%CreationDate:/d' \ 136*0a6a1f1dSLionel Sambuc > ${.TARGET} 137*0a6a1f1dSLionel Sambuc 138*0a6a1f1dSLionel Sambuc${SA}.pdf: ${SRCS2.${SA}} ${DEPSRCS2.${SA}} 139*0a6a1f1dSLionel Sambuc ${_MKTARGET_FORMAT} 140*0a6a1f1dSLionel Sambuc ${TOOL_ROFF_PDF} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \ 141*0a6a1f1dSLionel Sambuc > ${.TARGET} 142*0a6a1f1dSLionel Sambuc 143*0a6a1f1dSLionel Sambuc${SA}.html: ${SRCS2.${SA}} ${DEPSRCS2.${SA}} 144*0a6a1f1dSLionel Sambuc ${_MKTARGET_FORMAT} 145*0a6a1f1dSLionel Sambuc ${TOOL_ROFF_DOCHTML} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \ 146*0a6a1f1dSLionel Sambuc -P -I -P ${SA} \ 147*0a6a1f1dSLionel Sambuc > ${.TARGET} 148*0a6a1f1dSLionel Sambuc 149*0a6a1f1dSLionel Sambuc${SA}.ps.gz: ${SA}.ps 150*0a6a1f1dSLionel Sambuc ${TOOL_GZIP} -9 -c -n ${.ALLSRC} > ${.TARGET} 151*0a6a1f1dSLionel Sambuc 152*0a6a1f1dSLionel Sambuc.endfor # SUBARTICLES 153*0a6a1f1dSLionel Sambuc 154*0a6a1f1dSLionel Sambuc##### Install 155*0a6a1f1dSLionel Sambuc 156*0a6a1f1dSLionel SambucDOCINST:= 157*0a6a1f1dSLionel Sambuc.for SA in ${SUBARTICLES} 158*0a6a1f1dSLionel SambucDOCINST+=${SA}.txt ${SA}.${PRINTABLE} 159*0a6a1f1dSLionel Sambuc.if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no" 160*0a6a1f1dSLionel SambucDOCINST+=${SA}.html 161*0a6a1f1dSLionel Sambuc.endif 162*0a6a1f1dSLionel Sambuc.endfor 163*0a6a1f1dSLionel Sambuc.if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no" 164*0a6a1f1dSLionel SambucDOCINST+=${EXTRAHTMLFILES} 16551ffecc1SBen Gras.endif 16651ffecc1SBen Gras 167*0a6a1f1dSLionel Sambuc.if ${MKDOC} != "no" 168*0a6a1f1dSLionel Sambucdocinstall: 169*0a6a1f1dSLionel Sambuc.for D in ${DOCINST} 170*0a6a1f1dSLionel Sambuc ${_MKTARGET_INSTALL} 171*0a6a1f1dSLionel Sambuc ${INSTALL_FILE} -o ${DOCOWN} -g ${DOCGRP} -m ${DOCMODE} ${D} \ 172*0a6a1f1dSLionel Sambuc ${DESTDIR}${DOCDIR}/${SECTION}/${ARTICLE}/${D} 173*0a6a1f1dSLionel Sambuc.endfor 174*0a6a1f1dSLionel Sambuc.else 175*0a6a1f1dSLionel Sambucdocinstall: ; 176*0a6a1f1dSLionel Sambuc.endif 177*0a6a1f1dSLionel Sambuc 178*0a6a1f1dSLionel Sambuc.PHONY: docinstall 179*0a6a1f1dSLionel Sambucrealinstall: docinstall 180*0a6a1f1dSLionel Sambuc 181*0a6a1f1dSLionel Sambuc##### Clean 182*0a6a1f1dSLionel Sambuc 183*0a6a1f1dSLionel Sambuccleandoc: 184*0a6a1f1dSLionel Sambuc.for SA in ${SUBARTICLES} 185*0a6a1f1dSLionel Sambuc rm -f ${SA}.txt ${SA}.ps ${SA}.ps.gz ${SA}.html 186*0a6a1f1dSLionel Sambuc.endfor 187*0a6a1f1dSLionel Sambuc rm -f ${EXTRAHTMLFILES} [eE]rrs mklog ${CLEANFILES} 188*0a6a1f1dSLionel Sambuc 189*0a6a1f1dSLionel Sambuc.PHONY: cleandoc 190*0a6a1f1dSLionel Sambucclean: cleandoc 191*0a6a1f1dSLionel Sambuc 192*0a6a1f1dSLionel Sambuc##### Extra custom rules 193*0a6a1f1dSLionel Sambuc 194*0a6a1f1dSLionel Sambuc.if !target(print) 195*0a6a1f1dSLionel Sambucprint: ; 196*0a6a1f1dSLionel Sambuc.PHONY: print 197*0a6a1f1dSLionel Sambuc.for SA in ${SUBARTICLES} 198*0a6a1f1dSLionel Sambucprint: print.${SA} 199*0a6a1f1dSLionel Sambuc.PHONY: print.{SA} 200*0a6a1f1dSLionel Sambucprint.${SA}: ${SA}.ps 201*0a6a1f1dSLionel Sambuc lpr -P${PRINTER} ${.ALLSRC} 202*0a6a1f1dSLionel Sambuc.endfor 203*0a6a1f1dSLionel Sambuc.endif 204*0a6a1f1dSLionel Sambuc 205*0a6a1f1dSLionel Sambucspell: ; 206*0a6a1f1dSLionel Sambuc.PHONY: spell 207*0a6a1f1dSLionel Sambuc.for SA in ${SUBARTICLES} 208*0a6a1f1dSLionel Sambucspell: spell.${SA} 209*0a6a1f1dSLionel Sambuc.PHONY: spell.{SA} 210*0a6a1f1dSLionel Sambucspell.${SA}: ${SRCS2} ${DEPSRCS2} 211*0a6a1f1dSLionel Sambuc spell ${SRCS2} | sort | comm -23 - spell.ok > paper.spell 212*0a6a1f1dSLionel Sambuc.endfor 21351ffecc1SBen Gras 21451ffecc1SBen Gras##### Pull in related .mk logic 215*0a6a1f1dSLionel Sambuc 21651ffecc1SBen Gras.include <bsd.obj.mk> 21751ffecc1SBen Gras.include <bsd.sys.mk> 21851ffecc1SBen Gras 21951ffecc1SBen Gras${TARGETS}: # ensure existence 220