Skip to content

Commit 363837a

Browse files
rscharfegitster
authored andcommitted
macOS: make Homebrew use configurable
On macOS we opportunistically use Homebrew-installed versions of gettext(3) and msgfmt(1). Make that behavior configurable by providing make variables to disable Homebrew usage (NO_HOMEBREW) and to allow using a non-default installation location (HOMEBREW_PREFIX). Include and link only the gettext keg via the symlink opt/gettext pointing to its installed version instead of using the Homebrew prefix. This is simpler and prevents accidentally including other libraries. 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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9a2fb14 commit 363837a

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ include shared.mak
100100
# specify your own (or DarwinPort's) include directories and
101101
# library directories by defining CFLAGS and LDFLAGS appropriately.
102102
#
103+
# Define NO_HOMEBREW if you don't want to use gettext and msgfmt
104+
# installed by Homebrew.
105+
#
106+
# Define HOMEBREW_PREFIX if you have Homebrew installed in a non-default
107+
# location on macOS or on Linux and want to use it.
108+
#
103109
# Define NO_APPLE_COMMON_CRYPTO if you are building on Darwin/Mac OS X
104110
# and do not want to use Apple's CommonCrypto library. This allows you
105111
# to provide your own OpenSSL library, for example from MacPorts.
@@ -1690,6 +1696,18 @@ ifeq ($(uname_S),Darwin)
16901696
PTHREAD_LIBS =
16911697
endif
16921698

1699+
ifndef NO_HOMEBREW
1700+
ifdef HOMEBREW_PREFIX
1701+
ifeq ($(shell test -d $(HOMEBREW_PREFIX)/opt/gettext && echo y),y)
1702+
BASIC_CFLAGS += -I$(HOMEBREW_PREFIX)/opt/gettext/include
1703+
BASIC_LDFLAGS += -L$(HOMEBREW_PREFIX)/opt/gettext/lib
1704+
endif
1705+
ifeq ($(shell test -x $(HOMEBREW_PREFIX)/opt/gettext/msgfmt && echo y),y)
1706+
MSGFMT = $(HOMEBREW_PREFIX)/opt/gettext/msgfmt
1707+
endif
1708+
endif
1709+
endif
1710+
16931711
ifdef NO_LIBGEN_H
16941712
COMPAT_CFLAGS += -DNO_LIBGEN_H
16951713
COMPAT_OBJS += compat/basename.o

config.mak.uname

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -149,28 +149,10 @@ ifeq ($(uname_S),Darwin)
149149
CSPRNG_METHOD = arc4random
150150
USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS = YesPlease
151151

152-
# Workaround for `gettext` being keg-only and not even being linked via
153-
# `brew link --force gettext`, should be obsolete as of
154-
# https://github.com/Homebrew/homebrew-core/pull/53489
155-
ifeq ($(shell test -d /usr/local/opt/gettext/ && echo y),y)
156-
BASIC_CFLAGS += -I/usr/local/include -I/usr/local/opt/gettext/include
157-
BASIC_LDFLAGS += -L/usr/local/lib -L/usr/local/opt/gettext/lib
158-
ifeq ($(shell test -x /usr/local/opt/gettext/bin/msgfmt && echo y),y)
159-
MSGFMT = /usr/local/opt/gettext/bin/msgfmt
160-
endif
161-
# On newer ARM-based machines the default installation path has changed to
162-
# /opt/homebrew. Include it in our search paths so that the user does not
163-
# have to configure this manually.
164-
#
165-
# Note that we do not employ the same workaround as above where we manually
166-
# add gettext. The issue was fixed more than three years ago by now, and at
167-
# that point there haven't been any ARM-based Macs yet.
168-
else ifeq ($(shell test -d /opt/homebrew/ && echo y),y)
169-
BASIC_CFLAGS += -I/opt/homebrew/include
170-
BASIC_LDFLAGS += -L/opt/homebrew/lib
171-
ifeq ($(shell test -x /opt/homebrew/bin/msgfmt && echo y),y)
172-
MSGFMT = /opt/homebrew/bin/msgfmt
173-
endif
152+
ifeq ($(uname_M),arm64)
153+
HOMEBREW_PREFIX = /opt/homebrew
154+
else
155+
HOMEBREW_PREFIX = /usr/local
174156
endif
175157

176158
# The builtin FSMonitor on MacOS builds upon Simple-IPC. Both require

0 commit comments

Comments
 (0)