Home | History | Annotate | Line # | Download | only in mk
bsd.man.mk revision 1.119.6.1
      1  1.119.6.1  christos #	$NetBSD: bsd.man.mk,v 1.119.6.1 2019/06/10 22:05:42 christos Exp $
      2       1.26     mikel #	@(#)bsd.man.mk	8.1 (Berkeley) 6/8/93
      3        1.1       cgd 
      4       1.64        tv .include <bsd.init.mk>
      5       1.34   mycroft 
      6       1.64        tv ##### Basic targets
      7       1.96       dbj .PHONY:		catinstall maninstall catpages manpages catlinks manlinks
      8       1.97     lukem .PHONY:		htmlinstall htmlpages htmllinks
      9      1.101     joerg .PHONY:		lintmanpages
     10       1.32   mycroft realinstall:	${MANINSTALL}
     11       1.28   mycroft 
     12      1.116  christos # If our install destination is case-preserving, but case-insensitive
     13      1.116  christos # then we do filesystem comparisons in lower case to make sure that
     14      1.116  christos # we always refresh the target when needed. In general we don't
     15      1.116  christos # want to do this, otherwise things like _exit.2 -> _Exit.2 get
     16      1.116  christos # installed on each build even when they don't need to. Note that
     17      1.117  christos # the CASE_INSENSITIVE_DEST macro is currently not defined anywhere,
     18      1.117  christos # and the expansion does not really work because of make(1).
     19      1.116  christos .if defined(CASE_INSENSITIVE_DEST)
     20      1.117  christos _FLATTEN?=tl:
     21      1.116  christos .endif
     22      1.116  christos 
     23       1.64        tv ##### Default values
     24       1.66        tv .if ${USETOOLS} == "yes"
     25       1.69       jmc TMACDEPDIR?=	${TOOLDIR}/share/groff/tmac
     26       1.66        tv .else
     27       1.93       jmc TMACDEPDIR?=	/usr/share/tmac
     28       1.69       jmc .endif
     29       1.66        tv 
     30       1.98     lukem HTMLDIR?=	${DESTDIR}${MANDIR}
     31      1.110     joerg .if ${MKMANDOC} == yes && !defined(NOMANDOC)
     32      1.110     joerg CATDEPS?=
     33      1.110     joerg .else
     34       1.80       wiz CATDEPS?=	${TMACDEPDIR}/andoc.tmac \
     35       1.80       wiz 		${TMACDEPDIR}/doc.tmac \
     36       1.80       wiz 		${TMACDEPDIR}/mdoc/doc-common \
     37       1.80       wiz 		${TMACDEPDIR}/mdoc/doc-ditroff \
     38       1.80       wiz 		${TMACDEPDIR}/mdoc/doc-nroff \
     39       1.80       wiz 		${TMACDEPDIR}/mdoc/doc-syms
     40      1.110     joerg .endif
     41       1.28   mycroft MANTARGET?=	cat
     42       1.66        tv 
     43       1.64        tv MAN?=
     44       1.64        tv MLINKS?=
     45      1.114       apb _MSECTIONS=	1 2 3 4 5 6 7 8 9
     46      1.114       apb _MSECTIONS+=	3lua 9lua
     47      1.114       apb _MSECTIONREGEX=	${_MSECTIONS:ts|} # e.g. 1|2|3|...
     48      1.114       apb .SUFFIXES:	${_MSECTIONS:@N@.$N@}
     49       1.64        tv 
     50       1.82     lukem .if ${MKMANZ} == "no"
     51       1.82     lukem MANCOMPRESS?=
     52       1.82     lukem MANSUFFIX?=
     53       1.82     lukem .else
     54      1.115       apb MANCOMPRESS?=	${TOOL_GZIP_N} -cf
     55       1.82     lukem MANSUFFIX?=	.gz
     56       1.82     lukem .endif
     57       1.64        tv 
     58       1.64        tv # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
     59       1.64        tv .if !empty(MANCOMPRESS)
     60       1.64        tv MANCOMPRESS:=	| ${MANCOMPRESS}
     61       1.20       cgd .endif
     62        1.1       cgd 
     63       1.25  christos __installpage: .USE
     64       1.60    simonb 	@cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
     65       1.90     lukem 	    (${_MKSHMSG_INSTALL} ${.TARGET}; \
     66       1.87     lukem 	     ${_MKSHECHO} "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     67       1.95     jwise 		${.ALLSRC} ${.TARGET}" && \
     68       1.64        tv 	     ${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     69       1.95     jwise 		${.ALLSRC} ${.TARGET})
     70       1.25  christos 
     71       1.96       dbj # XXX consider including bsd.links.mk and using __linkinstall instead
     72       1.96       dbj __linkinstallpage: .USE
     73       1.96       dbj 	${_MKSHMSG_INSTALL} ${.TARGET}; \
     74      1.100       apb 	${_MKSHECHO} "${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     75      1.100       apb 	    ${.ALLSRC} ${.TARGET}" && \
     76      1.100       apb 	${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     77      1.100       apb 	    ${.ALLSRC} ${.TARGET}
     78       1.96       dbj 
     79       1.64        tv ##### Build and install rules (source form pages)
     80       1.25  christos 
     81       1.64        tv .if ${MKMAN} != "no"
     82       1.96       dbj maninstall:	manpages manlinks
     83       1.64        tv manpages::	# ensure target exists
     84       1.65     enami MANPAGES=	${MAN:C/.$/&${MANSUFFIX}/}
     85       1.64        tv 
     86       1.72        tv realall:	${MANPAGES}
     87       1.64        tv .if !empty(MANSUFFIX)
     88       1.64        tv .NOPATH:	${MANPAGES}
     89      1.114       apb .SUFFIXES:	${_MSECTIONS:@N@.$N${MANSUFFIX}@}
     90       1.64        tv 
     91      1.114       apb ${_MSECTIONS:@N@.$N.$N${MANSUFFIX}@}:			# build rule
     92       1.97     lukem 	${_MKTARGET_FORMAT}
     93  1.119.6.1  christos 	cat ${.IMPSRC} ${MANCOMPRESS} > ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}
     94       1.64        tv .endif # !empty(MANSUFFIX)
     95       1.64        tv 
     96       1.64        tv .for F in ${MANPAGES:S/${MANSUFFIX}$//:O:u}
     97       1.64        tv _F:=		${DESTDIR}${MANDIR}/man${F:T:E}${MANSUBDIR}/${F}${MANSUFFIX}
     98       1.64        tv 
     99       1.83     lukem .if ${MKUPDATE} == "no"
    100       1.78   mycroft ${_F}!		${F}${MANSUFFIX} __installpage		# install rule
    101       1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
    102       1.78   mycroft ${_F}!		.MADE					# no build at install
    103       1.78   mycroft .endif
    104       1.78   mycroft .else
    105       1.64        tv ${_F}:		${F}${MANSUFFIX} __installpage		# install rule
    106       1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
    107       1.64        tv ${_F}:		.MADE					# no build at install
    108       1.53   mycroft .endif
    109       1.78   mycroft .endif
    110       1.78   mycroft 
    111       1.78   mycroft manpages::	${_F}
    112       1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
    113       1.64        tv .endfor
    114       1.52   mycroft 
    115       1.96       dbj manlinks::						# link install
    116       1.96       dbj 
    117       1.96       dbj .for _src _dst in ${MLINKS}
    118       1.96       dbj _l:=${DESTDIR}${MANDIR}/man${_src:T:E}${MANSUBDIR}/${_src}${MANSUFFIX}
    119       1.96       dbj _t:=${DESTDIR}${MANDIR}/man${_dst:T:E}${MANSUBDIR}/${_dst}${MANSUFFIX}
    120       1.96       dbj 
    121       1.96       dbj # Handle case conflicts carefully, when _dst occurs
    122       1.96       dbj # more than once after case flattening
    123      1.117  christos .if ${MKUPDATE} == "no" || ${MLINKS:${_FLATTEN}M${_dst:${_FLATTEN}Q}:[\#]} > 1
    124       1.96       dbj ${_t}!		${_l} __linkinstallpage
    125       1.96       dbj .else
    126       1.96       dbj ${_t}:		${_l} __linkinstallpage
    127       1.19    brezak .endif
    128       1.96       dbj 
    129       1.96       dbj manlinks::	${_t}
    130       1.96       dbj .PRECIOUS:	${_t}
    131       1.96       dbj .endfor
    132       1.64        tv .endif # ${MKMAN} != "no"
    133       1.64        tv 
    134       1.64        tv ##### Build and install rules (plaintext pages)
    135       1.64        tv 
    136       1.64        tv .if (${MKCATPAGES} != "no") && (${MKMAN} != "no")
    137       1.96       dbj catinstall:	catpages catlinks
    138       1.64        tv catpages::	# ensure target exists
    139      1.114       apb CATPAGES=	${MAN:C/\.(${_MSECTIONREGEX})\$/.cat\1${MANSUFFIX}/}
    140       1.64        tv 
    141       1.64        tv realall:	${CATPAGES}
    142       1.64        tv .NOPATH:	${CATPAGES}
    143      1.114       apb .SUFFIXES:	${_MSECTIONS:@N@.cat$N${MANSUFFIX}@}
    144       1.75  christos .MADE:	${CATDEPS}
    145       1.64        tv 
    146      1.114       apb ${_MSECTIONS:@N@.$N.cat$N${MANSUFFIX}@}: ${CATDEPS}	# build rule
    147       1.88     lukem 	${_MKTARGET_FORMAT}
    148      1.106     joerg .if ${MKMANDOC} == yes && !defined(NOMANDOC)
    149      1.101     joerg 	if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \
    150      1.101     joerg 		${TOOL_MANDOC_ASCII} ${.IMPSRC} ${MANCOMPRESS} \
    151  1.119.6.1  christos 		    > ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}; \
    152      1.101     joerg 	else \
    153      1.101     joerg 		${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \
    154  1.119.6.1  christos 		    > ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}; \
    155      1.101     joerg 	fi
    156      1.106     joerg .elif defined(USETBL)
    157      1.106     joerg 	${TOOL_TBL} ${.IMPSRC} | ${TOOL_ROFF_ASCII} -mandoc ${MANCOMPRESS} \
    158  1.119.6.1  christos 	    > ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}
    159       1.64        tv .else
    160       1.81     lukem 	${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \
    161  1.119.6.1  christos 	    > ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}
    162       1.64        tv .endif
    163       1.64        tv 
    164       1.64        tv .for F in ${CATPAGES:S/${MANSUFFIX}$//:O:u}
    165       1.64        tv _F:=		${DESTDIR}${MANDIR}/${F:T:E}${MANSUBDIR}/${F:R}.0${MANSUFFIX}
    166       1.78   mycroft 
    167       1.83     lukem .if ${MKUPDATE} == "no"
    168       1.78   mycroft ${_F}!		${F}${MANSUFFIX} __installpage		# install rule
    169       1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
    170       1.78   mycroft ${_F}!		.MADE					# no build at install
    171       1.78   mycroft .endif
    172       1.78   mycroft .else
    173       1.64        tv ${_F}:		${F}${MANSUFFIX} __installpage		# install rule
    174       1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
    175       1.64        tv ${_F}:		.MADE					# no build at install
    176       1.43     lukem .endif
    177       1.78   mycroft .endif
    178       1.78   mycroft 
    179       1.78   mycroft catpages::	${_F}
    180       1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
    181       1.64        tv .endfor
    182       1.25  christos 
    183       1.96       dbj catlinks::						# link install
    184       1.96       dbj 
    185       1.96       dbj .for _src _dst in ${MLINKS}
    186       1.96       dbj _l:=${DESTDIR}${MANDIR}/cat${_src:T:E}${MANSUBDIR}/${_src:R}.0${MANSUFFIX}
    187       1.96       dbj _t:=${DESTDIR}${MANDIR}/cat${_dst:T:E}${MANSUBDIR}/${_dst:R}.0${MANSUFFIX}
    188       1.96       dbj 
    189       1.96       dbj # Handle case conflicts carefully, when _dst occurs
    190       1.96       dbj # more than once after case flattening
    191      1.117  christos .if ${MKUPDATE} == "no" || ${MLINKS:${_FLATTEN}M${_dst:${_FLATTEN}Q}:[\#]} > 1
    192       1.96       dbj ${_t}!		${_l} __linkinstallpage
    193       1.96       dbj .else
    194       1.96       dbj ${_t}:		${_l} __linkinstallpage
    195        1.8   mycroft .endif
    196       1.96       dbj 
    197       1.96       dbj catlinks::	${_t}
    198       1.96       dbj .PRECIOUS:	${_t}
    199       1.96       dbj .endfor
    200       1.64        tv .endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no")
    201       1.56      phil 
    202       1.64        tv ##### Build and install rules (HTML pages)
    203       1.56      phil 
    204       1.97     lukem .if (${MKHTML} != "no") && (${MKMAN} != "no")		# {
    205       1.97     lukem htmlinstall:	htmlpages htmllinks
    206       1.64        tv htmlpages::	# ensure target exists
    207      1.114       apb HTMLPAGES=	${MAN:C/\.(${_MSECTIONREGEX})\$/.html\1/}
    208       1.64        tv 
    209      1.107     njoly HTMLLINKS=	${MANSUBDIR:?../:}../html%S/%N.html
    210      1.107     njoly HTMLSTYLE=	${MANSUBDIR:?../:}../style.css
    211      1.107     njoly 
    212       1.97     lukem realall:	${HTMLPAGES}
    213       1.64        tv .NOPATH:	${HTMLPAGES}
    214      1.114       apb .SUFFIXES:	${_MSECTIONS:@N@.html$N@}
    215       1.64        tv 
    216      1.114       apb ${_MSECTIONS:@N@.$N.html$N@}: 				# build rule
    217       1.88     lukem 	${_MKTARGET_FORMAT}
    218      1.111  christos .if ${MKMANDOC} == yes && !defined(NOMANDOC)
    219      1.111  christos 	if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \
    220      1.119  jmcneill 	    ${TOOL_MANDOC_HTML} -Oman=${HTMLLINKS},style=${HTMLSTYLE} \
    221      1.111  christos 		${.IMPSRC} > ${.TARGET}.tmp && \
    222  1.119.6.1  christos 		${MV} ${.TARGET}.tmp ${.TARGET}; \
    223      1.111  christos 	else \
    224      1.112  christos 		${TOOL_ROFF_HTML} ${.IMPSRC} ${MANCOMPRESS} \
    225  1.119.6.1  christos 		    > ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}; \
    226      1.111  christos 	fi
    227      1.111  christos .elif defined(USETBL)
    228      1.112  christos 	${TOOL_TBL} ${.IMPSRC} | ${TOOL_ROFF_HTML} ${MANCOMPRESS} \
    229  1.119.6.1  christos 	    > ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}
    230      1.111  christos .else
    231      1.112  christos 	${TOOL_ROFF_HTML} ${.IMPSRC} ${MANCOMPRESS} \
    232  1.119.6.1  christos 	    > ${.TARGET}.tmp && ${MV} ${.TARGET}.tmp ${.TARGET}
    233      1.111  christos .endif
    234       1.64        tv 
    235       1.64        tv .for F in ${HTMLPAGES:O:u}
    236       1.77      ross # construct installed path
    237       1.77      ross _F:=		${HTMLDIR}/${F:T:E}${MANSUBDIR}/${F:R:S-/index$-/x&-}.html
    238       1.78   mycroft 
    239       1.83     lukem .if ${MKUPDATE} == "no"
    240       1.78   mycroft ${_F}!		${F} __installpage			# install rule
    241       1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
    242       1.78   mycroft ${_F}!		.MADE					# no build at install
    243       1.78   mycroft .endif
    244       1.78   mycroft .else
    245       1.64        tv ${_F}:		${F} __installpage			# install rule
    246       1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
    247       1.64        tv ${_F}:		.MADE					# no build at install
    248       1.64        tv .endif
    249       1.78   mycroft .endif
    250       1.78   mycroft 
    251       1.78   mycroft htmlpages::	${_F}
    252       1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
    253       1.56      phil .endfor
    254       1.56      phil 
    255       1.97     lukem htmllinks::						# link install
    256       1.97     lukem 
    257       1.97     lukem .for _src _dst in ${MLINKS}
    258       1.97     lukem _l:=${HTMLDIR}/html${_src:T:E}${MANSUBDIR}/${_src:R:S-/index$-/x&-}.html
    259       1.97     lukem _t:=${HTMLDIR}/html${_dst:T:E}${MANSUBDIR}/${_dst:R:S-/index$-/x&-}.html
    260       1.97     lukem 
    261       1.97     lukem # Handle case conflicts carefully, when _dst occurs
    262       1.97     lukem # more than once after case flattening
    263      1.117  christos .if ${MKUPDATE} == "no" || ${MLINKS:${_FLATTEN}M${_dst:${_FLATTEN}Q}:[\#]} > 1
    264       1.97     lukem ${_t}!		${_l} __linkinstallpage
    265       1.97     lukem .else
    266       1.97     lukem ${_t}:		${_l} __linkinstallpage
    267       1.97     lukem .endif
    268       1.97     lukem 
    269       1.97     lukem htmllinks::	${_t}
    270       1.97     lukem .PRECIOUS:	${_t}
    271       1.97     lukem .endfor
    272       1.97     lukem 
    273       1.82     lukem .endif							# }
    274       1.31   mycroft 
    275       1.64        tv ##### Clean rules
    276       1.64        tv .undef _F
    277        1.8   mycroft 
    278       1.64        tv .if !empty(MAN) && (${MKMAN} != "no")
    279       1.64        tv .if (${MKCATPAGES} != "no")
    280      1.109       apb CLEANDIRFILES+= ${CATPAGES}
    281        1.1       cgd .endif
    282       1.64        tv .if !empty(MANSUFFIX)
    283      1.109       apb CLEANDIRFILES+= ${MANPAGES} ${CATPAGES:S/${MANSUFFIX}$//}
    284       1.64        tv .endif
    285       1.97     lukem .if ${MKHTML} != "no"
    286      1.109       apb CLEANDIRFILES+= ${HTMLPAGES}
    287       1.97     lukem .endif
    288       1.64        tv .endif
    289       1.64        tv # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used)
    290       1.64        tv 
    291      1.103     joerg .if !empty(MANPAGES)
    292      1.101     joerg lintmanpages: ${MANPAGES}
    293      1.106     joerg 	${TOOL_MANDOC_LINT} -Tlint -fstrict -Wall,stop ${.ALLSRC}
    294      1.101     joerg .endif
    295      1.101     joerg 
    296      1.118  dholland ##### describe
    297      1.118  dholland describe:
    298      1.118  dholland .for _M in ${MANPAGES}
    299      1.118  dholland 	@echo $$(basename ${_M}) - \
    300      1.118  dholland 		$$(${TOOL_SED} < ${${_M}:P} -n -e '/^\.Nd /{;s/^....//;p;}')
    301      1.118  dholland .endfor
    302      1.118  dholland 
    303      1.118  dholland 
    304       1.64        tv ##### Pull in related .mk logic
    305       1.64        tv .include <bsd.obj.mk>
    306       1.84     lukem .include <bsd.files.mk>
    307       1.67   thorpej .include <bsd.sys.mk>
    308      1.109       apb .include <bsd.clean.mk>
    309       1.34   mycroft 
    310       1.97     lukem ${TARGETS} catinstall maninstall htmlinstall: # ensure existence
    311