1# $OpenBSD: bsd.man.mk,v 1.30 2010/04/03 19:34:00 schwarze Exp $ 2# $NetBSD: bsd.man.mk,v 1.23 1996/02/10 07:49:33 jtc Exp $ 3# @(#)bsd.man.mk 5.2 (Berkeley) 5/11/90 4 5MANTARGET?= cat 6MANDOC?= mandoc 7NROFF?= nroff -Tascii 8TBL?= tbl 9MANLINT?= \# 10 11.if !target(.MAIN) 12. if exists(${.CURDIR}/../Makefile.inc) 13. include "${.CURDIR}/../Makefile.inc" 14. endif 15 16.MAIN: all 17.endif 18 19.SUFFIXES: .1 .2 .3 .3p .4 .5 .6 .7 .8 .9 \ 20 .1tbl .2tbl .3tbl .4tbl .5tbl .6tbl .7tbl .8tbl .9tbl \ 21 .cat1 .cat2 .cat3 .cat3p .cat4 .cat5 .cat6 .cat7 .cat8 .cat9 \ 22 .ps1 .ps2 .ps3 .ps3p .ps4 .ps5 .ps6 .ps7 .ps8 .ps9 23 24.9.cat9 .8.cat8 .7.cat7 .6.cat6 .5.cat5 .4.cat4 .3p.cat3p .3.cat3 .2.cat2 .1.cat1: 25 @echo "${MANDOC} ${.IMPSRC} > ${.TARGET}" 26 @${MANDOC} ${.IMPSRC} > ${.TARGET} || (rm -f ${.TARGET}; false) 27 28.9tbl.cat9 .8tbl.cat8 .7tbl.cat7 .6tbl.cat6 .5tbl.cat5 .4tbl.cat4 .3tbl.cat3 \ 29.2tbl.cat2 .1tbl.cat1: 30 @echo "${TBL} ${.IMPSRC} | ${NROFF} -mandoc > ${.TARGET}" 31 @${MANLINT} -tbl ${.IMPSRC} 32 @${TBL} ${.IMPSRC} | ${NROFF} -mandoc > ${.TARGET} || \ 33 (rm -f ${.TARGET}; false) 34 35.9.ps9 .8.ps8 .7.ps7 .6.ps6 .5.ps5 .4.ps4 .3p.ps3p .3.ps3 .2.ps2 .1.ps1: 36 @echo "nroff -Tps -mandoc ${.IMPSRC} > ${.TARGET}" 37 @nroff -Tps -mandoc ${.IMPSRC} > ${.TARGET} || (rm -f ${.TARGET}; false) 38 39.9tbl.ps9 .8tbl.ps8 .7tbl.ps7 .6tbl.ps6 .5tbl.ps5 .4tbl.ps4 .3tbl.ps3 \ 40.2tbl.ps2 .1tbl.ps1: 41 @echo "${TBL} ${.IMPSRC} | nroff -Tps -mandoc > ${.TARGET}" 42 @${TBL} ${.IMPSRC} | nroff -Tps -mandoc > ${.TARGET} || (rm -f ${.TARGET}; false) 43 44.if defined(MAN) && !empty(MAN) && !defined(MANALL) 45. for v s in MANALL .cat PS2ALL .ps 46 47$v= ${MAN:S/.1$/$s1/g:S/.2$/$s2/g:S/.3$/$s3/g:S/.3p$/$s3p/g:S/.4$/$s4/g:S/.5$/$s5/g:S/.6$/$s6/g:S/.7$/$s7/g:S/.8$/$s8/g:S/.9$/$s9/g:S/.1tbl$/$s1/g:S/.2tbl$/$s2/g:S/.3tbl$/$s3/g:S/.4tbl$/$s4/g:S/.5tbl$/$s5/g:S/.6tbl$/$s6/g:S/.7tbl$/$s7/g:S/.8tbl$/$s8/g:S/.9tbl$/$s9/g} 48 49. endfor 50 51. if defined(MANPS) 52PSALL=${PS2ALL} 53. endif 54 55.endif 56 57MINSTALL= ${INSTALL} ${INSTALL_COPY} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} 58.if defined(MANZ) 59# chown and chmod are done afterward automatically 60MCOMPRESS= gzip -cf 61MCOMPRESSSUFFIX= .gz 62.endif 63 64.if defined(MANSUBDIR) 65# Add / so that we don't have to specify it. Better arch -> MANSUBDIR mapping 66MANSUBDIR:=${MANSUBDIR:S,^,/,} 67.else 68# XXX MANSUBDIR must be non empty for the mlink loops to work 69MANSUBDIR='' 70.endif 71 72.if !defined(MCOMPRESS) || empty(MCOMPRESS) 73install_manpage_fragment= \ 74 echo ${MINSTALL} $$page $$instpage; \ 75 ${MINSTALL} $$page $$instpage 76.else 77install_manpage_fragment= \ 78 rm -f $$instpage; \ 79 echo ${MCOMPRESS} $$page \> $$instpage; \ 80 ${MCOMPRESS} $$page > $$instpage; \ 81 chown ${MANOWN}:${MANGRP} $$instpage; \ 82 chmod ${MANMODE} $$instpage 83.endif 84 85maninstall: 86.for v d s t in MANALL ${MANDIR} .cat .0 PSALL ${PSDIR} .ps .ps 87. if defined($v) 88 @for page in ${$v}; do \ 89 set -- ${MANSUBDIR}; \ 90 subdir=$$1; \ 91 dir=${DESTDIR}$d$${page##*$s}; \ 92 base=$${page##*/}; \ 93 instpage=$${dir}$${subdir}/$${base%.*}$t${MCOMPRESSSUFFIX}; \ 94 ${install_manpage_fragment}; \ 95 while test $$# -ge 2; do \ 96 shift; \ 97 extra=$${dir}$$1/$${base%.*}$t${MCOMPRESSSUFFIX}; \ 98 echo $$extra -\> $$instpage; \ 99 ln -f $$instpage $$extra; \ 100 done; \ 101 done 102. endif 103.endfor 104 105.if defined(MLINKS) && !empty(MLINKS) 106. for sub in ${MANSUBDIR} 107. for lnk file in ${MLINKS} 108 @l=${DESTDIR}${MANDIR}${lnk:E}${sub}/${lnk:R}.0${MCOMPRESSSUFFIX}; \ 109 t=${DESTDIR}${MANDIR}${file:E}${sub}/${file:R}.0${MCOMPRESSSUFFIX}; \ 110 echo $$t -\> $$l; \ 111 rm -f $$t; ln $$l $$t; 112. endfor 113. endfor 114.endif 115 116.if (defined(MANALL) || defined(PSALL)) && !defined(MANLOCALBUILD) 117all: ${MANALL} ${PSALL} 118 119BEFOREMAN?= 120${MANALL} ${PSALL}: ${BEFOREMAN} 121 122 123cleandir: cleanman 124cleanman: 125 rm -f ${MANALL} ${PS2ALL} 126.endif 127