bsd.man.mk: Add a MANSRC.{TARGET} variable

This can be used to specify an alternate source file name for an
individual manpage.  For example, the following snippet:

    MAN=   foo::bar.3
    MANSRC.foo::bar.3= foo__bar.3

Will install a foo::bar.3 manpage but use foo__bar.3 as the source
input to MANFILTER, etc.

Suggested by:	ivy
Reviewed by:	ivy
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D51793
This commit is contained in:
John Baldwin
2025-08-26 16:44:11 -04:00
parent b55439338d
commit 65f60d715f
2 changed files with 16 additions and 7 deletions
+3
View File
@@ -259,6 +259,9 @@ MLINKS List of manual page links (using a .1 - .9 suffix). The
linked-to file must come first, the linked file second, linked-to file must come first, the linked file second,
and there may be multiple pairs. The files are hard-linked. and there may be multiple pairs. The files are hard-linked.
MANSRC.${MAN:T} Name of source file for an individual manual page.
Defaults to the manual page name.
The include file <bsd.man.mk> includes a file named "../Makefile.inc" if The include file <bsd.man.mk> includes a file named "../Makefile.inc" if
it exists. it exists.
+13 -7
View File
@@ -21,6 +21,9 @@
# MAN The manual pages to be installed. For sections see # MAN The manual pages to be installed. For sections see
# variable ${SECTIONS} # variable ${SECTIONS}
# #
# MANSRC.${MAN:T} Name of source file for an individual manual page.
# Defaults to the manual page name.
#
# MCOMPRESS_CMD Program to compress man pages. Output is to # MCOMPRESS_CMD Program to compress man pages. Output is to
# stdout. [${COMPRESS_CMD}] # stdout. [${COMPRESS_CMD}]
# #
@@ -141,13 +144,13 @@ CLEANFILES+= ${${__group}:T:S/$/${CATEXT}${FILTEXTENSION}/g}
# filenames contain colons. # filenames contain colons.
.for __target in ${__page:T:S/:/\:/g:S/$/${FILTEXTENSION}/g} .for __target in ${__page:T:S/:/\:/g:S/$/${FILTEXTENSION}/g}
all-man: ${__target} all-man: ${__target}
${__target}: ${__page} ${__target}: ${MANSRC.${__page:T}:U${__page}}
${MANFILTER} < ${.ALLSRC} > ${.TARGET} ${MANFILTER} < ${.ALLSRC} > ${.TARGET}
.endfor .endfor
.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
.for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}${FILTEXTENSION}/g} .for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}${FILTEXTENSION}/g}
all-man: ${__target} all-man: ${__target}
${__target}: ${__page} ${__target}: ${MANSRC.${__page:T}:U${__page}}
${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} > ${.TARGET} ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} > ${.TARGET}
.endfor .endfor
.endif .endif
@@ -160,7 +163,7 @@ CLEANFILES+= ${${__group}:T:S/$/${CATEXT}/g}
.for __page in ${${__group}} .for __page in ${${__group}}
.for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}/g} .for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}/g}
all-man: ${__target} all-man: ${__target}
${__target}: ${__page} ${__target}: ${MANSRC.${__page:T}:U${__page}}
${MANDOC_CMD} ${.ALLSRC} > ${.TARGET} ${MANDOC_CMD} ${.ALLSRC} > ${.TARGET}
.endfor .endfor
.endfor .endfor
@@ -180,7 +183,7 @@ CLEANFILES+= ${${__group}:T:S/$/${CATEXT}${MCOMPRESS_EXT}/g}
.for __page in ${${__group}} .for __page in ${${__group}}
.for __target in ${__page:T:S/:/\:/g:S/$/${MCOMPRESS_EXT}/} .for __target in ${__page:T:S/:/\:/g:S/$/${MCOMPRESS_EXT}/}
all-man: ${__target} all-man: ${__target}
${__target}: ${__page} ${__target}: ${MANSRC.${__page:T}:U${__page}}
.if defined(MANFILTER) .if defined(MANFILTER)
${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET} ${MANFILTER} < ${.ALLSRC} | ${MCOMPRESS_CMD} > ${.TARGET}
.else .else
@@ -190,7 +193,7 @@ ${__target}: ${__page}
.if defined(MANBUILDCAT) && !empty(MANBUILDCAT) .if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
.for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}${MCOMPRESS_EXT}/} .for __target in ${__page:T:S/:/\:/g:S/$/${CATEXT}${MCOMPRESS_EXT}/}
all-man: ${__target} all-man: ${__target}
${__target}: ${__page} ${__target}: ${MANSRC.${__page:T}:U${__page}}
.if defined(MANFILTER) .if defined(MANFILTER)
${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} | ${MCOMPRESS_CMD} > ${.TARGET} ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} | ${MCOMPRESS_CMD} > ${.TARGET}
.else .else
@@ -238,7 +241,10 @@ stage_links.mlinks.${__group}: ${_mansets.${__group}:@s@stage_files.${__group}.$
realmaninstall-${__group}: realmaninstall-${__group}:
.if defined(${__group}) && !empty(${__group}) .if defined(${__group}) && !empty(${__group})
realmaninstall-${__group}: ${${__group}} .for __page in ${${__group}}
__mansrc.${__group}+= ${MANSRC.${__page:T}:U${__page}}
.endfor
realmaninstall-${__group}: ${__mansrc.${__group}}
.if ${MK_MANCOMPRESS} == "no" .if ${MK_MANCOMPRESS} == "no"
.if defined(MANFILTER) .if defined(MANFILTER)
.for __page in ${${__group}} .for __page in ${${__group}}
@@ -292,7 +298,7 @@ manlint: .PHONY checkmanlinks
.if defined(${__group}) && !empty(${__group}) .if defined(${__group}) && !empty(${__group})
.for __page in ${${__group}} .for __page in ${${__group}}
manlint: ${__page:S/:/\:/g}lint manlint: ${__page:S/:/\:/g}lint
${__page:S/:/\:/g}lint: .PHONY ${__page} ${__page:S/:/\:/g}lint: .PHONY ${MANSRC.${__page:T}:U${__page}}
.if defined(MANFILTER) .if defined(MANFILTER)
${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} -Tlint ${MANFILTER} < ${.ALLSRC} | ${MANDOC_CMD} -Tlint
.else .else