libgd: avoid recursive and redundant dependencies
[feed/packages.git] / libs / glib2 / patches / 010-libintl.patch
1 From 750687bf2824fcaf8976fb8b558d583f29acdfeb Mon Sep 17 00:00:00 2001
2 From: Eli Schwartz <eschwartz@archlinux.org>
3 Date: Tue, 7 Jun 2022 16:14:04 -0400
4 Subject: [PATCH 1/2] meson: simplify iconv lookups using Meson's builtin
5 dependency lookup
6
7 iconv is complicated to look up. That complexity now resides in
8 Meson, since 0.60.0, via a `dependency('iconv')` lookup, so use that
9 instead.
10
11 No effort is made to support the old option for which type of iconv to
12 use. It was a false choice, because if only one was available, then
13 that's the only one you can use, and if both are available, the external
14 iconv shadows the builtin one and renders the builtin one unusable,
15 so there is still only one you can use.
16
17 This meant that when configuring glib with -Diconv=libc on systems that
18 had an external iconv, the configure check would detect a valid libc
19 iconv, try to use it, and then fail during the build because iconv.h
20 belongs to the external iconv and generates machine code using the
21 external iconv ABI, but fails to link to the iconv `find_library()`.
22 Meson handles this transparently.
23 ---
24 meson.build | 20 +-------------------
25 meson_options.txt | 8 +-------
26 2 files changed, 2 insertions(+), 26 deletions(-)
27
28 --- a/meson.build
29 +++ b/meson.build
30 @@ -1958,28 +1958,10 @@ glibconfig_conf.set10('G_HAVE_GROWING_ST
31 # We should never use the MinGW C library's iconv because it may not be
32 # available in the actual runtime environment. On Windows, we always use
33 # the built-in implementation
34 -iconv_opt = get_option('iconv')
35 if host_system == 'windows'
36 libiconv = []
37 - # We have a #include "win_iconv.c" in gconvert.c on Windows, so we don't need
38 - # any external library for it
39 - if iconv_opt != 'auto'
40 - warning('-Diconv was set to @0@, which was ignored')
41 - endif
42 else
43 - found_iconv = false
44 - if ['auto', 'libc'].contains(iconv_opt) and cc.has_function('iconv_open')
45 - libiconv = []
46 - found_iconv = true
47 - endif
48 - if not found_iconv and ['auto', 'external'].contains(iconv_opt) and cc.has_header_symbol('iconv.h', 'iconv_open')
49 - libiconv = [cc.find_library('iconv')]
50 - found_iconv = true
51 - endif
52 -
53 - if not found_iconv
54 - error('iconv implementation "@0@" not found'.format(iconv_opt))
55 - endif
56 + libiconv = dependency('iconv')
57 endif
58
59 pcre = dependency('libpcre', version: '>= 8.31', required : false) # Should check for Unicode support, too. FIXME
60 @@ -2046,42 +2028,37 @@ endif
61 # FIXME: glib-gettext.m4 has much more checks to detect broken/uncompatible
62 # implementations. This could be extended if issues are found in some platforms.
63 libintl_deps = []
64 -if cc.has_function('ngettext', args : osx_ldflags)
65 - have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset')
66 -else
67 - # First just find the bare library.
68 - libintl = cc.find_library('intl', required : false)
69 - # The bare library probably won't link without help if it's static.
70 - if libintl.found() and not cc.has_function('ngettext', args : osx_ldflags, dependencies : libintl)
71 - libintl_iconv = cc.find_library('iconv', required : false)
72 - # libintl supports different threading APIs, which may not
73 - # require additional flags, but it defaults to using pthreads if
74 - # found. Meson's "threads" dependency does not allow you to
75 - # prefer pthreads. We may not be using pthreads for glib itself
76 - # either so just link the library to satisfy libintl rather than
77 - # also defining the macros with the -pthread flag.
78 - libintl_pthread = cc.find_library('pthread', required : false)
79 - # Try linking with just libiconv.
80 - if libintl_iconv.found() and cc.has_function('ngettext', args : osx_ldflags, dependencies : [libintl, libintl_iconv])
81 - libintl_deps += [libintl_iconv]
82 - # Then also try linking with pthreads.
83 - elif libintl_iconv.found() and libintl_pthread.found() and cc.has_function('ngettext', args : osx_ldflags, dependencies : [libintl, libintl_iconv, libintl_pthread])
84 - libintl_deps += [libintl_iconv, libintl_pthread]
85 - else
86 - libintl = disabler()
87 - endif
88 - endif
89 - if not libintl.found()
90 - libintl = subproject('proxy-libintl').get_variable('intl_dep')
91 - libintl_deps = [libintl] + libintl_deps
92 - have_bind_textdomain_codeset = true # proxy-libintl supports it
93 +libintl = dependency('intl', required: false)
94 +if libintl.found()
95 + # libintl supports different threading APIs, which may not
96 + # require additional flags, but it defaults to using pthreads if
97 + # found. Meson's "threads" dependency does not allow you to
98 + # prefer pthreads. We may not be using pthreads for glib itself
99 + # either so just link the library to satisfy libintl rather than
100 + # also defining the macros with the -pthread flag.
101 + #
102 + # Meson's builtin dependency lookup as of 0.60.0 doesn't check for
103 + # pthread, so we do this manually here.
104 + if cc.has_function('ngettext', dependencies : libintl)
105 + libintl_deps += [libintl]
106 else
107 - libintl_deps = [libintl] + libintl_deps
108 - have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset', args : osx_ldflags,
109 - dependencies : libintl_deps)
110 + libintl_pthread = cc.find_library('pthread', required : false)
111 + if libintl_pthread.found() and cc.has_function('ngettext', dependencies : [libintl, libintl_pthread])
112 + libintl_deps += [libintl, libintl_pthread]
113 + else
114 + libintl = disabler()
115 + endif
116 endif
117 endif
118
119 +if libintl.found()
120 + have_bind_textdomain_codeset = cc.has_function('bind_textdomain_codeset', dependencies: libintl_deps)
121 +else
122 + libintl = subproject('proxy-libintl').get_variable('intl_dep')
123 + libintl_deps = [libintl]
124 + have_bind_textdomain_codeset = true # proxy-libintl supports it
125 +endif
126 +
127 glib_conf.set('HAVE_BIND_TEXTDOMAIN_CODESET', have_bind_textdomain_codeset)
128
129 # We require gettext to always be present
130 --- a/meson_options.txt
131 +++ b/meson_options.txt
132 @@ -3,12 +3,6 @@ option('runtime_libdir',
133 value : '',
134 description : 'install runtime libraries relative to libdir')
135
136 -option('iconv',
137 - type : 'combo',
138 - choices : ['auto', 'libc', 'external'],
139 - value : 'auto',
140 - description : 'iconv implementation to use (\'libc\' = \'Part of the C library\'; \'external\' = \'External libiconv\'; \'auto\' = \'Auto-detect which iconv is available\')')
141 -
142 option('charsetalias_dir',
143 type : 'string',
144 value : '',