1 1.29 mycroft # $NetBSD: bsd.man.mk,v 1.29 1997/05/06 21:29:41 mycroft Exp $ 2 1.26 mikel # @(#)bsd.man.mk 8.1 (Berkeley) 6/8/93 3 1.1 cgd 4 1.9 mycroft .if !target(.MAIN) 5 1.1 cgd .if exists(${.CURDIR}/../Makefile.inc) 6 1.1 cgd .include "${.CURDIR}/../Makefile.inc" 7 1.9 mycroft .endif 8 1.9 mycroft 9 1.28 mycroft .MAIN: all 10 1.1 cgd .endif 11 1.28 mycroft .PHONY: catinstall maninstall catpages manpages catlinks manlinks cleanman 12 1.28 mycroft 13 1.28 mycroft MANTARGET?= cat 14 1.28 mycroft NROFF?= nroff 15 1.12 jtc 16 1.25 christos .SUFFIXES: .1 .2 .3 .4 .5 .6 .7 .8 .9 \ 17 1.25 christos .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 .cat7 .cat8 .cat9 18 1.12 jtc 19 1.21 perry .9.cat9 .8.cat8 .7.cat7 .6.cat6 .5.cat5 .4.cat4 .3.cat3 .2.cat2 .1.cat1: 20 1.22 thorpej @echo "${NROFF} -mandoc ${.IMPSRC} > ${.TARGET}" 21 1.25 christos @${NROFF} -mandoc ${.IMPSRC} > ${.TARGET} || \ 22 1.25 christos (rm -f ${.TARGET}; false) 23 1.12 jtc 24 1.16 cgd .if defined(MAN) && !empty(MAN) 25 1.25 christos MANPAGES= ${MAN} 26 1.25 christos CATPAGES= ${MANPAGES:C/(.*).([1-9])/\1.cat\2/} 27 1.16 cgd .endif 28 1.1 cgd 29 1.24 thorpej MINSTALL= ${INSTALL} ${COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 30 1.25 christos 31 1.20 cgd .if defined(MANZ) 32 1.20 cgd # chown and chmod are done afterward automatically 33 1.20 cgd MCOMPRESS= gzip -cf 34 1.20 cgd MCOMPRESSSUFFIX= .gz 35 1.20 cgd .endif 36 1.1 cgd 37 1.25 christos catinstall: catlinks 38 1.25 christos maninstall: manlinks 39 1.25 christos 40 1.25 christos __installpage: .USE 41 1.25 christos .if defined(MCOMPRESS) && !empty(MCOMPRESS) 42 1.25 christos @rm -f ${.TARGET} 43 1.25 christos ${MCOMPRESS} ${.ALLSRC} > ${.TARGET} 44 1.25 christos @chown ${MANOWN}:${MANGRP} ${.TARGET} 45 1.25 christos @chmod ${MANMODE} ${.TARGET} 46 1.25 christos .else 47 1.25 christos ${MINSTALL} ${.ALLSRC} ${.TARGET} 48 1.25 christos .endif 49 1.25 christos 50 1.25 christos 51 1.25 christos # Rules for source page installation 52 1.25 christos .if defined(MANPAGES) && !empty(MANPAGES) 53 1.25 christos . for P in ${MANPAGES} 54 1.27 perry manpages:: ${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX} 55 1.25 christos . if !defined(UPDATE) 56 1.27 perry .PHONY: ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX} 57 1.25 christos . endif 58 1.25 christos 59 1.29 mycroft .PRECIOUS: ${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX} 60 1.27 perry ${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}: ${P} __installpage 61 1.25 christos . endfor 62 1.25 christos .else 63 1.25 christos manpages:: 64 1.25 christos .endif 65 1.25 christos 66 1.25 christos # Rules for cat'ed man page installation 67 1.25 christos .if defined(CATPAGES) && !empty(CATPAGES) 68 1.25 christos . for P in ${CATPAGES} 69 1.25 christos catpages:: ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX} 70 1.25 christos 71 1.25 christos . if !defined(UPDATE) 72 1.25 christos .PHONY: ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX} 73 1.25 christos . endif 74 1.25 christos . if !defined(BUILD) 75 1.25 christos ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: .MADE 76 1.25 christos . endif 77 1.25 christos 78 1.29 mycroft .PRECIOUS: ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX} 79 1.25 christos ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: ${P} __installpage 80 1.25 christos . endfor 81 1.25 christos .else 82 1.25 christos catpages:: 83 1.25 christos .endif 84 1.25 christos 85 1.25 christos catlinks: catpages 86 1.25 christos .if defined(MLINKS) && !empty(MLINKS) 87 1.25 christos @set ${MLINKS}; \ 88 1.25 christos while test $$# -ge 2; do \ 89 1.25 christos name=$$1; \ 90 1.25 christos shift; \ 91 1.25 christos dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \ 92 1.25 christos l=$${dir}${MANSUBDIR}/$${name%.*}.0${MCOMPRESSSUFFIX}; \ 93 1.25 christos name=$$1; \ 94 1.25 christos shift; \ 95 1.25 christos dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \ 96 1.25 christos t=$${dir}${MANSUBDIR}/$${name%.*}.0${MCOMPRESSSUFFIX}; \ 97 1.25 christos if [ ! -f $$t -o -z "${UPDATE}" ]; then \ 98 1.25 christos echo $$t -\> $$l; \ 99 1.25 christos rm -f $$t; \ 100 1.25 christos ln $$l $$t; \ 101 1.25 christos fi; \ 102 1.19 brezak done 103 1.19 brezak .endif 104 1.25 christos 105 1.25 christos manlinks: manpages 106 1.1 cgd .if defined(MLINKS) && !empty(MLINKS) 107 1.1 cgd @set ${MLINKS}; \ 108 1.1 cgd while test $$# -ge 2; do \ 109 1.1 cgd name=$$1; \ 110 1.1 cgd shift; \ 111 1.25 christos dir=${DESTDIR}${MANDIR}/man$${name##*.}; \ 112 1.27 perry l=$${dir}${MANSUBDIR}/$${name}${MCOMPRESSSUFFIX}; \ 113 1.1 cgd name=$$1; \ 114 1.1 cgd shift; \ 115 1.25 christos dir=${DESTDIR}${MANDIR}/man$${name##*.}; \ 116 1.27 perry t=$${dir}${MANSUBDIR}/$${name}${MCOMPRESSSUFFIX}; \ 117 1.25 christos if [ ! -f $$t -o -z "${UPDATE}" ]; then \ 118 1.25 christos echo $$t -\> $$l; \ 119 1.25 christos rm -f $$t; \ 120 1.25 christos ln $$l $$t; \ 121 1.25 christos fi; \ 122 1.20 cgd done 123 1.8 mycroft .endif 124 1.25 christos .if defined(CATPAGES) 125 1.25 christos all: ${CATPAGES} 126 1.8 mycroft 127 1.8 mycroft cleandir: cleanman 128 1.8 mycroft cleanman: 129 1.25 christos rm -f ${CATPAGES} 130 1.1 cgd .endif 131