Home | History | Annotate | Line # | Download | only in mk
bsd.man.mk revision 1.78
      1  1.78   mycroft #	$NetBSD: bsd.man.mk,v 1.78 2002/02/11 21:15:00 mycroft 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.64        tv .PHONY:		catinstall maninstall catpages manpages catlinks manlinks \
      8  1.64        tv 		cleanman html installhtml cleanhtml
      9  1.32   mycroft realinstall:	${MANINSTALL}
     10  1.28   mycroft 
     11  1.64        tv ##### Default values
     12  1.66        tv .if ${USETOOLS} == "yes"
     13  1.69       jmc TMACDEPDIR?=	${TOOLDIR}/share/groff/tmac
     14  1.66        tv .else
     15  1.69       jmc TMACDEPDIR?=	${DESTDIR}/usr/share/tmac
     16  1.69       jmc .endif
     17  1.66        tv 
     18  1.56      phil HTMLDIR?=	${DESTDIR}/usr/share/man
     19  1.69       jmc CATDEPS?=	${TMACDEPDIR}/tmac.andoc \
     20  1.69       jmc 		${TMACDEPDIR}/tmac.doc \
     21  1.69       jmc 		${TMACDEPDIR}/tmac.doc-ditroff \
     22  1.69       jmc 		${TMACDEPDIR}/tmac.doc-common \
     23  1.69       jmc 		${TMACDEPDIR}/tmac.doc-nroff \
     24  1.69       jmc 		${TMACDEPDIR}/tmac.doc-syms
     25  1.76      ross HTMLDEPS?=	${TMACDEPDIR}/tmac.doc2html
     26  1.28   mycroft MANTARGET?=	cat
     27  1.66        tv 
     28  1.66        tv GROFF_HTML?=	${GROFF} -Tlatin1 -mdoc2html -P-b -P-o -P-u
     29  1.66        tv NROFF?=		${GROFF} -Tascii -mtty-char
     30  1.33      phil TBL?=		tbl
     31  1.12       jtc 
     32  1.64        tv MAN?=
     33  1.64        tv MLINKS?=
     34  1.64        tv _MNUMBERS=	1 2 3 4 5 6 7 8 9
     35  1.64        tv .SUFFIXES:	${_MNUMBERS:@N@.$N@}
     36  1.64        tv 
     37  1.64        tv MANCOMPRESS?=	${MANZ:Dgzip -cf}
     38  1.64        tv MANSUFFIX?=	${MANZ:D.gz}
     39  1.64        tv 
     40  1.64        tv # make MANCOMPRESS a filter, so it can be inserted on an as-needed basis
     41  1.64        tv .if !empty(MANCOMPRESS)
     42  1.64        tv MANCOMPRESS:=	| ${MANCOMPRESS}
     43  1.20       cgd .endif
     44   1.1       cgd 
     45  1.25  christos __installpage: .USE
     46  1.60    simonb 	@cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
     47  1.64        tv 	    (echo "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     48  1.64        tv 		${.ALLSRC} ${.TARGET}" && \
     49  1.64        tv 	     ${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
     50  1.64        tv 		${.ALLSRC} ${.TARGET})
     51  1.25  christos 
     52  1.64        tv ##### Build and install rules (source form pages)
     53  1.25  christos 
     54  1.64        tv .if ${MKMAN} != "no"
     55  1.64        tv maninstall:	manlinks
     56  1.64        tv manpages::	# ensure target exists
     57  1.65     enami MANPAGES=	${MAN:C/.$/&${MANSUFFIX}/}
     58  1.64        tv 
     59  1.72        tv realall:	${MANPAGES}
     60  1.64        tv .if !empty(MANSUFFIX)
     61  1.64        tv .NOPATH:	${MANPAGES}
     62  1.64        tv .SUFFIXES:	${_MNUMBERS:@N@.$N${MANSUFFIX}@}
     63  1.64        tv 
     64  1.64        tv ${_MNUMBERS:@N@.$N.$N${MANSUFFIX}@}:			# build rule
     65  1.73       mrg 	cat ${.IMPSRC} ${MANCOMPRESS} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
     66  1.64        tv .endif # !empty(MANSUFFIX)
     67  1.64        tv 
     68  1.64        tv .for F in ${MANPAGES:S/${MANSUFFIX}$//:O:u}
     69  1.64        tv _F:=		${DESTDIR}${MANDIR}/man${F:T:E}${MANSUBDIR}/${F}${MANSUFFIX}
     70  1.64        tv 
     71  1.78   mycroft .if !defined(UPDATE)
     72  1.78   mycroft ${_F}!		${F}${MANSUFFIX} __installpage		# install rule
     73  1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
     74  1.78   mycroft ${_F}!		.MADE					# no build at install
     75  1.78   mycroft .endif
     76  1.78   mycroft .else
     77  1.64        tv ${_F}:		${F}${MANSUFFIX} __installpage		# install rule
     78  1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
     79  1.64        tv ${_F}:		.MADE					# no build at install
     80  1.53   mycroft .endif
     81  1.78   mycroft .endif
     82  1.78   mycroft 
     83  1.78   mycroft manpages::	${_F}
     84  1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
     85  1.64        tv .endfor
     86  1.52   mycroft 
     87  1.64        tv manlinks: manpages					# symlink install
     88  1.64        tv .if !empty(MLINKS)
     89  1.25  christos 	@set ${MLINKS}; \
     90  1.25  christos 	while test $$# -ge 2; do \
     91  1.64        tv 		name=$$1; shift; \
     92  1.64        tv 		dir=${DESTDIR}${MANDIR}/man$${name##*.}; \
     93  1.64        tv 		l=$${dir}${MANSUBDIR}/$${name}${MANSUFFIX}; \
     94  1.64        tv 		name=$$1; shift; \
     95  1.64        tv 		dir=${DESTDIR}${MANDIR}/man$${name##*.}; \
     96  1.64        tv 		t=$${dir}${MANSUBDIR}/$${name}${MANSUFFIX}; \
     97  1.55    itojun 		if test $$l -nt $$t -o ! -f $$t; then \
     98  1.55    itojun 			echo $$t -\> $$l; \
     99  1.68     perry 			${INSTALL_LINK} $$l $$t; \
    100  1.55    itojun 		fi; \
    101  1.19    brezak 	done
    102  1.19    brezak .endif
    103  1.64        tv .endif # ${MKMAN} != "no"
    104  1.64        tv 
    105  1.64        tv ##### Build and install rules (plaintext pages)
    106  1.64        tv 
    107  1.64        tv .if (${MKCATPAGES} != "no") && (${MKMAN} != "no")
    108  1.64        tv catinstall:	catlinks
    109  1.64        tv catpages::	# ensure target exists
    110  1.64        tv CATPAGES=	${MAN:C/\.([1-9])$/.cat\1${MANSUFFIX}/}
    111  1.64        tv 
    112  1.64        tv realall:	${CATPAGES}
    113  1.64        tv .NOPATH:	${CATPAGES}
    114  1.64        tv .SUFFIXES:	${_MNUMBERS:@N@.cat$N${MANSUFFIX}@}
    115  1.75  christos .MADE:	${CATDEPS}
    116  1.76      ross .MADE:	${HTMLDEPS}
    117  1.64        tv 
    118  1.64        tv ${_MNUMBERS:@N@.$N.cat$N${MANSUFFIX}@}: ${CATDEPS}	# build rule
    119  1.64        tv .if defined(USETBL)
    120  1.73       mrg 	${TBL} ${.IMPSRC} | ${NROFF} -mandoc ${MANCOMPRESS} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
    121  1.64        tv .else
    122  1.73       mrg 	${NROFF} -mandoc ${.IMPSRC} ${MANCOMPRESS} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
    123  1.64        tv .endif
    124  1.64        tv 
    125  1.64        tv .for F in ${CATPAGES:S/${MANSUFFIX}$//:O:u}
    126  1.64        tv _F:=		${DESTDIR}${MANDIR}/${F:T:E}${MANSUBDIR}/${F:R}.0${MANSUFFIX}
    127  1.78   mycroft 
    128  1.78   mycroft .if !defined(UPDATE)
    129  1.78   mycroft ${_F}!		${F}${MANSUFFIX} __installpage		# install rule
    130  1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
    131  1.78   mycroft ${_F}!		.MADE					# no build at install
    132  1.78   mycroft .endif
    133  1.78   mycroft .else
    134  1.64        tv ${_F}:		${F}${MANSUFFIX} __installpage		# install rule
    135  1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
    136  1.64        tv ${_F}:		.MADE					# no build at install
    137  1.43     lukem .endif
    138  1.78   mycroft .endif
    139  1.78   mycroft 
    140  1.78   mycroft catpages::	${_F}
    141  1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
    142  1.64        tv .endfor
    143  1.25  christos 
    144  1.64        tv catlinks: catpages					# symlink install
    145  1.64        tv .if !empty(MLINKS)
    146   1.1       cgd 	@set ${MLINKS}; \
    147   1.1       cgd 	while test $$# -ge 2; do \
    148  1.64        tv 		name=$$1; shift; \
    149  1.64        tv 		dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \
    150  1.64        tv 		l=$${dir}${MANSUBDIR}/$${name%.*}.0${MANSUFFIX}; \
    151  1.64        tv 		name=$$1; shift; \
    152  1.64        tv 		dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \
    153  1.64        tv 		t=$${dir}${MANSUBDIR}/$${name%.*}.0${MANSUFFIX}; \
    154  1.55    itojun 		if test $$l -nt $$t -o ! -f $$t; then \
    155  1.55    itojun 			echo $$t -\> $$l; \
    156  1.68     perry 			${INSTALL_LINK} $$l $$t; \
    157  1.55    itojun 		fi; \
    158  1.20       cgd 	done
    159   1.8   mycroft .endif
    160  1.64        tv .endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no")
    161  1.56      phil 
    162  1.64        tv ##### Build and install rules (HTML pages)
    163  1.56      phil 
    164  1.64        tv .if !defined(NOHTML)
    165  1.64        tv installhtml:	htmlpages
    166  1.64        tv htmlpages::	# ensure target exists
    167  1.64        tv HTMLPAGES=	${MAN:C/\.([1-9])$/.html\1/}
    168  1.64        tv 
    169  1.64        tv html:		${HTMLPAGES}
    170  1.64        tv .NOPATH:	${HTMLPAGES}
    171  1.64        tv .SUFFIXES:	${_MNUMBERS:@N@.html$N@}
    172  1.64        tv 
    173  1.76      ross ${_MNUMBERS:@N@.$N.html$N@}: ${HTMLDEPS}			# build rule
    174  1.73       mrg 	${GROFF_HTML} ${.IMPSRC} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET}
    175  1.64        tv 
    176  1.64        tv .for F in ${HTMLPAGES:O:u}
    177  1.77      ross # construct installed path
    178  1.77      ross _F:=		${HTMLDIR}/${F:T:E}${MANSUBDIR}/${F:R:S-/index$-/x&-}.html
    179  1.78   mycroft 
    180  1.78   mycroft .if !defined(UPDATE)
    181  1.78   mycroft ${_F}!		${F} __installpage			# install rule
    182  1.78   mycroft .if !defined(BUILD) && !make(all) && !make(${F})
    183  1.78   mycroft ${_F}!		.MADE					# no build at install
    184  1.78   mycroft .endif
    185  1.78   mycroft .else
    186  1.64        tv ${_F}:		${F} __installpage			# install rule
    187  1.64        tv .if !defined(BUILD) && !make(all) && !make(${F})
    188  1.64        tv ${_F}:		.MADE					# no build at install
    189  1.64        tv .endif
    190  1.78   mycroft .endif
    191  1.78   mycroft 
    192  1.78   mycroft htmlpages::	${_F}
    193  1.78   mycroft .PRECIOUS:	${_F}					# keep if install fails
    194  1.56      phil .endfor
    195  1.56      phil 
    196  1.56      phil cleanhtml:
    197  1.56      phil 	rm -f ${HTMLPAGES}
    198  1.64        tv .endif # !defined(NOHTML)
    199  1.31   mycroft 
    200  1.64        tv ##### Clean rules
    201  1.64        tv .undef _F
    202   1.8   mycroft 
    203  1.64        tv cleandir: cleanman
    204   1.8   mycroft cleanman:
    205  1.64        tv .if !empty(MAN) && (${MKMAN} != "no")
    206  1.64        tv .if (${MKCATPAGES} != "no")
    207  1.25  christos 	rm -f ${CATPAGES}
    208   1.1       cgd .endif
    209  1.64        tv .if !empty(MANSUFFIX)
    210  1.64        tv 	rm -f ${MANPAGES} ${CATPAGES:S/${MANSUFFIX}$//}
    211  1.64        tv .endif
    212  1.64        tv .endif
    213  1.64        tv # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used)
    214  1.64        tv 
    215  1.64        tv ##### Pull in related .mk logic
    216  1.64        tv .include <bsd.obj.mk>
    217  1.67   thorpej .include <bsd.sys.mk>
    218  1.34   mycroft 
    219  1.64        tv ${TARGETS} catinstall maninstall: # ensure existence
    220