Skip to content

Commit d281241

Browse files
tboegigitster
authored andcommitted
utf8.c: enable workaround for iconv under macOS 14/15
The previous commit introduced a workaround in utf8.c to deal with broken iconv implementations. It is enabled when a MacOS version is used that has a buggy iconv library and there is no external library provided (and linked against) from neither MacPorts nor Homebrew nor Fink. For Homebrew, MacPorts and Fink we check if libiconv exist. Introduce 2 new macros: HAS_GOOD_LIBICONV and NEEDS_GOOD_LIBICONV. For Homebrew HAS_GOOD_LIBICONV is set when the libiconv directory exist. MacPorts can be installed with or without libiconv, so check if libiconv.dylib exists (which is a softlink) Fink compiles and installs libiconv by default. Note that a fresh installation of Fink now defaults to /opt/sw. Older versions used /sw as default, so leave the check and setting of BASIC_CFLAGS and BASIC_LDFLAGS as is. For the new default check for the existance of /opt/sw as well. Add a check for /opt/sw/lib/libiconv.dylib which sets HAS_GOOD_LIBICONV Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0cec08 commit d281241

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,11 +1687,21 @@ ifeq ($(uname_S),Darwin)
16871687
BASIC_CFLAGS += -I/sw/include
16881688
BASIC_LDFLAGS += -L/sw/lib
16891689
endif
1690+
ifeq ($(shell test -d /opt/sw/lib && echo y),y)
1691+
BASIC_CFLAGS += -I/opt/sw/include
1692+
BASIC_LDFLAGS += -L/opt/sw/lib
1693+
ifeq ($(shell test -e /opt/sw/lib/libiconv.dylib && echo y),y)
1694+
HAS_GOOD_LIBICONV = Yes
1695+
endif
1696+
endif
16901697
endif
16911698
ifndef NO_DARWIN_PORTS
16921699
ifeq ($(shell test -d /opt/local/lib && echo y),y)
16931700
BASIC_CFLAGS += -I/opt/local/include
16941701
BASIC_LDFLAGS += -L/opt/local/lib
1702+
ifeq ($(shell test -e /opt/local/lib/libiconv.dylib && echo y),y)
1703+
HAS_GOOD_LIBICONV = Yes
1704+
endif
16951705
endif
16961706
endif
16971707
ifndef NO_APPLE_COMMON_CRYPTO
@@ -1714,6 +1724,7 @@ endif
17141724
ifdef USE_HOMEBREW_LIBICONV
17151725
ifeq ($(shell test -d $(HOMEBREW_PREFIX)/opt/libiconv && echo y),y)
17161726
ICONVDIR ?= $(HOMEBREW_PREFIX)/opt/libiconv
1727+
HAS_GOOD_LIBICONV = Yes
17171728
endif
17181729
endif
17191730
endif
@@ -1859,6 +1870,11 @@ ifndef NO_ICONV
18591870
endif
18601871
EXTLIBS += $(ICONV_LINK) -liconv
18611872
endif
1873+
ifdef NEEDS_GOOD_LIBICONV
1874+
ifndef HAS_GOOD_LIBICONV
1875+
BASIC_CFLAGS += -DICONV_RESTART_RESET
1876+
endif
1877+
endif
18621878
endif
18631879
ifdef ICONV_OMITS_BOM
18641880
BASIC_CFLAGS += -DICONV_OMITS_BOM

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ ifeq ($(uname_S),Darwin)
157157
endif
158158
ifeq ($(shell test "$(DARWIN_MAJOR_VERSION)" -ge 24 && echo 1),1)
159159
USE_HOMEBREW_LIBICONV = UnfortunatelyYes
160+
NEEDS_GOOD_LIBICONV = UnfortunatelyYes
160161
endif
161162

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

0 commit comments

Comments
 (0)