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