Debian Codegraph @

m4/intlmacosx.m4

raw
1 # intlmacosx.m4
2 # serial 10 (gettext-0.23)
3 dnl Copyright (C) 2004-2014, 2016, 2019-2025 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8 dnl
9 dnl This file can be used in projects which are not available under
10 dnl the GNU General Public License or the GNU Lesser General Public
11 dnl License but which still want to provide support for the GNU gettext
12 dnl functionality.
13 dnl Please note that the actual code of the GNU gettext library is covered
14 dnl by the GNU Lesser General Public License, and the rest of the GNU
15 dnl gettext package is covered by the GNU General Public License.
16 dnl They are *not* in the public domain.
17
18 dnl Checks for special options needed on Mac OS X.
19 dnl Defines INTL_MACOSX_LIBS.
20 AC_DEFUN([gt_INTL_MACOSX],
21 [
22 dnl Check for API introduced in Mac OS X 10.4.
23 AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
24 [gt_cv_func_CFPreferencesCopyAppValue],
25 [gt_saved_LIBS="$LIBS"
26 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
27 AC_LINK_IFELSE(
28 [AC_LANG_PROGRAM(
29 [[#include <CoreFoundation/CFPreferences.h>]],
30 [[CFPreferencesCopyAppValue(NULL, NULL)]])],
31 [gt_cv_func_CFPreferencesCopyAppValue=yes],
32 [gt_cv_func_CFPreferencesCopyAppValue=no])
33 LIBS="$gt_saved_LIBS"])
34 if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
35 AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
36 [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
37 fi
38 dnl Don't check for the API introduced in Mac OS X 10.5, CFLocaleCopyCurrent,
39 dnl because in macOS 10.13.4 it has the following behaviour:
40 dnl When two or more languages are specified in the
41 dnl "System Preferences > Language & Region > Preferred Languages" panel,
42 dnl it returns en_CC where CC is the territory (even when English is not among
43 dnl the preferred languages!). What we want instead is what
44 dnl CFLocaleCopyCurrent returned in earlier macOS releases and what
45 dnl CFPreferencesCopyAppValue still returns, namely ll_CC where ll is the
46 dnl first among the preferred languages and CC is the territory.
47 AC_CACHE_CHECK([for CFLocaleCopyPreferredLanguages], [gt_cv_func_CFLocaleCopyPreferredLanguages],
48 [gt_saved_LIBS="$LIBS"
49 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
50 AC_LINK_IFELSE(
51 [AC_LANG_PROGRAM(
52 [[#include <CoreFoundation/CFLocale.h>]],
53 [[CFLocaleCopyPreferredLanguages();]])],
54 [gt_cv_func_CFLocaleCopyPreferredLanguages=yes],
55 [gt_cv_func_CFLocaleCopyPreferredLanguages=no])
56 LIBS="$gt_saved_LIBS"])
57 if test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then
58 AC_DEFINE([HAVE_CFLOCALECOPYPREFERREDLANGUAGES], [1],
59 [Define to 1 if you have the Mac OS X function CFLocaleCopyPreferredLanguages in the CoreFoundation framework.])
60 fi
61 INTL_MACOSX_LIBS=
62 if test $gt_cv_func_CFPreferencesCopyAppValue = yes \
63 || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then
64 dnl Starting with macOS version 14, CoreFoundation relies on CoreServices,
65 dnl and we have to link it in explicitly, otherwise an exception
66 dnl NSInvalidArgumentException "unrecognized selector sent to instance"
67 dnl occurs.
68 INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreServices"
69 fi
70 AC_SUBST([INTL_MACOSX_LIBS])
71 ])