1 1.96 dbj # $NetBSD: bsd.man.mk,v 1.96 2006/09/11 22:24:09 dbj 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.32 mycroft realinstall: ${MANINSTALL} 9 1.28 mycroft 10 1.64 tv ##### Default values 11 1.66 tv .if ${USETOOLS} == "yes" 12 1.69 jmc TMACDEPDIR?= ${TOOLDIR}/share/groff/tmac 13 1.66 tv .else 14 1.93 jmc TMACDEPDIR?= /usr/share/tmac 15 1.69 jmc .endif 16 1.66 tv 17 1.56 phil HTMLDIR?= ${DESTDIR}/usr/share/man 18 1.80 wiz CATDEPS?= ${TMACDEPDIR}/andoc.tmac \ 19 1.80 wiz ${TMACDEPDIR}/doc.tmac \ 20 1.80 wiz ${TMACDEPDIR}/mdoc/doc-common \ 21 1.80 wiz ${TMACDEPDIR}/mdoc/doc-ditroff \ 22 1.80 wiz ${TMACDEPDIR}/mdoc/doc-nroff \ 23 1.80 wiz ${TMACDEPDIR}/mdoc/doc-syms 24 1.80 wiz HTMLDEPS?= ${TMACDEPDIR}/doc2html.tmac 25 1.28 mycroft MANTARGET?= cat 26 1.66 tv 27 1.64 tv MAN?= 28 1.64 tv MLINKS?= 29 1.64 tv _MNUMBERS= 1 2 3 4 5 6 7 8 9 30 1.64 tv .SUFFIXES: ${_MNUMBERS:@N@.$N@} 31 1.64 tv 32 1.82 lukem .if ${MKMANZ} == "no" 33 1.82 lukem MANCOMPRESS?= 34 1.82 lukem MANSUFFIX?= 35 1.82 lukem .else 36 1.82 lukem MANCOMPRESS?= gzip -cf 37 1.82 lukem MANSUFFIX?= .gz 38 1.82 lukem .endif 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.90 lukem (${_MKSHMSG_INSTALL} ${.TARGET}; \ 48 1.87 lukem ${_MKSHECHO} "${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ 49 1.95 jwise ${.ALLSRC} ${.TARGET}" && \ 50 1.64 tv ${INSTALL_FILE} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \ 51 1.95 jwise ${.ALLSRC} ${.TARGET}) 52 1.25 christos 53 1.96 dbj # XXX consider including bsd.links.mk and using __linkinstall instead 54 1.96 dbj __linkinstallpage: .USE 55 1.96 dbj ${_MKSHMSG_INSTALL} ${.TARGET}; \ 56 1.96 dbj ${_MKSHECHO} "${INSTALL_LINK} ${.ALLSRC} ${.TARGET}" && \ 57 1.96 dbj ${INSTALL_LINK} ${.ALLSRC} ${.TARGET} 58 1.96 dbj 59 1.64 tv ##### Build and install rules (source form pages) 60 1.25 christos 61 1.64 tv .if ${MKMAN} != "no" 62 1.96 dbj maninstall: manpages manlinks 63 1.64 tv manpages:: # ensure target exists 64 1.65 enami MANPAGES= ${MAN:C/.$/&${MANSUFFIX}/} 65 1.64 tv 66 1.72 tv realall: ${MANPAGES} 67 1.64 tv .if !empty(MANSUFFIX) 68 1.64 tv .NOPATH: ${MANPAGES} 69 1.64 tv .SUFFIXES: ${_MNUMBERS:@N@.$N${MANSUFFIX}@} 70 1.64 tv 71 1.64 tv ${_MNUMBERS:@N@.$N.$N${MANSUFFIX}@}: # build rule 72 1.73 mrg cat ${.IMPSRC} ${MANCOMPRESS} > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} 73 1.64 tv .endif # !empty(MANSUFFIX) 74 1.64 tv 75 1.64 tv .for F in ${MANPAGES:S/${MANSUFFIX}$//:O:u} 76 1.64 tv _F:= ${DESTDIR}${MANDIR}/man${F:T:E}${MANSUBDIR}/${F}${MANSUFFIX} 77 1.64 tv 78 1.83 lukem .if ${MKUPDATE} == "no" 79 1.78 mycroft ${_F}! ${F}${MANSUFFIX} __installpage # install rule 80 1.78 mycroft .if !defined(BUILD) && !make(all) && !make(${F}) 81 1.78 mycroft ${_F}! .MADE # no build at install 82 1.78 mycroft .endif 83 1.78 mycroft .else 84 1.64 tv ${_F}: ${F}${MANSUFFIX} __installpage # install rule 85 1.64 tv .if !defined(BUILD) && !make(all) && !make(${F}) 86 1.64 tv ${_F}: .MADE # no build at install 87 1.53 mycroft .endif 88 1.78 mycroft .endif 89 1.78 mycroft 90 1.78 mycroft manpages:: ${_F} 91 1.78 mycroft .PRECIOUS: ${_F} # keep if install fails 92 1.64 tv .endfor 93 1.52 mycroft 94 1.96 dbj manlinks:: # link install 95 1.96 dbj 96 1.96 dbj .for _src _dst in ${MLINKS} 97 1.96 dbj _l:=${DESTDIR}${MANDIR}/man${_src:T:E}${MANSUBDIR}/${_src}${MANSUFFIX} 98 1.96 dbj _t:=${DESTDIR}${MANDIR}/man${_dst:T:E}${MANSUBDIR}/${_dst}${MANSUFFIX} 99 1.96 dbj 100 1.96 dbj # Handle case conflicts carefully, when _dst occurs 101 1.96 dbj # more than once after case flattening 102 1.96 dbj .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1 103 1.96 dbj ${_t}! ${_l} __linkinstallpage 104 1.96 dbj .else 105 1.96 dbj ${_t}: ${_l} __linkinstallpage 106 1.19 brezak .endif 107 1.96 dbj 108 1.96 dbj manlinks:: ${_t} 109 1.96 dbj .PRECIOUS: ${_t} 110 1.96 dbj .endfor 111 1.64 tv .endif # ${MKMAN} != "no" 112 1.64 tv 113 1.64 tv ##### Build and install rules (plaintext pages) 114 1.64 tv 115 1.64 tv .if (${MKCATPAGES} != "no") && (${MKMAN} != "no") 116 1.96 dbj catinstall: catpages catlinks 117 1.64 tv catpages:: # ensure target exists 118 1.64 tv CATPAGES= ${MAN:C/\.([1-9])$/.cat\1${MANSUFFIX}/} 119 1.64 tv 120 1.64 tv realall: ${CATPAGES} 121 1.64 tv .NOPATH: ${CATPAGES} 122 1.64 tv .SUFFIXES: ${_MNUMBERS:@N@.cat$N${MANSUFFIX}@} 123 1.75 christos .MADE: ${CATDEPS} 124 1.76 ross .MADE: ${HTMLDEPS} 125 1.64 tv 126 1.64 tv ${_MNUMBERS:@N@.$N.cat$N${MANSUFFIX}@}: ${CATDEPS} # build rule 127 1.88 lukem ${_MKTARGET_FORMAT} 128 1.64 tv .if defined(USETBL) 129 1.81 lukem ${TOOL_TBL} ${.IMPSRC} | ${TOOL_ROFF_ASCII} -mandoc ${MANCOMPRESS} \ 130 1.81 lukem > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} 131 1.64 tv .else 132 1.81 lukem ${TOOL_ROFF_ASCII} -mandoc ${.IMPSRC} ${MANCOMPRESS} \ 133 1.81 lukem > ${.TARGET}.tmp && mv ${.TARGET}.tmp ${.TARGET} 134 1.64 tv .endif 135 1.64 tv 136 1.64 tv .for F in ${CATPAGES:S/${MANSUFFIX}$//:O:u} 137 1.64 tv _F:= ${DESTDIR}${MANDIR}/${F:T:E}${MANSUBDIR}/${F:R}.0${MANSUFFIX} 138 1.78 mycroft 139 1.83 lukem .if ${MKUPDATE} == "no" 140 1.78 mycroft ${_F}! ${F}${MANSUFFIX} __installpage # install rule 141 1.78 mycroft .if !defined(BUILD) && !make(all) && !make(${F}) 142 1.78 mycroft ${_F}! .MADE # no build at install 143 1.78 mycroft .endif 144 1.78 mycroft .else 145 1.64 tv ${_F}: ${F}${MANSUFFIX} __installpage # install rule 146 1.64 tv .if !defined(BUILD) && !make(all) && !make(${F}) 147 1.64 tv ${_F}: .MADE # no build at install 148 1.43 lukem .endif 149 1.78 mycroft .endif 150 1.78 mycroft 151 1.78 mycroft catpages:: ${_F} 152 1.78 mycroft .PRECIOUS: ${_F} # keep if install fails 153 1.64 tv .endfor 154 1.25 christos 155 1.96 dbj catlinks:: # link install 156 1.96 dbj 157 1.96 dbj .for _src _dst in ${MLINKS} 158 1.96 dbj _l:=${DESTDIR}${MANDIR}/cat${_src:T:E}${MANSUBDIR}/${_src:R}.0${MANSUFFIX} 159 1.96 dbj _t:=${DESTDIR}${MANDIR}/cat${_dst:T:E}${MANSUBDIR}/${_dst:R}.0${MANSUFFIX} 160 1.96 dbj 161 1.96 dbj # Handle case conflicts carefully, when _dst occurs 162 1.96 dbj # more than once after case flattening 163 1.96 dbj .if ${MKUPDATE} == "no" || ${MLINKS:tl:M${_dst:tl:Q}:[\#]} > 1 164 1.96 dbj ${_t}! ${_l} __linkinstallpage 165 1.96 dbj .else 166 1.96 dbj ${_t}: ${_l} __linkinstallpage 167 1.8 mycroft .endif 168 1.96 dbj 169 1.96 dbj catlinks:: ${_t} 170 1.96 dbj .PRECIOUS: ${_t} 171 1.96 dbj .endfor 172 1.64 tv .endif # (${MKCATPAGES} != "no") && (${MKMAN} != "no") 173 1.56 phil 174 1.64 tv ##### Build and install rules (HTML pages) 175 1.56 phil 176 1.82 lukem .if ${MKHTML} != "no" # { 177 1.91 lukem installhtml: .PHONY htmlpages 178 1.64 tv htmlpages:: # ensure target exists 179 1.64 tv HTMLPAGES= ${MAN:C/\.([1-9])$/.html\1/} 180 1.64 tv 181 1.91 lukem html: .PHONY ${HTMLPAGES} 182 1.64 tv .NOPATH: ${HTMLPAGES} 183 1.64 tv .SUFFIXES: ${_MNUMBERS:@N@.html$N@} 184 1.64 tv 185 1.76 ross ${_MNUMBERS:@N@.$N.html$N@}: ${HTMLDEPS} # build rule 186 1.88 lukem ${_MKTARGET_FORMAT} 187 1.81 lukem ${TOOL_ROFF_HTML} ${.IMPSRC} > ${.TARGET}.tmp && \ 188 1.81 lukem mv ${.TARGET}.tmp ${.TARGET} 189 1.64 tv 190 1.64 tv .for F in ${HTMLPAGES:O:u} 191 1.77 ross # construct installed path 192 1.77 ross _F:= ${HTMLDIR}/${F:T:E}${MANSUBDIR}/${F:R:S-/index$-/x&-}.html 193 1.78 mycroft 194 1.83 lukem .if ${MKUPDATE} == "no" 195 1.78 mycroft ${_F}! ${F} __installpage # install rule 196 1.78 mycroft .if !defined(BUILD) && !make(all) && !make(${F}) 197 1.78 mycroft ${_F}! .MADE # no build at install 198 1.78 mycroft .endif 199 1.78 mycroft .else 200 1.64 tv ${_F}: ${F} __installpage # install rule 201 1.64 tv .if !defined(BUILD) && !make(all) && !make(${F}) 202 1.64 tv ${_F}: .MADE # no build at install 203 1.64 tv .endif 204 1.78 mycroft .endif 205 1.78 mycroft 206 1.78 mycroft htmlpages:: ${_F} 207 1.78 mycroft .PRECIOUS: ${_F} # keep if install fails 208 1.56 phil .endfor 209 1.56 phil 210 1.91 lukem cleanhtml: .PHONY 211 1.56 phil rm -f ${HTMLPAGES} 212 1.82 lukem .endif # } 213 1.31 mycroft 214 1.64 tv ##### Clean rules 215 1.64 tv .undef _F 216 1.8 mycroft 217 1.64 tv cleandir: cleanman 218 1.94 tron .if !empty(CLEANFILES) 219 1.94 tron rm -f ${CLEANFILES} 220 1.94 tron .endif 221 1.94 tron 222 1.91 lukem cleanman: .PHONY 223 1.64 tv .if !empty(MAN) && (${MKMAN} != "no") 224 1.64 tv .if (${MKCATPAGES} != "no") 225 1.25 christos rm -f ${CATPAGES} 226 1.1 cgd .endif 227 1.64 tv .if !empty(MANSUFFIX) 228 1.64 tv rm -f ${MANPAGES} ${CATPAGES:S/${MANSUFFIX}$//} 229 1.64 tv .endif 230 1.64 tv .endif 231 1.64 tv # (XXX ${CATPAGES:S...} cleans up old .catN files where .catN.gz now used) 232 1.64 tv 233 1.64 tv ##### Pull in related .mk logic 234 1.64 tv .include <bsd.obj.mk> 235 1.84 lukem .include <bsd.files.mk> 236 1.67 thorpej .include <bsd.sys.mk> 237 1.34 mycroft 238 1.64 tv ${TARGETS} catinstall maninstall: # ensure existence 239