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

From: Torsten Bögershausen <[email-masked]>
Date: Sun, 14 Dec 2025 07:45:44 +0100

On Sat, Dec 13, 2025 at 07:42:38PM +0100, René Scharfe wrote:
> Allow disabling the use of Homebrew on macOS, or Linux for that matter,
> like we already do for other package sources, MacPorts and Fink in
> particular.  This is useful for packagers, or anyone else who wants to
> control dependencies.

Good.
> 
> Suggested-by: Carlo Marcelo Arenas Belón <[email-masked]>
> Suggested-by: Torsten Bögershausen <[email-masked]>
> Signed-off-by: René Scharfe <[email-masked]>
> ---
>  Makefile         | 17 +++++++++++++++++
>  config.mak.uname | 11 +++++------
>  2 files changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 6fc322ff88..dbd2760d18 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -100,6 +100,9 @@ include shared.mak
>  # specify your own (or DarwinPort's) include directories and
>  # library directories by defining CFLAGS and LDFLAGS appropriately.
>  #
> +# Define NO_HOMEBREW if you have Homebrew and don't want Git to link
> +# against libraries installed by it.
> +#
Good
>  # Define NO_APPLE_COMMON_CRYPTO if you are building on Darwin/Mac OS X
>  # and do not want to use Apple's CommonCrypto library.  This allows you
>  # to provide your own OpenSSL library, for example from MacPorts.
> @@ -1692,6 +1695,20 @@ ifeq ($(uname_S),Darwin)
>  	PTHREAD_LIBS =
>  endif
>  
> +ifndef NO_HOMEBREW
> +        ifdef HOMEBREW_PREFIX

Question from a homebrew newbie, kind of:
Where do the HOMEBREW_PREFIX (and other HOMEBREW...) come from,
and what do they do ?

Running
git grep HOMEBREW
gives
ci/install-dependencies.sh:     export HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1

Whould it make sense to have a few words here as a comment ?

> +		BASIC_CFLAGS += -I$(HOMEBREW_PREFIX)/include
> +		BASIC_LDFLAGS += -L$(HOMEBREW_PREFIX)/lib
> +        endif
> +        ifdef HOMEBREW_GETTEXT_PREFIX
> +		BASIC_CFLAGS += -I$(HOMEBREW_GETTEXT_PREFIX)/include
> +		BASIC_LDFLAGS += -L$(HOMEBREW_GETTEXT_PREFIX)/lib
> +        endif
> +        ifdef HOMEBREW_MSGFMT
> +		MSGFMT = $(HOMEBREW_MSGFMT)
> +        endif
> +endif
> +
>  ifdef NO_LIBGEN_H
>  	COMPAT_CFLAGS += -DNO_LIBGEN_H
>  	COMPAT_OBJS += compat/basename.o
> diff --git a/config.mak.uname b/config.mak.uname
> index 1691c6ae6e..a6521575ee 100644
> --- a/config.mak.uname
> +++ b/config.mak.uname
> @@ -153,10 +153,10 @@ ifeq ($(uname_S),Darwin)
>  	# `brew link --force gettext`, should be obsolete as of
>  	# https://github.com/Homebrew/homebrew-core/pull/53489
>          ifeq ($(shell test -d /usr/local/opt/gettext/ && echo y),y)
> -		BASIC_CFLAGS += -I/usr/local/include -I/usr/local/opt/gettext/include
> -		BASIC_LDFLAGS += -L/usr/local/lib -L/usr/local/opt/gettext/lib
> +		HOMEBREW_PREFIX = /usr/local
> +		HOMEBREW_GETTEXT_PREFIX = /usr/local/opt/gettext
>                  ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
> -			MSGFMT = /usr/local/opt/gettext/bin/msgfmt
> +			HOMEBREW_MSGFMT = /usr/local/opt/gettext/bin/msgfmt
>                  endif
>  	# On newer ARM-based machines the default installation path has changed to
>  	# /opt/homebrew. Include it in our search paths so that the user does not
> @@ -166,10 +166,9 @@ ifeq ($(uname_S),Darwin)
>  	# add gettext. The issue was fixed more than three years ago by now, and at
>  	# that point there haven't been any ARM-based Macs yet.
>          else ifeq ($(shell test -d /opt/homebrew/ && echo y),y)
> -		BASIC_CFLAGS += -I/opt/homebrew/include
> -		BASIC_LDFLAGS += -L/opt/homebrew/lib
> +		HOMEBREW_PREFIX = /opt/homebrew
>                  ifeq ($(shell test -x /opt/homebrew/bin/msgfmt && echo y),y)
> -			MSGFMT = /opt/homebrew/bin/msgfmt
> +			HOMEBREW_MSGFMT = /opt/homebrew/bin/msgfmt
>                  endif
>          endif
>  
> -- 
> 2.52.0
>