+
Skip to content

meson: do a link test for locale_charset() #1203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 64 additions & 39 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -126,53 +126,43 @@ foreach h : headers
endif
endforeach

if cc.has_header_symbol('libcharset.h', 'locale_charset')
conf.set10('HAVE_LIBCHARSET', true)
endif

if conf.has('HAVE_SYS_SELECT_H')
conf.set10('HAVE_SELECT', true)
conf.set('SELECT_FD_SET_CAST', '')
endif

# Function checks.
functions = {
'div': {},
'getpwuid': {},
'gettimeofday': {},
'lstat': {},
'memcpy': {},
'memmove': {},
'mkfifo': {},
'nl_langinfo': {'have': 'HAVE_CODESET'},
'putenv': {},
'setpgid': {},
'setpgrp': {},
'setvbuf': {},
'sigaction': {},
'siginterrupt': {},
'siglongjmp': {},
'sigsetjmp': {},
'socket': {},
'strchr': {},
'strdup': {},
'strstr': {},
'strtol': {},
'sysconf': {},
'intl': {},
'uname': {},
'wait3': {},
'waitpid': {},
}
functions = [
'div',
'getpwuid',
'gettimeofday',
'lstat',
'memcpy',
'memmove',
'mkfifo',
'putenv',
'setpgid',
'setpgrp',
'setvbuf',
'sigaction',
'siginterrupt',
'siglongjmp',
'sigsetjmp',
'socket',
'strchr',
'strdup',
'strstr',
'strtol',
'sysconf',
'intl',
'uname',
'wait3',
'waitpid',
]

foreach f, v : functions
foreach f : functions
if cc.has_function(f, dependencies: syslibs)
val = ''
if 'have' in v
val = v['have']
else
val = 'HAVE_' + f.to_upper().underscorify()
endif
val = 'HAVE_' + f.to_upper().underscorify()
conf.set10(val, true)
endif
endforeach
Expand Down Expand Up @@ -269,10 +259,34 @@ if fribidi.found()
conf.set10('HAVE_BIDI', true)
endif

iconv_warning = false

iconv = dependency('iconv', required: get_option('iconv'))
if iconv.found()
conf.set10('HAVE_ICONV', true)
all_found_deps += iconv

# Check if we have nl_langinfo function (typically glibc)
if cc.has_function('nl_langinfo')
conf.set10('HAVE_CODESET', true)
endif

libcharset_code = '''
#include <libcharset.h>

int main(void) {
const char *charset = locale_charset();
return 0;
}
'''

if cc.links(libcharset_code, dependencies: iconv, name: 'libcharset check')
conf.set10('HAVE_LIBCHARSET', true)
elif cc.has_header_symbol('libcharset.h', 'locale_charset')
# If header is present but linking fails, it might be a conflict
# we'll warn after the summary so that this isn't lost in configure noise
iconv_warning = true
endif
endif

libintl = dependency('intl', required: get_option('nls'))
Expand Down Expand Up @@ -593,3 +607,14 @@ summary(
bool_yn: true,
section: 'Dependencies',
)

if iconv_warning
warning(
'''Found libcharset.h header, but couldn't link against locale_charset() function.
This typically happens when GNU libiconv conflicts with the iconv built into libc.
GNU libc systems shouldn't have GNU libiconv installed as they already provide iconv.
This is a bug in your distribution's packaging.
Please report this to your distribution's developers.
'''
)
endif
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载