Skip to content

Commit b39aad0

Browse files
committed
Merge branch 'rs/macos-iconv-workaround'
Workaround the "iconv" shipped as part of macOS, which is broken handling stateful ISO/IEC 2022 encoded strings. * rs/macos-iconv-workaround: macOS: use iconv from Homebrew if needed and present macOS: make Homebrew use configurable
2 parents 8fb86e1 + cee341e commit b39aad0

2 files changed

Lines changed: 34 additions & 22 deletions

File tree

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ include shared.mak
101101
# specify your own (or DarwinPort's) include directories and
102102
# library directories by defining CFLAGS and LDFLAGS appropriately.
103103
#
104+
# Define NO_HOMEBREW if you don't want to use gettext, libiconv and
105+
# msgfmt installed by Homebrew.
106+
#
107+
# Define HOMEBREW_PREFIX if you have Homebrew installed in a non-default
108+
# location on macOS or on Linux and want to use it.
109+
#
110+
# Define USE_HOMEBREW_LIBICONV to link against libiconv installed by
111+
# Homebrew, if present.
112+
#
104113
# Define NO_APPLE_COMMON_CRYPTO if you are building on Darwin/Mac OS X
105114
# and do not want to use Apple's CommonCrypto library. This allows you
106115
# to provide your own OpenSSL library, for example from MacPorts.
@@ -1693,6 +1702,23 @@ ifeq ($(uname_S),Darwin)
16931702
PTHREAD_LIBS =
16941703
endif
16951704

1705+
ifndef NO_HOMEBREW
1706+
ifdef HOMEBREW_PREFIX
1707+
ifeq ($(shell test -d $(HOMEBREW_PREFIX)/opt/gettext && echo y),y)
1708+
BASIC_CFLAGS += -I$(HOMEBREW_PREFIX)/opt/gettext/include
1709+
BASIC_LDFLAGS += -L$(HOMEBREW_PREFIX)/opt/gettext/lib
1710+
endif
1711+
ifeq ($(shell test -x $(HOMEBREW_PREFIX)/opt/gettext/msgfmt && echo y),y)
1712+
MSGFMT = $(HOMEBREW_PREFIX)/opt/gettext/msgfmt
1713+
endif
1714+
ifdef USE_HOMEBREW_LIBICONV
1715+
ifeq ($(shell test -d $(HOMEBREW_PREFIX)/opt/libiconv && echo y),y)
1716+
ICONVDIR ?= $(HOMEBREW_PREFIX)/opt/libiconv
1717+
endif
1718+
endif
1719+
endif
1720+
endif
1721+
16961722
ifdef NO_LIBGEN_H
16971723
COMPAT_CFLAGS += -DNO_LIBGEN_H
16981724
COMPAT_OBJS += compat/basename.o

config.mak.uname

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ ifeq ($(uname_S),Darwin)
124124
# - MacOS 10.0.* and MacOS 10.1.0 = Darwin 1.*
125125
# - MacOS 10.x.* = Darwin (x+4).* for (1 <= x)
126126
# i.e. "begins with [15678] and a dot" means "10.4.* or older".
127+
DARWIN_MAJOR_VERSION = $(shell expr "$(uname_R)" : '\([0-9]*\)\.')
127128
ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
128129
OLD_ICONV = UnfortunatelyYes
129130
NO_APPLE_COMMON_CRYPTO = YesPlease
@@ -149,28 +150,13 @@ ifeq ($(uname_S),Darwin)
149150
CSPRNG_METHOD = arc4random
150151
USE_ENHANCED_BASIC_REGULAR_EXPRESSIONS = YesPlease
151152

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
153+
ifeq ($(uname_M),arm64)
154+
HOMEBREW_PREFIX = /opt/homebrew
155+
else
156+
HOMEBREW_PREFIX = /usr/local
157+
endif
158+
ifeq ($(shell test "$(DARWIN_MAJOR_VERSION)" -ge 24 && echo 1),1)
159+
USE_HOMEBREW_LIBICONV = UnfortunatelyYes
174160
endif
175161

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

0 commit comments

Comments
 (0)