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