From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Stefan Weil <sw@weilnetz.de>,
Yonggang Luo <luoyonggang@gmail.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [PULL 5/9] configure: Fixes ncursesw detection under msys2/mingw by convert them to meson
Date: Wed, 14 Oct 2020 10:21:45 +0200 [thread overview]
Message-ID: <20201014082149.26853-6-kraxel@redhat.com> (raw)
In-Reply-To: <20201014082149.26853-1-kraxel@redhat.com>
From: Yonggang Luo <luoyonggang@gmail.com>
The mingw pkg-config are showing following absolute path and contains : as the separator,
-D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw:
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -pipe -lncursesw -lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lncursesw
-DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC -lcursesw
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lncursesw
-DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -lcursesw
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx -ltre -lintl -liconv
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw
-DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Message-id: 20201012234348.1427-6-luoyonggang@gmail.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
configure | 118 +++-------------------------------------------
meson_options.txt | 4 ++
meson.build | 83 +++++++++++++++++++++++++++-----
ui/meson.build | 2 +-
4 files changed, 83 insertions(+), 124 deletions(-)
diff --git a/configure b/configure
index 9a87685517ee..f839c2a557c3 100755
--- a/configure
+++ b/configure
@@ -295,7 +295,8 @@ unset target_list_exclude
brlapi=""
curl=""
-curses=""
+iconv="auto"
+curses="auto"
docs=""
fdt="auto"
netmap="no"
@@ -1173,13 +1174,13 @@ for opt do
;;
--disable-safe-stack) safe_stack="no"
;;
- --disable-curses) curses="no"
+ --disable-curses) curses="disabled"
;;
- --enable-curses) curses="yes"
+ --enable-curses) curses="enabled"
;;
- --disable-iconv) iconv="no"
+ --disable-iconv) iconv="disabled"
;;
- --enable-iconv) iconv="yes"
+ --enable-iconv) iconv="enabled"
;;
--disable-curl) curl="no"
;;
@@ -3440,102 +3441,6 @@ EOF
fi
fi
-##########################################
-# iconv probe
-if test "$iconv" != "no" ; then
- cat > $TMPC << EOF
-#include <iconv.h>
-int main(void) {
- iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
- return conv != (iconv_t) -1;
-}
-EOF
- iconv_prefix_list="/usr/local:/usr"
- iconv_lib_list=":-liconv"
- IFS=:
- for iconv_prefix in $iconv_prefix_list; do
- IFS=:
- iconv_cflags="-I$iconv_prefix/include"
- iconv_ldflags="-L$iconv_prefix/lib"
- for iconv_link in $iconv_lib_list; do
- unset IFS
- iconv_lib="$iconv_ldflags $iconv_link"
- echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
- if compile_prog "$iconv_cflags" "$iconv_lib" ; then
- iconv_found=yes
- break
- fi
- done
- if test "$iconv_found" = yes ; then
- break
- fi
- done
- if test "$iconv_found" = "yes" ; then
- iconv=yes
- else
- if test "$iconv" = "yes" ; then
- feature_not_found "iconv" "Install iconv devel"
- fi
- iconv=no
- fi
-fi
-
-##########################################
-# curses probe
-if test "$iconv" = "no" ; then
- # curses will need iconv
- curses=no
-fi
-if test "$curses" != "no" ; then
- if test "$mingw32" = "yes" ; then
- curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
- curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
- else
- curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
- curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
- fi
- curses_found=no
- cat > $TMPC << EOF
-#include <locale.h>
-#include <curses.h>
-#include <wchar.h>
-int main(void) {
- wchar_t wch = L'w';
- setlocale(LC_ALL, "");
- resize_term(0, 0);
- addwstr(L"wide chars\n");
- addnwstr(&wch, 1);
- add_wch(WACS_DEGREE);
- return 0;
-}
-EOF
- IFS=:
- for curses_inc in $curses_inc_list; do
- # Make sure we get the wide character prototypes
- curses_inc="-DNCURSES_WIDECHAR $curses_inc"
- IFS=:
- for curses_lib in $curses_lib_list; do
- unset IFS
- if compile_prog "$curses_inc" "$curses_lib" ; then
- curses_found=yes
- break
- fi
- done
- if test "$curses_found" = yes ; then
- break
- fi
- done
- unset IFS
- if test "$curses_found" = "yes" ; then
- curses=yes
- else
- if test "$curses" = "yes" ; then
- feature_not_found "curses" "Install ncurses devel"
- fi
- curses=no
- fi
-fi
-
##########################################
# curl probe
if test "$curl" != "no" ; then
@@ -6200,16 +6105,6 @@ if test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
echo "X11_LIBS=$x11_libs" >> $config_host_mak
fi
-if test "$iconv" = "yes" ; then
- echo "CONFIG_ICONV=y" >> $config_host_mak
- echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
- echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
-fi
-if test "$curses" = "yes" ; then
- echo "CONFIG_CURSES=y" >> $config_host_mak
- echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
- echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
-fi
if test "$pipe2" = "yes" ; then
echo "CONFIG_PIPE2=y" >> $config_host_mak
fi
@@ -7181,6 +7076,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \
-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
-Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
+ -Diconv=$iconv -Dcurses=$curses \
$cross_arg \
"$PWD" "$source_path"
diff --git a/meson_options.txt b/meson_options.txt
index 1d3c94840a90..e6cb1e589b4e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -32,6 +32,10 @@ option('cocoa', type : 'feature', value : 'auto',
description: 'Cocoa user interface (macOS only)')
option('mpath', type : 'feature', value : 'auto',
description: 'Multipath persistent reservation passthrough')
+option('iconv', type : 'feature', value : 'auto',
+ description: 'Font glyph conversion support')
+option('curses', type : 'feature', value : 'auto',
+ description: 'curses UI')
option('sdl', type : 'feature', value : 'auto',
description: 'SDL user interface')
option('sdl_image', type : 'feature', value : 'auto',
diff --git a/meson.build b/meson.build
index ad6c7c90c787..1a4a48249243 100644
--- a/meson.build
+++ b/meson.build
@@ -426,6 +426,74 @@ if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
endif
endif
+iconv = not_found
+if not get_option('iconv').disabled()
+ libiconv = cc.find_library('iconv',
+ required: false,
+ static: enable_static)
+ if libiconv.found()
+ if cc.links('''
+ #include <iconv.h>
+ int main(void) {
+ iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
+ return conv != (iconv_t) -1;
+ }''', dependencies: [libiconv])
+ iconv = declare_dependency(dependencies: [libiconv])
+ endif
+ endif
+endif
+if get_option('iconv').enabled() and not iconv.found()
+ error('Cannot detect iconv API')
+endif
+
+curses = not_found
+if iconv.found() and not get_option('curses').disabled()
+ curses_libname_list = ['ncursesw', 'ncurses', 'cursesw', 'pdcurses']
+ curses_test = '''
+ #include <locale.h>
+ #include <curses.h>
+ #include <wchar.h>
+ int main(void) {
+ wchar_t wch = L'w';
+ 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,
+ required: false,
+ dirs: dirs,
+ static: enable_static)
+ endif
+ if libcurses.found()
+ if cc.links(curses_test, dependencies: [libcurses])
+ curses = declare_dependency(compile_args: '-DNCURSES_WIDECHAR', dependencies: [libcurses])
+ break
+ endif
+ endif
+ endforeach
+endif
+if get_option('curses').enabled() and not curses.found()
+ if not iconv.found()
+ error('Cannot detect iconv API')
+ else
+ error('Cannot detect curses API')
+ endif
+endif
+
brlapi = not_found
if 'CONFIG_BRLAPI' in config_host
brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
@@ -504,16 +572,6 @@ if 'CONFIG_X11' in config_host
x11 = declare_dependency(compile_args: config_host['X11_CFLAGS'].split(),
link_args: config_host['X11_LIBS'].split())
endif
-curses = not_found
-if 'CONFIG_CURSES' in config_host
- curses = declare_dependency(compile_args: config_host['CURSES_CFLAGS'].split(),
- link_args: config_host['CURSES_LIBS'].split())
-endif
-iconv = not_found
-if 'CONFIG_ICONV' in config_host
- iconv = declare_dependency(compile_args: config_host['ICONV_CFLAGS'].split(),
- link_args: config_host['ICONV_LIBS'].split())
-endif
vnc = not_found
png = not_found
jpeg = not_found
@@ -622,6 +680,7 @@ config_host_data.set('CONFIG_COCOA', cocoa.found())
config_host_data.set('CONFIG_LIBUDEV', libudev.found())
config_host_data.set('CONFIG_MPATH', mpathpersist.found())
config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
+config_host_data.set('CONFIG_CURSES', curses.found())
config_host_data.set('CONFIG_SDL', sdl.found())
config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
config_host_data.set('CONFIG_VNC', vnc.found())
@@ -1905,8 +1964,8 @@ if config_host.has_key('CONFIG_NETTLE')
endif
summary_info += {'libtasn1': config_host.has_key('CONFIG_TASN1')}
summary_info += {'PAM': config_host.has_key('CONFIG_AUTH_PAM')}
-summary_info += {'iconv support': config_host.has_key('CONFIG_ICONV')}
-summary_info += {'curses support': config_host.has_key('CONFIG_CURSES')}
+summary_info += {'iconv support': iconv.found()}
+summary_info += {'curses support': curses.found()}
# TODO: add back version
summary_info += {'virgl support': config_host.has_key('CONFIG_VIRGL')}
summary_info += {'curl support': config_host.has_key('CONFIG_CURL')}
diff --git a/ui/meson.build b/ui/meson.build
index 8a080c38e325..78ad792ffb8d 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -39,7 +39,7 @@ specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)
ui_modules = {}
-if config_host.has_key('CONFIG_CURSES')
+if curses.found()
curses_ss = ss.source_set()
curses_ss.add(when: [curses, iconv], if_true: [files('curses.c'), pixman])
ui_modules += {'curses' : curses_ss}
--
2.27.0
next prev parent reply other threads:[~2020-10-14 8:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-14 8:21 [PULL 0/9] Ui 20201014 patches Gerd Hoffmann
2020-10-14 8:21 ` [PULL 1/9] qemu-edid: drop cast Gerd Hoffmann
2020-10-14 8:21 ` [PULL 2/9] curses: Fixes compiler error that complain don't have langinfo.h on msys2/mingw Gerd Hoffmann
2020-10-14 8:21 ` [PULL 3/9] curses: Fixes curses compiling errors Gerd Hoffmann
2020-10-14 8:21 ` [PULL 4/9] win32: Simplify gmtime_r detection not depends on if _POSIX_C_SOURCE are defined on msys2/mingw Gerd Hoffmann
2020-10-14 8:21 ` Gerd Hoffmann [this message]
2020-10-14 18:22 ` [PULL 5/9] configure: Fixes ncursesw detection under msys2/mingw by convert them to meson Bruce Rogers
2020-10-14 19:16 ` 罗勇刚(Yonggang Luo)
2020-10-14 19:17 ` 罗勇刚(Yonggang Luo)
2020-10-14 20:10 ` Bruce Rogers
2020-10-14 8:21 ` [PULL 6/9] vnc-stubs: Allow -vnc none Gerd Hoffmann
2020-10-14 8:21 ` [PULL 7/9] SDL: enable OpenGL context creation Gerd Hoffmann
2020-10-14 8:21 ` [PULL 8/9] input-linux: Reset il->fd handler before closing it Gerd Hoffmann
2020-10-14 8:21 ` [PULL 9/9] ui: Fix default window_id value Gerd Hoffmann
2020-10-14 14:24 ` [PULL 0/9] Ui 20201014 patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201014082149.26853-6-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=luoyonggang@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.