1 # $Id: man.mk,v 1.20 2012/12/13 01:51:01 sjg Exp $
3 .if
!target
(__
${.PARSEFILE
}__
)
8 # unlike bsd.man.mk we handle 3 approaches
9 # 1. install unformated nroff (default)
10 # 2. install formatted pages
11 # 3. install formatted pages but with extension of .0
12 # sadly we cannot rely on a shell that supports ${foo#...} and ${foo%...}
13 # so we have to use sed(1).
15 # set MANTARGET=cat for formatted pages
17 # set this to .0 for same behavior as bsd.man.mk
21 MANDIR?
= /usr
/share
/man
24 .SUFFIXES
: .1 .2 .3 .4 .5 .6 .7 .8 .9 .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 \
27 .9.cat9
.8.cat8
.7.cat7
.6.cat6
.5.cat5
.4.cat4
.3.cat3
.2.cat2
.1.cat1
:
28 @echo
"${NROFF} -${MANDOC} ${.IMPSRC} > ${.TARGET:T}"
29 @
${NROFF} -${MANDOC} ${.IMPSRC
} > ${.TARGET
:T
} ||
( rm -f
${.TARGET
:T
} ; false
)
31 .if defined
(MAN
) && !empty
(MAN
)
33 # we use cmt2doc.pl to extract manpages from source
34 # this is triggered by the setting of EXTRACT_MAN or MAN being set but
37 .if
!exists
(${MAN
:[1]}) && !target
(${MAN
:[1]})
38 .if defined
(EXTRACT_MAN
) && ${EXTRACT_MAN} == "no"
41 .if exists
(/usr
/local
/share
/bin
/cmt2doc.pl
)
43 CMT2DOC_OPTS?
= ${CMT2DOC_ORGOPT} -pmS
${.TARGET
:E
}
46 .c
.8 .c
.5 .c
.3 .c
.4 .c
.1 \
47 .
cc.8 .
cc.5 .
cc.3 .
cc.4 .
cc.1 \
48 .h
.8 .h
.5 .h
.3 .h
.4 .h
.1 \
49 .sh
.8 .sh
.5 .sh
.3 .sh
.4 .sh
.1 \
50 .pl
.8 .pl
.5 .pl
.3 .pl
.4 .pl
.1:
51 @echo
"${CMT2DOC} ${.IMPSRC} > ${.TARGET:T}"
52 @
${CMT2DOC} ${CMT2DOC_OPTS} ${.IMPSRC
} > ${.TARGET
:T
} ||
( rm -f
${.TARGET
:T
} ; false
)
59 _mandir
=${DESTDIR}${MANDIR}/${MANTARGET}`echo $$page | sed -e 's/.*\.cat/./' -e 's/.*\.//'`
60 .if
${MANTARGET} == "cat"
62 MANALL
= ${MAN
:S
/.1$/.cat1
/g
:S
/.2$/.cat2
/g
:S
/.3$/.cat3
/g
:S
/.4$/.cat4
/g
:S
/.5$/.cat5
/g
:S
/.6$/.cat6
/g
:S
/.7$/.cat7
/g
:S
/.8$/.cat8
/g
:S
/.9$/.cat9
/g
}
64 _minstpage
=`echo $$page | sed 's/\.cat/./'`
66 _minstpage
=`echo $$page | sed 's/\.cat.*//'`${MCATEXT}
69 .if target
(${MAN
:[1]})
78 MAN_INSTALL_OWN ?
= -o
${MANOWN} -g
${MANGRP}
84 MINSTALL
= ${INSTALL} ${COPY} ${MAN_INSTALL_OWN} -m
${MANMODE}
86 # chown and chmod are done afterward automatically
92 .if defined
(MANALL
) && !empty
(MANALL
)
93 @for page in
${MANALL
:T
}; do \
94 test -s
${_mfromdir}/$$page || continue
; \
96 ${INSTALL} -d
${MAN_INSTALL_OWN} -m
755 $$dir; \
97 instpage
=$${dir}${MANSUBDIR}/${_minstpage}${MCOMPRESSSUFFIX}; \
98 if
[ X
"${MCOMPRESS}" = X
]; then \
99 echo
${MINSTALL} ${_mfromdir}/$$page $$instpage; \
100 ${MINSTALL} ${_mfromdir}/$$page $$instpage; \
103 echo
${MCOMPRESS} ${_mfromdir}/$$page \
> $$instpage; \
104 ${MCOMPRESS} ${_mfromdir}/$$page > $$instpage; \
105 ${MAN_CHOWN} ${MANOWN}:${MANGRP} $$instpage; \
106 chmod
${MANMODE} $$instpage; \
109 .if defined
(MLINKS
) && !empty
(MLINKS
)
111 while
test $$# -ge 2; do \
115 l
=${_minstpage}${MCOMPRESSSUFFIX}; \
119 t
=$${dir}${MANSUBDIR}/${_minstpage}${MCOMPRESSSUFFIX}; \
127 .if defined
(MANALL
) && !empty
(MANALL
)
132 .if defined
(CLEANMAN
) && !empty
(CLEANMAN
)