Makefile: detect new Homebrew location for ARM-based Macs

With the introduction of the ARM-based Macs the default location for Homebrew has changed from "/usr/local" to "/opt/homebrew". We only handle the former location though, which means that unless the user has manually configured required search paths we won't be able to locate it. Improve upon this by adding relevant paths to our CFLAGS and LDFLAGS as well as detecting the location of msgfmt(1). Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jan 18, 2024 at 11:22 UTC d52b426ad4b038e09421c2e3a3c991832e1eec97
1 file changed +13
config.mak.uname
+13
@@ -158,6 +158,19 @@ ifeq ($(uname_S),Darwin)
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
174 endif
175
176 # The builtin FSMonitor on MacOS builds upon Simple-IPC. Both require