Re: git: 557cc0f350e7 - main - bsd.man.mk: Handle MANSRC.{TARGET} for MK_MANCOMPRESS=no and empty MANBUILDCAT

From: Matteo Riondato <matteo_at_FreeBSD.org>
Date: Thu, 28 Aug 2025 15:53:44 UTC

> On Aug 28, 2025, at 10:09 AM, John Baldwin <jhb@freebsd.org> wrote:
> 
> On 8/28/25 08:10, Matteo Riondato wrote:
>>> On Aug 27, 2025, at 4:12 PM, John Baldwin <jhb@freebsd.org> wrote:
>>> 
>>> The branch main has been updated by jhb:
>>> 
>>> URL: https://cgit.FreeBSD.org/src/commit/?id=557cc0f350e758a223dffe8bca359de9fc2642b2
>>> 
>>> commit 557cc0f350e758a223dffe8bca359de9fc2642b2
>>> Author:     John Baldwin <jhb@FreeBSD.org>
>>> AuthorDate: 2025-08-27 20:11:54 +0000
>>> Commit:     John Baldwin <jhb@FreeBSD.org>
>>> CommitDate: 2025-08-27 20:11:54 +0000
>>> 
>>>    bsd.man.mk: Handle MANSRC.{TARGET} for MK_MANCOMPRESS=no and empty MANBUILDCAT
>>> 
>>>    Reviewed by:    kevans
>>>    Fixes:          65f60d715fd9 ("bsd.man.mk: Add a MANSRC.{TARGET} variable")
>>>    Sponsored by:   Chelsio Communications
>>>    Differential Revision:  https://reviews.freebsd.org/D52181
>>> ---
>> This did not fix the breakage of buildworld I reported. I had to disable “WITHOUT_MANCOMPRESS=y” from src.conf to make buildworld complete.
> 
> Locally for me it fixed libutil++ (which is what you reported), and while I also
> tried a library that did not use MANSRC (libutil), something else must be going
> on.
> 
>> Once I’ve done a successful buildworld with “WITHOUT_MANCOMPRESS=y” disabled, I tried to buildworld with “WITHOUT_MANCOMPRESS=y” enabled, and it failed again, at:
>> make[3]: don't know how to make apmd.8. Stop
>> (detailed message below)
>> I have “WITHOUT_APM=y” in src.conf, so I don’t know why it is trying to build ampd.8.
> 
> Hmm, that is because of this in usr.sbin/Makefile which I think is quite wrong
> (it probably installs the manpage twice on i386 (and possibly in different packages?)
> which would break pkgbase if we were building packages for i386):
> 
> # Add architecture-specific manpages
> # to be included anyway
> MAN=   apmd/apmd.8 \
>       nvram/nvram.8
> 
>> I tried without specifying “-j50”, with “WITHOUT_MANCOMPRESS=y” enabled, and it stopped at:
>> make[4]: don't know how to make vi.1. Stop
> 
> This is similar to the above in that it has a relative pathname with a subdirectory:
> 
> MAN=    ${SRCDIR}/man/vi.1
> 
> Most of the existing logic in bsd.man.mk uses :T, but perhaps the rule this commit added
> needs to not use :T when defining the target in the !MANSRC case.
> 
> The patch below fixes a manual 'make WITHOUT_MANCOMPRESS=yes' in usr.bin/vi in a buildenv
> for me and I think would fix the apmd.8 case as well.
> 
> diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk
> index 768879b64e60..a2c34eff9e3e 100644
> --- a/share/mk/bsd.man.mk
> +++ b/share/mk/bsd.man.mk
> @@ -169,14 +169,16 @@ ${__target}: ${MANSRC.${__page:T}:U${__page}}
> .endfor
> .else
> .for __page in ${${__group}}
> +.if defined(MANSRC.${__page:T})
> .for __target in ${__page:T:S/:/\:/g}
> all-man: ${__target}
> -.if defined(MANSRC.${__page:T})
> CLEANFILES+= ${__target}
> ${__target}: ${MANSRC.${__page:T}}
> ${CP} ${.ALLSRC} ${.TARGET}
> -.endif
> .endfor
> +.else
> +all-man: ${__page}
> +.endif
> .endfor
> .endif
> .endif

This fixes “make -j50 buildworld” for me with “WITHOUT_MANCOMPRESS=y” in src.conf. 

Thank you!

> (In a related note, I don't really understand the nested for loops used in much of bsd.man.mk,
> once you do 'for page in group' page will already be a single word so the 'for target in page'
> will always just be a single iteration IIUC.  Is it just a convenient way to define __target as
> a temporary variable?)

That’s above my pay grade =)


Thanks,
Matteo