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