meson: rewrite curses/iconv test
Redo the curses test to do the same tests that the configure check used to do. OpenBSD triggers the warning because it does not support NCURSES_WIDECHAR and thus the cc.links test fails. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
da0dfe251d
commit
925a40df28
127
meson.build
127
meson.build
|
@ -465,70 +465,89 @@ endif
|
||||||
iconv = not_found
|
iconv = not_found
|
||||||
curses = not_found
|
curses = not_found
|
||||||
if have_system and not get_option('curses').disabled()
|
if have_system and not get_option('curses').disabled()
|
||||||
if not get_option('iconv').disabled()
|
curses_test = '''
|
||||||
libiconv = cc.find_library('iconv',
|
#include <locale.h>
|
||||||
required: false,
|
#include <curses.h>
|
||||||
static: enable_static)
|
#include <wchar.h>
|
||||||
if cc.links('''
|
int main(void) {
|
||||||
#include <iconv.h>
|
wchar_t wch = L'w';
|
||||||
int main(void) {
|
setlocale(LC_ALL, "");
|
||||||
iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
|
resize_term(0, 0);
|
||||||
return conv != (iconv_t) -1;
|
addwstr(L"wide chars\n");
|
||||||
}''', dependencies: [libiconv])
|
addnwstr(&wch, 1);
|
||||||
iconv = declare_dependency(dependencies: [libiconv])
|
add_wch(WACS_DEGREE);
|
||||||
|
return 0;
|
||||||
|
}'''
|
||||||
|
|
||||||
|
curses = dependency((targetos == 'windows' ? 'ncurses' : 'ncursesw'),
|
||||||
|
required: false,
|
||||||
|
method: 'pkg-config',
|
||||||
|
static: enable_static)
|
||||||
|
msg = get_option('curses').enabled() ? 'curses library not found' : ''
|
||||||
|
if curses.found()
|
||||||
|
if cc.links(curses_test, dependencies: [curses])
|
||||||
|
curses = declare_dependency(compile_args: '-DNCURSES_WIDECHAR', dependencies: [curses])
|
||||||
|
else
|
||||||
|
msg = 'curses package not usable'
|
||||||
|
curses = not_found
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if get_option('iconv').enabled() and not iconv.found()
|
if not curses.found()
|
||||||
error('Cannot detect iconv API')
|
curses_compile_args = ['-DNCURSES_WIDECHAR']
|
||||||
endif
|
has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
|
||||||
if iconv.found()
|
if targetos != 'windows' and not has_curses_h
|
||||||
curses_libname_list = ['ncursesw', 'ncurses', 'cursesw', 'pdcurses']
|
message('Trying with /usr/include/ncursesw')
|
||||||
curses_test = '''
|
curses_compile_args += ['-I/usr/include/ncursesw']
|
||||||
#include <locale.h>
|
has_curses_h = cc.has_header('curses.h', args: curses_compile_args)
|
||||||
#include <curses.h>
|
endif
|
||||||
#include <wchar.h>
|
if has_curses_h
|
||||||
int main(void) {
|
curses_libname_list = (targetos == 'windows' ? ['pdcurses'] : ['ncursesw', 'cursesw'])
|
||||||
wchar_t wch = L'w';
|
foreach curses_libname : curses_libname_list
|
||||||
setlocale(LC_ALL, "");
|
|
||||||
resize_term(0, 0);
|
|
||||||
addwstr(L"wide chars\n");
|
|
||||||
addnwstr(&wch, 1);
|
|
||||||
add_wch(WACS_DEGREE);
|
|
||||||
return 0;
|
|
||||||
}'''
|
|
||||||
foreach curses_libname : curses_libname_list
|
|
||||||
libcurses = dependency(curses_libname,
|
|
||||||
required: false,
|
|
||||||
method: 'pkg-config',
|
|
||||||
static: enable_static)
|
|
||||||
|
|
||||||
if not libcurses.found()
|
|
||||||
dirs = ['/usr/include/ncursesw']
|
|
||||||
if targetos == 'windows'
|
|
||||||
dirs = []
|
|
||||||
endif
|
|
||||||
libcurses = cc.find_library(curses_libname,
|
libcurses = cc.find_library(curses_libname,
|
||||||
required: false,
|
required: false,
|
||||||
dirs: dirs,
|
|
||||||
static: enable_static)
|
static: enable_static)
|
||||||
endif
|
if libcurses.found()
|
||||||
if libcurses.found()
|
if cc.links(curses_test, args: curses_compile_args, dependencies: libcurses)
|
||||||
if cc.links(curses_test, dependencies: [libcurses])
|
curses = declare_dependency(compile_args: curses_compile_args,
|
||||||
curses = declare_dependency(compile_args: '-DNCURSES_WIDECHAR', dependencies: [libcurses])
|
dependencies: [libcurses])
|
||||||
break
|
break
|
||||||
|
else
|
||||||
|
msg = 'curses library not usable'
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
endforeach
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if not get_option('iconv').disabled()
|
||||||
|
foreach link_args : [ ['-liconv'], [] ]
|
||||||
|
# Programs will be linked with glib and this will bring in libiconv on FreeBSD.
|
||||||
|
# We need to use libiconv if available because mixing libiconv's headers with
|
||||||
|
# the system libc does not work.
|
||||||
|
# However, without adding glib to the dependencies -L/usr/local/lib will not be
|
||||||
|
# included in the command line and libiconv will not be found.
|
||||||
|
if cc.links('''
|
||||||
|
#include <iconv.h>
|
||||||
|
int main(void) {
|
||||||
|
iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
|
||||||
|
return conv != (iconv_t) -1;
|
||||||
|
}''', args: config_host['GLIB_CFLAGS'].split() + config_host['GLIB_LIBS'].split() + link_args)
|
||||||
|
iconv = declare_dependency(link_args: link_args, dependencies: glib)
|
||||||
|
break
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
endif
|
endif
|
||||||
if not curses.found()
|
if curses.found() and not iconv.found()
|
||||||
if iconv.found()
|
if get_option('iconv').enabled()
|
||||||
if get_option('curses').enabled()
|
error('iconv not available')
|
||||||
error('Cannot find curses')
|
endif
|
||||||
endif
|
msg = 'iconv required for curses UI but not available'
|
||||||
elif get_option('curses').enabled()
|
curses = not_found
|
||||||
error('iconv required for curses UI but not available')
|
endif
|
||||||
|
if not curses.found() and msg != ''
|
||||||
|
if get_option('curses').enabled()
|
||||||
|
error(msg)
|
||||||
else
|
else
|
||||||
warning('iconv required for curses UI but not available, disabling')
|
warning(msg + ', disabling')
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
Loading…
Reference in New Issue