Subject: Re: [PATCH v2 1/2] Makefile: add NO_HOMEBREW

From: Junio C Hamano <[email-masked]>
Date: Mon, 15 Dec 2025 08:19:57 +0900

René Scharfe <[email-masked]> writes:

> Sounds useful, but before this can become a documented feature it
> deserves more research and refinement.  The current code uses what it
> can find in an ad-hoc manner, and the patches just extend this behavior
> to libiconv.  A user-settable HOMEBREW_PREFIX would require a more
> principled approach, so that overriding it affects the search for
> gettext and libiconv.

Oh, that is so true (but the specifics in macOS details is a bit
beyond my depth :/).

> I guess that would look like this in config.mak.uname:
>
> ifeq ($(uname_S),Darwin)
> ifeq ($(uname_M),arm64)
> 	HOMEBREW_PREFIX = /opt/homebrew
> else
> 	HOMEBREW_PREFIX = /usr/local
> endif
> 	USE_HOMEBREW_GETTEXT = IfAvailable
> 	USE_HOMEBREW_MSGFMT = IfAvailable
> 	USE_HOMEBREW_LIBICONV = IfAvailable
> endif
>
> ... and in Makefile:
>
> ifndef NO_HOMEBREW
> ifdef HOMEBREW_PREFIX
> ifdef USE_HOMEBREW_GETTEXT
> 	# magic!
> endif
> ifdef USE_HOMEBREW_MSGFMT
> 	# more magic!
> endif
> ifdef USE_HOMEBREW_LIBICONV
> ifeq ($(shell test -d $(HOMEBREW_PREFIX)/opt/libiconv && echo y),y)
> 	ICONVDIR ?= $(HOMEBREW_PREFIX)/opt/libiconv
> endif
> endif
> endif
>
> Perhaps the magic parts just need to check for the existence of
> $(HOMEBREW_PREFIX)/opt/gettext and use that, but the current code is
> more complicated for some reason.
>
> René