Home | History | Annotate | Line # | Download | only in mk
bsd.man.mk revision 1.103
      1  1.103     joerg #	$NetBSD: bsd.man.mk,v 1.103 2010/03/01 22:00:07 joerg 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.64        tv ##### Default values
     13   1.66        tv .if ${USETOOLS} == "yes"
     14   1.69       jmc TMACDEPDIR?=	${TOOLDIR}/share/groff/tmac
     15   1.66        tv .else
     16   1.93       jmc TMACDEPDIR?=	/usr/share/tmac
     17   1.69       jmc .endif
     18   1.66        tv 
     19   1.98     lukem HTMLDIR?=	${DESTDIR}${MANDIR}
     20   1.80       wiz CATDEPS?=	${TMACDEPDIR}/andoc.tmac \
     21   1.80       wiz 		${TMACDEPDIR}/doc.tmac \
     22   1.80       wiz 		${TMACDEPDIR}/mdoc/doc-common \
     23   1.80       wiz 		${TMACDEPDIR}/mdoc/doc-ditroff \
     24   1.80       wiz 		${TMACDEPDIR}/mdoc/doc-nroff \
     25   1.80       wiz 		${TMACDEPDIR}/mdoc/doc-syms
     26   1.80       wiz HTMLDEPS?=	${TMACDEPDIR}/doc2html.tmac
     27   1.28   mycroft MANTARGET?=	cat
     28   1.66        tv 
     29   1.64        tv MAN?=
     30   1.64        tv MLINKS?=
     31   1.64        tv _MNUMBERS=	1 2 3 4 5 6 7 8 9
     32   1.64        tv .SUFFIXES:	${_MNUMBERS:@N@.$N@}
     33   1.64        tv 
     34   1.82     lukem .if ${MKMANZ} == "no"
     35   1.82     lukem MANCOMPRESS?=
     36   1.82     lukem MANSUFFIX?=
     37   1.82     lukem .else
     38   1.99     perry MANCOMPRESS?=	gzip -ncf
     39   1.82     lukem MANSUFFIX?=	.gz
     40   1.82     lukem .endif
     41   1.64        tv 
     42   1.64        tv # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
     43   1.64        tv .if !empty(MANCOMPRESS)
     44   1.64        tv MANCOMPRESS:=	| ${MANCOMPRESS}
     45   1.20       cgd .endif
     46    1.1       cgd 
     47   1.25  christos __installpage: .USE
     48   1.60    simonb 	@cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
     49   1.90     lukem 	    (${_MKSHMSG_INSTALL} ${.TARGET}; \
     50   1.87     lukem 	     ${_MKSHECHO} "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     51   1.95     jwise 		${.ALLSRC} ${.TARGET}" && \
     52   1.64        tv 	     ${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     53   1.95     jwise 		${.ALLSRC} ${.TARGET})
     54   1.25  christos 
     55   1.96       dbj # XXX consider including bsd.links.mk and using __linkinstall instead
     56   1.96       dbj __linkinstallpage: .USE
     57   1.96       dbj 	${_MKSHMSG_INSTALL} ${.TARGET}; \
     58  1.100       apb 	${_MKSHECHO} "${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     59  1.100       apb 	    ${.ALLSRC} ${.TARGET}" && \
     60  1.100       apb 	${INSTALL_LINK} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     61  1.100       apb 	    ${.ALLSRC} ${.TARGET}
     62   1.96       dbj 
     63   1.64        tv ##### Build and install rules (source form pages)
     64   1.25  christos 
     65   1.64        tv .if ${MKMAN} != "no"
     66   1.96       dbj maninstall:	manpages manlinks
     67   1.64        tv manpages::	# ensure target exists
     68   1.65     enami MANPAGES=	${MAN:C/.$/&${MANSUFFIX}/}
     69   1.64        tv 
     70   1.72        tv realall:	${MANPAGES}
     71   1.64        tv .if !empty(MANSUFFIX)
     72   1.64        tv .NOPATH:	${MANPAGES}
     73   1.64        tv .SUFFIXES:	${_MNUMBERS:@N@.$N${MANSUFFIX}@}
     74   1.64        tv 
     75   1.64        tv ${_MNUMBERS:@N@.$N.$N${MANSUFFIX}@}:			# build rule
     76   1.97     lukem 	${_MKTARGET_FORMAT}
     77   1.73       mrg 	cat ${.IMPSRC} ${MANCOMPRESS} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
     78   1.64        tv .endif # !empty(MANSUFFIX)
     79   1.64        tv 
     80   1.64        tv .for F in ${MANPAGES:S/${MANSUFFIX}$//:O:u}
     81   1.64        tv _F:=		${DESTDIR}${MANDIR}/man${F:T:E}${MANSUBDIR}/${F}${MANSUFFIX}
     82   1.64        tv 
     83   1.83     lukem .if ${MKUPDATE} == "no"
     84   1.78   mycroft ${_F}!		${F}${MANSUFFIX} __installpage		# install rule
     85   1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
     86   1.78   mycroft ${_F}!		.MADE					# no build at install
     87   1.78   mycroft .endif
     88   1.78   mycroft .else
     89   1.64        tv ${_F}:		${F}${MANSUFFIX} __installpage		# install rule
     90   1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
     91   1.64        tv ${_F}:		.MADE					# no build at install
     92   1.53   mycroft .endif
     93   1.78   mycroft .endif
     94   1.78   mycroft 
     95   1.78   mycroft manpages::	${_F}
     96   1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
     97   1.64        tv .endfor
     98   1.52   mycroft 
     99   1.96       dbj manlinks::						# link install
    100   1.96       dbj 
    101   1.96       dbj .for _src _dst in ${MLINKS}
    102   1.96       dbj _l:=${DESTDIR}${MANDIR}/man${_src:T:E}${MANSUBDIR}/${_src}${MANSUFFIX}
    103   1.96       dbj _t:=${DESTDIR}${MANDIR}/man${_dst:T:E}${MANSUBDIR}/${_dst}${MANSUFFIX}
    104   1.96       dbj 
    105   1.96       dbj # Handle case conflicts carefully, when _dst occurs
    106   1.96       dbj # more than once after case flattening
    107   1.96       dbj .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
    108   1.96       dbj ${_t}!		${_l} __linkinstallpage
    109   1.96       dbj .else
    110   1.96       dbj ${_t}:		${_l} __linkinstallpage
    111   1.19    brezak .endif
    112   1.96       dbj 
    113   1.96       dbj manlinks::	${_t}
    114   1.96       dbj .PRECIOUS:	${_t}
    115   1.96       dbj .endfor
    116   1.64        tv .endif # ${MKMAN} != "no"
    117   1.64        tv 
    118   1.64        tv ##### Build and install rules (plaintext pages)
    119   1.64        tv 
    120   1.64        tv .if (${MKCATPAGES} != "no") && (${MKMAN} != "no")
    121   1.96       dbj catinstall:	catpages catlinks
    122   1.64        tv catpages::	# ensure target exists
    123   1.64        tv CATPAGES=	${MAN:C/\.([1-9])$/.cat\1${MANSUFFIX}/}
    124   1.64        tv 
    125   1.64        tv realall:	${CATPAGES}
    126   1.64        tv .NOPATH:	${CATPAGES}
    127   1.64        tv .SUFFIXES:	${_MNUMBERS:@N@.cat$N${MANSUFFIX}@}
    128   1.75  christos .MADE:	${CATDEPS}
    129   1.64        tv 
    130   1.64        tv ${_MNUMBERS:@N@.$N.cat$N${MANSUFFIX}@}: ${CATDEPS}	# build rule
    131   1.88     lukem 	${_MKTARGET_FORMAT}
    132   1.64        tv .if defined(USETBL)
    133   1.81     lukem 	${TOOL_TBL} ${.IMPSRC} | ${TOOL_ROFF_ASCII} -mandoc ${MANCOMPRESS} \
    134   1.81     lukem 	    > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
    135  1.101     joerg .elif ${MKMANDOC} == yes && !defined(NOMANDOC)
    136  1.101     joerg 	if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \
    137  1.101     joerg 		${TOOL_MANDOC_ASCII} ${.IMPSRC} ${MANCOMPRESS} \
    138  1.101     joerg 		    > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \
    139  1.101     joerg 	else \
    140  1.101     joerg 		${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \
    141  1.101     joerg 		    > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}; \
    142  1.101     joerg 	fi
    143   1.64        tv .else
    144   1.81     lukem 	${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \
    145   1.81     lukem 	    > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
    146   1.64        tv .endif
    147   1.64        tv 
    148   1.64        tv .for F in ${CATPAGES:S/${MANSUFFIX}$//:O:u}
    149   1.64        tv _F:=		${DESTDIR}${MANDIR}/${F:T:E}${MANSUBDIR}/${F:R}.0${MANSUFFIX}
    150   1.78   mycroft 
    151   1.83     lukem .if ${MKUPDATE} == "no"
    152   1.78   mycroft ${_F}!		${F}${MANSUFFIX} __installpage		# install rule
    153   1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
    154   1.78   mycroft ${_F}!		.MADE					# no build at install
    155   1.78   mycroft .endif
    156   1.78   mycroft .else
    157   1.64        tv ${_F}:		${F}${MANSUFFIX} __installpage		# install rule
    158   1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
    159   1.64        tv ${_F}:		.MADE					# no build at install
    160   1.43     lukem .endif
    161   1.78   mycroft .endif
    162   1.78   mycroft 
    163   1.78   mycroft catpages::	${_F}
    164   1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
    165   1.64        tv .endfor
    166   1.25  christos 
    167   1.96       dbj catlinks::						# link install
    168   1.96       dbj 
    169   1.96       dbj .for _src _dst in ${MLINKS}
    170   1.96       dbj _l:=${DESTDIR}${MANDIR}/cat${_src:T:E}${MANSUBDIR}/${_src:R}.0${MANSUFFIX}
    171   1.96       dbj _t:=${DESTDIR}${MANDIR}/cat${_dst:T:E}${MANSUBDIR}/${_dst:R}.0${MANSUFFIX}
    172   1.96       dbj 
    173   1.96       dbj # Handle case conflicts carefully, when _dst occurs
    174   1.96       dbj # more than once after case flattening
    175   1.96       dbj .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
    176   1.96       dbj ${_t}!		${_l} __linkinstallpage
    177   1.96       dbj .else
    178   1.96       dbj ${_t}:		${_l} __linkinstallpage
    179    1.8   mycroft .endif
    180   1.96       dbj 
    181   1.96       dbj catlinks::	${_t}
    182   1.96       dbj .PRECIOUS:	${_t}
    183   1.96       dbj .endfor
    184   1.64        tv .endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no")
    185   1.56      phil 
    186   1.64        tv ##### Build and install rules (HTML pages)
    187   1.56      phil 
    188   1.97     lukem .if (${MKHTML} != "no") && (${MKMAN} != "no")		# {
    189   1.97     lukem htmlinstall:	htmlpages htmllinks
    190   1.64        tv htmlpages::	# ensure target exists
    191   1.64        tv HTMLPAGES=	${MAN:C/\.([1-9])$/.html\1/}
    192   1.64        tv 
    193   1.97     lukem realall:	${HTMLPAGES}
    194   1.64        tv .NOPATH:	${HTMLPAGES}
    195   1.64        tv .SUFFIXES:	${_MNUMBERS:@N@.html$N@}
    196   1.97     lukem .MADE:	${HTMLDEPS}
    197   1.64        tv 
    198   1.76      ross ${_MNUMBERS:@N@.$N.html$N@}: ${HTMLDEPS}			# build rule
    199   1.88     lukem 	${_MKTARGET_FORMAT}
    200  1.101     joerg .if ${MKMANDOC} == "yes" && !defined(NOMANDOC)
    201  1.101     joerg 	if test ""${NOMANDOC.${.IMPSRC:T}:tl:Q} != "yes"; then \
    202  1.101     joerg 		${TOOL_MANDOC_HTML} ${.IMPSRC} > ${.TARGET}.tmp && \
    203  1.101     joerg 		    mv ${.TARGET}.tmp ${.TARGET}; \
    204  1.101     joerg 	else \
    205  1.101     joerg 		${TOOL_ROFF_HTML} ${.IMPSRC} > ${.TARGET}.tmp && \
    206  1.101     joerg 		    mv ${.TARGET}.tmp ${.TARGET}; \
    207  1.101     joerg 	fi
    208  1.101     joerg .else
    209   1.81     lukem 	${TOOL_ROFF_HTML} ${.IMPSRC} > ${.TARGET}.tmp && \
    210   1.81     lukem 	    mv ${.TARGET}.tmp ${.TARGET}
    211  1.101     joerg .endif
    212   1.64        tv 
    213   1.64        tv .for F in ${HTMLPAGES:O:u}
    214   1.77      ross # construct installed path
    215   1.77      ross _F:=		${HTMLDIR}/${F:T:E}${MANSUBDIR}/${F:R:S-/index$-/x&-}.html
    216   1.78   mycroft 
    217   1.83     lukem .if ${MKUPDATE} == "no"
    218   1.78   mycroft ${_F}!		${F} __installpage			# install rule
    219   1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
    220   1.78   mycroft ${_F}!		.MADE					# no build at install
    221   1.78   mycroft .endif
    222   1.78   mycroft .else
    223   1.64        tv ${_F}:		${F} __installpage			# install rule
    224   1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
    225   1.64        tv ${_F}:		.MADE					# no build at install
    226   1.64        tv .endif
    227   1.78   mycroft .endif
    228   1.78   mycroft 
    229   1.78   mycroft htmlpages::	${_F}
    230   1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
    231   1.56      phil .endfor
    232   1.56      phil 
    233   1.97     lukem htmllinks::						# link install
    234   1.97     lukem 
    235   1.97     lukem .for _src _dst in ${MLINKS}
    236   1.97     lukem _l:=${HTMLDIR}/html${_src:T:E}${MANSUBDIR}/${_src:R:S-/index$-/x&-}.html
    237   1.97     lukem _t:=${HTMLDIR}/html${_dst:T:E}${MANSUBDIR}/${_dst:R:S-/index$-/x&-}.html
    238   1.97     lukem 
    239   1.97     lukem # Handle case conflicts carefully, when _dst occurs
    240   1.97     lukem # more than once after case flattening
    241   1.97     lukem .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
    242   1.97     lukem ${_t}!		${_l} __linkinstallpage
    243   1.97     lukem .else
    244   1.97     lukem ${_t}:		${_l} __linkinstallpage
    245   1.97     lukem .endif
    246   1.97     lukem 
    247   1.97     lukem htmllinks::	${_t}
    248   1.97     lukem .PRECIOUS:	${_t}
    249   1.97     lukem .endfor
    250   1.97     lukem 
    251   1.82     lukem .endif							# }
    252   1.31   mycroft 
    253   1.64        tv ##### Clean rules
    254   1.64        tv .undef _F
    255    1.8   mycroft 
    256   1.64        tv cleandir: cleanman
    257   1.94      tron .if !empty(CLEANFILES)
    258   1.94      tron 	rm -f ${CLEANFILES}
    259   1.94      tron .endif
    260   1.94      tron 
    261   1.91     lukem cleanman: .PHONY
    262   1.64        tv .if !empty(MAN) && (${MKMAN} != "no")
    263   1.64        tv .if (${MKCATPAGES} != "no")
    264   1.25  christos 	rm -f ${CATPAGES}
    265    1.1       cgd .endif
    266   1.64        tv .if !empty(MANSUFFIX)
    267   1.64        tv 	rm -f ${MANPAGES} ${CATPAGES:S/${MANSUFFIX}$//}
    268   1.64        tv .endif
    269   1.97     lukem .if ${MKHTML} != "no"
    270   1.97     lukem 	rm -f ${HTMLPAGES}
    271   1.97     lukem .endif
    272   1.64        tv .endif
    273   1.64        tv # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used)
    274   1.64        tv 
    275  1.103     joerg .if !empty(MANPAGES)
    276  1.101     joerg lintmanpages: ${MANPAGES}
    277  1.103     joerg 	${TOOL_MANDOC_LINT} -Tlint -fstrict -Wall ${.ALLSRC}
    278  1.101     joerg .endif
    279  1.101     joerg 
    280   1.64        tv ##### Pull in related .mk logic
    281   1.64        tv .include <bsd.obj.mk>
    282   1.84     lukem .include <bsd.files.mk>
    283   1.67   thorpej .include <bsd.sys.mk>
    284   1.34   mycroft 
    285   1.97     lukem ${TARGETS} catinstall maninstall htmlinstall: # ensure existence
    286