[PATCH v2 1/2] Makefile: add NO_HOMEBREW
- From
René Scharfe <l.s.r@web.de>
- Date
- Dec 13, 2025, 18:42 UTC
- Message-ID
- <fe00aa37-e929-4ca6-ac23-84a693a48bc6@web.de>
- In-Reply-To
- <53690064-1c98-40e9-8b9a-7ba6bee63703@web.de>
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.
Suggested-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Suggested-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: René Scharfe <l.s.r@web.de> --- 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. +# # 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 + 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