diff mbox series

[PULL,5/9] configure: Fixes ncursesw detection under msys2/mingw by convert them to meson

Message ID 20201014082149.26853-6-kraxel@redhat.com
State New
Headers show
Series Ui 20201014 patches | expand

Commit Message

Gerd Hoffmann Oct. 14, 2020, 8:21 a.m. UTC
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(-)

Comments

Bruce Rogers Oct. 14, 2020, 6:22 p.m. UTC | #1
On Wed, 2020-10-14 at 10:21 +0200, Gerd Hoffmann wrote:
> 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}


I find that this change causes a configure failure when choosing either
--enable-iconv or --enable-curses as follows:

../configure --enable-curses results in 
../meson.build:491:4: ERROR: Problem encountered: Cannot detect iconv
API

../configure --enable-iconv results in 
../meson.build:446:2: ERROR: Problem encountered: Cannot detect iconv
API

I haven't yet learned meson well enough to identify further what is
going wrong.

Can someone take a look at what might be failing, or give me some clue
what I can check on or report on from my end which would be helpful to
resolve this?
I am running openSUSE Tumbleweed, by the way.

Thanks,

Bruce
罗勇刚(Yonggang Luo) Oct. 14, 2020, 7:16 p.m. UTC | #2
Because you didn't install the iconv.

On Thu, Oct 15, 2020 at 2:22 AM Bruce Rogers <brogers@suse.com> wrote:
>
> On Wed, 2020-10-14 at 10:21 +0200, Gerd Hoffmann wrote:
> > 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}
>
> I find that this change causes a configure failure when choosing either
> --enable-iconv or --enable-curses as follows:
>
> ../configure --enable-curses results in
> ../meson.build:491:4: ERROR: Problem encountered: Cannot detect iconv
> API
>
> ../configure --enable-iconv results in
> ../meson.build:446:2: ERROR: Problem encountered: Cannot detect iconv
> API
>
> I haven't yet learned meson well enough to identify further what is
> going wrong.
>
> Can someone take a look at what might be failing, or give me some clue
> what I can check on or report on from my end which would be helpful to
> resolve this?
> I am running openSUSE Tumbleweed, by the way.
>
> Thanks,
>
> Bruce
>


--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr">Because you didn&#39;t install the iconv.<br><br>On Thu, Oct 15, 2020 at 2:22 AM Bruce Rogers &lt;<a href="mailto:brogers@suse.com">brogers@suse.com</a>&gt; wrote:<br>&gt;<br>&gt; On Wed, 2020-10-14 at 10:21 +0200, Gerd Hoffmann wrote:<br>&gt; &gt; From: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt;<br>&gt; &gt; The mingw pkg-config are showing following absolute path and contains<br>&gt; &gt; : as the separator,<br>&gt; &gt;<br>&gt; &gt; -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-<br>&gt; &gt; Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw:<br>&gt; &gt; -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC<br>&gt; &gt; -pipe -lncursesw -lgnurx -ltre -lintl -liconv<br>&gt; &gt; -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC<br>&gt; &gt; -lncursesw<br>&gt; &gt; -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC<br>&gt; &gt; -lcursesw<br>&gt; &gt; -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe<br>&gt; &gt; -lncursesw -lgnurx -ltre -lintl -liconv<br>&gt; &gt; -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw<br>&gt; &gt; -lncursesw<br>&gt; &gt; -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw<br>&gt; &gt; -lcursesw<br>&gt; &gt; -DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx<br>&gt; &gt; -ltre -lintl -liconv<br>&gt; &gt; -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw<br>&gt; &gt; -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw<br>&gt; &gt;<br>&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt; Reviewed-by: Gerd Hoffmann &lt;<a href="mailto:kraxel@redhat.com">kraxel@redhat.com</a>&gt;<br>&gt; &gt; Message-id: <a href="mailto:20201012234348.1427-6-luoyonggang@gmail.com">20201012234348.1427-6-luoyonggang@gmail.com</a><br>&gt; &gt; Signed-off-by: Gerd Hoffmann &lt;<a href="mailto:kraxel@redhat.com">kraxel@redhat.com</a>&gt;<br>&gt; &gt; ---<br>&gt; &gt;  configure         | 118 +++-----------------------------------------<br>&gt; &gt; --<br>&gt; &gt;  meson_options.txt |   4 ++<br>&gt; &gt;  meson.build       |  83 +++++++++++++++++++++++++++-----<br>&gt; &gt;  ui/meson.build    |   2 +-<br>&gt; &gt;  4 files changed, 83 insertions(+), 124 deletions(-)<br>&gt; &gt;<br>&gt; &gt; diff --git a/configure b/configure<br>&gt; &gt; index 9a87685517ee..f839c2a557c3 100755<br>&gt; &gt; --- a/configure<br>&gt; &gt; +++ b/configure<br>&gt; &gt; @@ -295,7 +295,8 @@ unset target_list_exclude<br>&gt; &gt; <br>&gt; &gt;  brlapi=&quot;&quot;<br>&gt; &gt;  curl=&quot;&quot;<br>&gt; &gt; -curses=&quot;&quot;<br>&gt; &gt; +iconv=&quot;auto&quot;<br>&gt; &gt; +curses=&quot;auto&quot;<br>&gt; &gt;  docs=&quot;&quot;<br>&gt; &gt;  fdt=&quot;auto&quot;<br>&gt; &gt;  netmap=&quot;no&quot;<br>&gt; &gt; @@ -1173,13 +1174,13 @@ for opt do<br>&gt; &gt;    ;;<br>&gt; &gt;    --disable-safe-stack) safe_stack=&quot;no&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; -  --disable-curses) curses=&quot;no&quot;<br>&gt; &gt; +  --disable-curses) curses=&quot;disabled&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; -  --enable-curses) curses=&quot;yes&quot;<br>&gt; &gt; +  --enable-curses) curses=&quot;enabled&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; -  --disable-iconv) iconv=&quot;no&quot;<br>&gt; &gt; +  --disable-iconv) iconv=&quot;disabled&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; -  --enable-iconv) iconv=&quot;yes&quot;<br>&gt; &gt; +  --enable-iconv) iconv=&quot;enabled&quot;<br>&gt; &gt;    ;;<br>&gt; &gt;    --disable-curl) curl=&quot;no&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; @@ -3440,102 +3441,6 @@ EOF<br>&gt; &gt;    fi<br>&gt; &gt;  fi<br>&gt; &gt; <br>&gt; &gt; -##########################################<br>&gt; &gt; -# iconv probe<br>&gt; &gt; -if test &quot;$iconv&quot; != &quot;no&quot; ; then<br>&gt; &gt; -  cat &gt; $TMPC &lt;&lt; EOF<br>&gt; &gt; -#include &lt;iconv.h&gt;<br>&gt; &gt; -int main(void) {<br>&gt; &gt; -  iconv_t conv = iconv_open(&quot;WCHAR_T&quot;, &quot;UCS-2&quot;);<br>&gt; &gt; -  return conv != (iconv_t) -1;<br>&gt; &gt; -}<br>&gt; &gt; -EOF<br>&gt; &gt; -  iconv_prefix_list=&quot;/usr/local:/usr&quot;<br>&gt; &gt; -  iconv_lib_list=&quot;:-liconv&quot;<br>&gt; &gt; -  IFS=:<br>&gt; &gt; -  for iconv_prefix in $iconv_prefix_list; do<br>&gt; &gt; -    IFS=:<br>&gt; &gt; -    iconv_cflags=&quot;-I$iconv_prefix/include&quot;<br>&gt; &gt; -    iconv_ldflags=&quot;-L$iconv_prefix/lib&quot;<br>&gt; &gt; -    for iconv_link in $iconv_lib_list; do<br>&gt; &gt; -      unset IFS<br>&gt; &gt; -      iconv_lib=&quot;$iconv_ldflags $iconv_link&quot;<br>&gt; &gt; -      echo &quot;looking at iconv in &#39;$iconv_cflags&#39; &#39;$iconv_lib&#39;&quot; &gt;&gt;<br>&gt; &gt; config.log<br>&gt; &gt; -      if compile_prog &quot;$iconv_cflags&quot; &quot;$iconv_lib&quot; ; then<br>&gt; &gt; -        iconv_found=yes<br>&gt; &gt; -        break<br>&gt; &gt; -      fi<br>&gt; &gt; -    done<br>&gt; &gt; -    if test &quot;$iconv_found&quot; = yes ; then<br>&gt; &gt; -      break<br>&gt; &gt; -    fi<br>&gt; &gt; -  done<br>&gt; &gt; -  if test &quot;$iconv_found&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -    iconv=yes<br>&gt; &gt; -  else<br>&gt; &gt; -    if test &quot;$iconv&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -      feature_not_found &quot;iconv&quot; &quot;Install iconv devel&quot;<br>&gt; &gt; -    fi<br>&gt; &gt; -    iconv=no<br>&gt; &gt; -  fi<br>&gt; &gt; -fi<br>&gt; &gt; -<br>&gt; &gt; -##########################################<br>&gt; &gt; -# curses probe<br>&gt; &gt; -if test &quot;$iconv&quot; = &quot;no&quot; ; then<br>&gt; &gt; -  # curses will need iconv<br>&gt; &gt; -  curses=no<br>&gt; &gt; -fi<br>&gt; &gt; -if test &quot;$curses&quot; != &quot;no&quot; ; then<br>&gt; &gt; -  if test &quot;$mingw32&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -    curses_inc_list=&quot;$($pkg_config --cflags ncurses 2&gt;/dev/null):&quot;<br>&gt; &gt; -    curses_lib_list=&quot;$($pkg_config --libs ncurses 2&gt;/dev/null):-<br>&gt; &gt; lpdcurses&quot;<br>&gt; &gt; -  else<br>&gt; &gt; -    curses_inc_list=&quot;$($pkg_config --cflags ncursesw 2&gt;/dev/null):-<br>&gt; &gt; I/usr/include/ncursesw:&quot;<br>&gt; &gt; -    curses_lib_list=&quot;$($pkg_config --libs ncursesw 2&gt;/dev/null):-<br>&gt; &gt; lncursesw:-lcursesw&quot;<br>&gt; &gt; -  fi<br>&gt; &gt; -  curses_found=no<br>&gt; &gt; -  cat &gt; $TMPC &lt;&lt; EOF<br>&gt; &gt; -#include &lt;locale.h&gt;<br>&gt; &gt; -#include &lt;curses.h&gt;<br>&gt; &gt; -#include &lt;wchar.h&gt;<br>&gt; &gt; -int main(void) {<br>&gt; &gt; -  wchar_t wch = L&#39;w&#39;;<br>&gt; &gt; -  setlocale(LC_ALL, &quot;&quot;);<br>&gt; &gt; -  resize_term(0, 0);<br>&gt; &gt; -  addwstr(L&quot;wide chars\n&quot;);<br>&gt; &gt; -  addnwstr(&amp;wch, 1);<br>&gt; &gt; -  add_wch(WACS_DEGREE);<br>&gt; &gt; -  return 0;<br>&gt; &gt; -}<br>&gt; &gt; -EOF<br>&gt; &gt; -  IFS=:<br>&gt; &gt; -  for curses_inc in $curses_inc_list; do<br>&gt; &gt; -    # Make sure we get the wide character prototypes<br>&gt; &gt; -    curses_inc=&quot;-DNCURSES_WIDECHAR $curses_inc&quot;<br>&gt; &gt; -    IFS=:<br>&gt; &gt; -    for curses_lib in $curses_lib_list; do<br>&gt; &gt; -      unset IFS<br>&gt; &gt; -      if compile_prog &quot;$curses_inc&quot; &quot;$curses_lib&quot; ; then<br>&gt; &gt; -        curses_found=yes<br>&gt; &gt; -        break<br>&gt; &gt; -      fi<br>&gt; &gt; -    done<br>&gt; &gt; -    if test &quot;$curses_found&quot; = yes ; then<br>&gt; &gt; -      break<br>&gt; &gt; -    fi<br>&gt; &gt; -  done<br>&gt; &gt; -  unset IFS<br>&gt; &gt; -  if test &quot;$curses_found&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -    curses=yes<br>&gt; &gt; -  else<br>&gt; &gt; -    if test &quot;$curses&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -      feature_not_found &quot;curses&quot; &quot;Install ncurses devel&quot;<br>&gt; &gt; -    fi<br>&gt; &gt; -    curses=no<br>&gt; &gt; -  fi<br>&gt; &gt; -fi<br>&gt; &gt; -<br>&gt; &gt;  ##########################################<br>&gt; &gt;  # curl probe<br>&gt; &gt;  if test &quot;$curl&quot; != &quot;no&quot; ; then<br>&gt; &gt; @@ -6200,16 +6105,6 @@ if test &quot;$have_x11&quot; = &quot;yes&quot; &amp;&amp; test<br>&gt; &gt; &quot;$need_x11&quot; = &quot;yes&quot;; then<br>&gt; &gt;    echo &quot;X11_CFLAGS=$x11_cflags&quot; &gt;&gt; $config_host_mak<br>&gt; &gt;    echo &quot;X11_LIBS=$x11_libs&quot; &gt;&gt; $config_host_mak<br>&gt; &gt;  fi<br>&gt; &gt; -if test &quot;$iconv&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -  echo &quot;CONFIG_ICONV=y&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -  echo &quot;ICONV_CFLAGS=$iconv_cflags&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -  echo &quot;ICONV_LIBS=$iconv_lib&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -fi<br>&gt; &gt; -if test &quot;$curses&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -  echo &quot;CONFIG_CURSES=y&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -  echo &quot;CURSES_CFLAGS=$curses_inc&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -  echo &quot;CURSES_LIBS=$curses_lib&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -fi<br>&gt; &gt;  if test &quot;$pipe2&quot; = &quot;yes&quot; ; then<br>&gt; &gt;    echo &quot;CONFIG_PIPE2=y&quot; &gt;&gt; $config_host_mak<br>&gt; &gt;  fi<br>&gt; &gt; @@ -7181,6 +7076,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \<br>&gt; &gt;          -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg<br>&gt; &gt; -Dvnc_png=$vnc_png \<br>&gt; &gt;          -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \<br>&gt; &gt;          -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \<br>&gt; &gt; +        -Diconv=$iconv -Dcurses=$curses \<br>&gt; &gt;          $cross_arg \<br>&gt; &gt;          &quot;$PWD&quot; &quot;$source_path&quot;<br>&gt; &gt; <br>&gt; &gt; diff --git a/meson_options.txt b/meson_options.txt<br>&gt; &gt; index 1d3c94840a90..e6cb1e589b4e 100644<br>&gt; &gt; --- a/meson_options.txt<br>&gt; &gt; +++ b/meson_options.txt<br>&gt; &gt; @@ -32,6 +32,10 @@ option(&#39;cocoa&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt;         description: &#39;Cocoa user interface (macOS only)&#39;)<br>&gt; &gt;  option(&#39;mpath&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt;         description: &#39;Multipath persistent reservation passthrough&#39;)<br>&gt; &gt; +option(&#39;iconv&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt; +       description: &#39;Font glyph conversion support&#39;)<br>&gt; &gt; +option(&#39;curses&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt; +       description: &#39;curses UI&#39;)<br>&gt; &gt;  option(&#39;sdl&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt;         description: &#39;SDL user interface&#39;)<br>&gt; &gt;  option(&#39;sdl_image&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt; diff --git a/meson.build b/meson.build<br>&gt; &gt; index ad6c7c90c787..1a4a48249243 100644<br>&gt; &gt; --- a/meson.build<br>&gt; &gt; +++ b/meson.build<br>&gt; &gt; @@ -426,6 +426,74 @@ if targetos == &#39;linux&#39; and have_tools and not<br>&gt; &gt; get_option(&#39;mpath&#39;).disabled()<br>&gt; &gt;    endif<br>&gt; &gt;  endif<br>&gt; &gt; <br>&gt; &gt; +iconv = not_found<br>&gt; &gt; +if not get_option(&#39;iconv&#39;).disabled()<br>&gt; &gt; +  libiconv = cc.find_library(&#39;iconv&#39;,<br>&gt; &gt; +                             required: false,<br>&gt; &gt; +                             static: enable_static)<br>&gt; &gt; +  if libiconv.found()<br>&gt; &gt; +    if cc.links(&#39;&#39;&#39;<br>&gt; &gt; +      #include &lt;iconv.h&gt;<br>&gt; &gt; +      int main(void) {<br>&gt; &gt; +        iconv_t conv = iconv_open(&quot;WCHAR_T&quot;, &quot;UCS-2&quot;);<br>&gt; &gt; +        return conv != (iconv_t) -1;<br>&gt; &gt; +      }&#39;&#39;&#39;, dependencies: [libiconv])<br>&gt; &gt; +      iconv = declare_dependency(dependencies: [libiconv])<br>&gt; &gt; +    endif<br>&gt; &gt; +  endif<br>&gt; &gt; +endif<br>&gt; &gt; +if get_option(&#39;iconv&#39;).enabled() and not iconv.found()<br>&gt; &gt; +  error(&#39;Cannot detect iconv API&#39;)<br>&gt; &gt; +endif<br>&gt; &gt; +<br>&gt; &gt; +curses = not_found<br>&gt; &gt; +if iconv.found() and not get_option(&#39;curses&#39;).disabled()<br>&gt; &gt; +  curses_libname_list = [&#39;ncursesw&#39;, &#39;ncurses&#39;, &#39;cursesw&#39;,<br>&gt; &gt; &#39;pdcurses&#39;]<br>&gt; &gt; +  curses_test = &#39;&#39;&#39;<br>&gt; &gt; +    #include &lt;locale.h&gt;<br>&gt; &gt; +    #include &lt;curses.h&gt;<br>&gt; &gt; +    #include &lt;wchar.h&gt;<br>&gt; &gt; +    int main(void) {<br>&gt; &gt; +      wchar_t wch = L&#39;w&#39;;<br>&gt; &gt; +      setlocale(LC_ALL, &quot;&quot;);<br>&gt; &gt; +      resize_term(0, 0);<br>&gt; &gt; +      addwstr(L&quot;wide chars\n&quot;);<br>&gt; &gt; +      addnwstr(&amp;wch, 1);<br>&gt; &gt; +      add_wch(WACS_DEGREE);<br>&gt; &gt; +      return 0;<br>&gt; &gt; +    }&#39;&#39;&#39;<br>&gt; &gt; +  foreach curses_libname : curses_libname_list<br>&gt; &gt; +      libcurses = dependency(curses_libname,<br>&gt; &gt; +                             required: false,<br>&gt; &gt; +                             method: &#39;pkg-config&#39;,<br>&gt; &gt; +                             static: enable_static)<br>&gt; &gt; +<br>&gt; &gt; +      if not libcurses.found()<br>&gt; &gt; +        dirs = [&#39;/usr/include/ncursesw&#39;]<br>&gt; &gt; +        if targetos == &#39;windows&#39;<br>&gt; &gt; +          dirs = []<br>&gt; &gt; +        endif<br>&gt; &gt; +        libcurses = cc.find_library(curses_libname,<br>&gt; &gt; +                                    required: false,<br>&gt; &gt; +                                    dirs: dirs,<br>&gt; &gt; +                                    static: enable_static)<br>&gt; &gt; +      endif<br>&gt; &gt; +      if libcurses.found()<br>&gt; &gt; +        if cc.links(curses_test, dependencies: [libcurses])<br>&gt; &gt; +          curses = declare_dependency(compile_args: &#39;-<br>&gt; &gt; DNCURSES_WIDECHAR&#39;, dependencies: [libcurses])<br>&gt; &gt; +          break<br>&gt; &gt; +        endif<br>&gt; &gt; +      endif<br>&gt; &gt; +  endforeach<br>&gt; &gt; +endif<br>&gt; &gt; +if get_option(&#39;curses&#39;).enabled() and not curses.found()<br>&gt; &gt; +  if not iconv.found()<br>&gt; &gt; +    error(&#39;Cannot detect iconv API&#39;)<br>&gt; &gt; +  else<br>&gt; &gt; +    error(&#39;Cannot detect curses API&#39;)<br>&gt; &gt; +  endif<br>&gt; &gt; +endif<br>&gt; &gt; +<br>&gt; &gt;  brlapi = not_found<br>&gt; &gt;  if &#39;CONFIG_BRLAPI&#39; in config_host<br>&gt; &gt;    brlapi = declare_dependency(link_args:<br>&gt; &gt; config_host[&#39;BRLAPI_LIBS&#39;].split())<br>&gt; &gt; @@ -504,16 +572,6 @@ if &#39;CONFIG_X11&#39; in config_host<br>&gt; &gt;    x11 = declare_dependency(compile_args:<br>&gt; &gt; config_host[&#39;X11_CFLAGS&#39;].split(),<br>&gt; &gt;                             link_args:<br>&gt; &gt; config_host[&#39;X11_LIBS&#39;].split())<br>&gt; &gt;  endif<br>&gt; &gt; -curses = not_found<br>&gt; &gt; -if &#39;CONFIG_CURSES&#39; in config_host<br>&gt; &gt; -  curses = declare_dependency(compile_args:<br>&gt; &gt; config_host[&#39;CURSES_CFLAGS&#39;].split(),<br>&gt; &gt; -                              link_args:<br>&gt; &gt; config_host[&#39;CURSES_LIBS&#39;].split())<br>&gt; &gt; -endif<br>&gt; &gt; -iconv = not_found<br>&gt; &gt; -if &#39;CONFIG_ICONV&#39; in config_host<br>&gt; &gt; -  iconv = declare_dependency(compile_args:<br>&gt; &gt; config_host[&#39;ICONV_CFLAGS&#39;].split(),<br>&gt; &gt; -                             link_args:<br>&gt; &gt; config_host[&#39;ICONV_LIBS&#39;].split())<br>&gt; &gt; -endif<br>&gt; &gt;  vnc = not_found<br>&gt; &gt;  png = not_found<br>&gt; &gt;  jpeg = not_found<br>&gt; &gt; @@ -622,6 +680,7 @@ config_host_data.set(&#39;CONFIG_COCOA&#39;,<br>&gt; &gt; cocoa.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_LIBUDEV&#39;, libudev.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_MPATH&#39;, mpathpersist.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_MPATH_NEW_API&#39;, mpathpersist_new_api)<br>&gt; &gt; +config_host_data.set(&#39;CONFIG_CURSES&#39;, curses.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_SDL&#39;, sdl.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_SDL_IMAGE&#39;, sdl_image.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_VNC&#39;, vnc.found())<br>&gt; &gt; @@ -1905,8 +1964,8 @@ if config_host.has_key(&#39;CONFIG_NETTLE&#39;)<br>&gt; &gt;  endif<br>&gt; &gt;  summary_info +=<br>&gt; &gt; {&#39;libtasn1&#39;:          config_host.has_key(&#39;CONFIG_TASN1&#39;)}<br>&gt; &gt;  summary_info +=<br>&gt; &gt; {&#39;PAM&#39;:               config_host.has_key(&#39;CONFIG_AUTH_PAM&#39;)}<br>&gt; &gt; -summary_info += {&#39;iconv<br>&gt; &gt; support&#39;:     config_host.has_key(&#39;CONFIG_ICONV&#39;)}<br>&gt; &gt; -summary_info += {&#39;curses<br>&gt; &gt; support&#39;:    config_host.has_key(&#39;CONFIG_CURSES&#39;)}<br>&gt; &gt; +summary_info += {&#39;iconv support&#39;:     iconv.found()}<br>&gt; &gt; +summary_info += {&#39;curses support&#39;:    curses.found()}<br>&gt; &gt;  # TODO: add back version<br>&gt; &gt;  summary_info += {&#39;virgl<br>&gt; &gt; support&#39;:     config_host.has_key(&#39;CONFIG_VIRGL&#39;)}<br>&gt; &gt;  summary_info += {&#39;curl<br>&gt; &gt; support&#39;:      config_host.has_key(&#39;CONFIG_CURL&#39;)}<br>&gt; &gt; diff --git a/ui/meson.build b/ui/meson.build<br>&gt; &gt; index 8a080c38e325..78ad792ffb8d 100644<br>&gt; &gt; --- a/ui/meson.build<br>&gt; &gt; +++ b/ui/meson.build<br>&gt; &gt; @@ -39,7 +39,7 @@ specific_ss.add(when: [&#39;CONFIG_SOFTMMU&#39;], if_true:<br>&gt; &gt; opengl)<br>&gt; &gt; <br>&gt; &gt;  ui_modules = {}<br>&gt; &gt; <br>&gt; &gt; -if config_host.has_key(&#39;CONFIG_CURSES&#39;)<br>&gt; &gt; +if curses.found()<br>&gt; &gt;    curses_ss = ss.source_set()<br>&gt; &gt;    curses_ss.add(when: [curses, iconv], if_true: [files(&#39;curses.c&#39;),<br>&gt; &gt; pixman])<br>&gt; &gt;    ui_modules += {&#39;curses&#39; : curses_ss}<br>&gt;<br>&gt; I find that this change causes a configure failure when choosing either<br>&gt; --enable-iconv or --enable-curses as follows:<br>&gt;<br>&gt; ../configure --enable-curses results in<br>&gt; ../meson.build:491:4: ERROR: Problem encountered: Cannot detect iconv<br>&gt; API<br>&gt;<br>&gt; ../configure --enable-iconv results in<br>&gt; ../meson.build:446:2: ERROR: Problem encountered: Cannot detect iconv<br>&gt; API<br>&gt;<br>&gt; I haven&#39;t yet learned meson well enough to identify further what is<br>&gt; going wrong.<br>&gt;<br>&gt; Can someone take a look at what might be failing, or give me some clue<br>&gt; what I can check on or report on from my end which would be helpful to<br>&gt; resolve this?<br>&gt; I am running openSUSE Tumbleweed, by the way.<br>&gt;<br>&gt; Thanks,<br>&gt;<br>&gt; Bruce<br>&gt;<br><br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div>
罗勇刚(Yonggang Luo) Oct. 14, 2020, 7:17 p.m. UTC | #3
If iconv installed then it's the meson's probme that didn't found the iconv
properly
On Thu, Oct 15, 2020 at 2:22 AM Bruce Rogers <brogers@suse.com> wrote:
>
> On Wed, 2020-10-14 at 10:21 +0200, Gerd Hoffmann wrote:
> > 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}
>
> I find that this change causes a configure failure when choosing either
> --enable-iconv or --enable-curses as follows:
>
> ../configure --enable-curses results in
> ../meson.build:491:4: ERROR: Problem encountered: Cannot detect iconv
> API
>
> ../configure --enable-iconv results in
> ../meson.build:446:2: ERROR: Problem encountered: Cannot detect iconv
> API
>
> I haven't yet learned meson well enough to identify further what is
> going wrong.
>
> Can someone take a look at what might be failing, or give me some clue
> what I can check on or report on from my end which would be helpful to
> resolve this?
> I am running openSUSE Tumbleweed, by the way.
>
> Thanks,
>
> Bruce
>


--
         此致
礼
罗勇刚
Yours
    sincerely,
Yonggang Luo
<div dir="ltr"><br>If iconv installed then it&#39;s the meson&#39;s probme that didn&#39;t found the iconv properly<br>On Thu, Oct 15, 2020 at 2:22 AM Bruce Rogers &lt;<a href="mailto:brogers@suse.com">brogers@suse.com</a>&gt; wrote:<br>&gt;<br>&gt; On Wed, 2020-10-14 at 10:21 +0200, Gerd Hoffmann wrote:<br>&gt; &gt; From: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt;<br>&gt; &gt; The mingw pkg-config are showing following absolute path and contains<br>&gt; &gt; : as the separator,<br>&gt; &gt;<br>&gt; &gt; -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC:/CI-<br>&gt; &gt; Tools/msys64/mingw64/include/ncursesw:-I/usr/include/ncursesw:<br>&gt; &gt; -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC<br>&gt; &gt; -pipe -lncursesw -lgnurx -ltre -lintl -liconv<br>&gt; &gt; -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC<br>&gt; &gt; -lncursesw<br>&gt; &gt; -DNCURSES_WIDECHAR -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L -IC<br>&gt; &gt; -lcursesw<br>&gt; &gt; -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw -pipe<br>&gt; &gt; -lncursesw -lgnurx -ltre -lintl -liconv<br>&gt; &gt; -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw<br>&gt; &gt; -lncursesw<br>&gt; &gt; -DNCURSES_WIDECHAR /CI-Tools/msys64/mingw64/include/ncursesw<br>&gt; &gt; -lcursesw<br>&gt; &gt; -DNCURSES_WIDECHAR -I/usr/include/ncursesw -pipe -lncursesw -lgnurx<br>&gt; &gt; -ltre -lintl -liconv<br>&gt; &gt; -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lncursesw<br>&gt; &gt; -DNCURSES_WIDECHAR -I/usr/include/ncursesw -lcursesw<br>&gt; &gt;<br>&gt; &gt; Signed-off-by: Yonggang Luo &lt;<a href="mailto:luoyonggang@gmail.com">luoyonggang@gmail.com</a>&gt;<br>&gt; &gt; Reviewed-by: Gerd Hoffmann &lt;<a href="mailto:kraxel@redhat.com">kraxel@redhat.com</a>&gt;<br>&gt; &gt; Message-id: <a href="mailto:20201012234348.1427-6-luoyonggang@gmail.com">20201012234348.1427-6-luoyonggang@gmail.com</a><br>&gt; &gt; Signed-off-by: Gerd Hoffmann &lt;<a href="mailto:kraxel@redhat.com">kraxel@redhat.com</a>&gt;<br>&gt; &gt; ---<br>&gt; &gt;  configure         | 118 +++-----------------------------------------<br>&gt; &gt; --<br>&gt; &gt;  meson_options.txt |   4 ++<br>&gt; &gt;  meson.build       |  83 +++++++++++++++++++++++++++-----<br>&gt; &gt;  ui/meson.build    |   2 +-<br>&gt; &gt;  4 files changed, 83 insertions(+), 124 deletions(-)<br>&gt; &gt;<br>&gt; &gt; diff --git a/configure b/configure<br>&gt; &gt; index 9a87685517ee..f839c2a557c3 100755<br>&gt; &gt; --- a/configure<br>&gt; &gt; +++ b/configure<br>&gt; &gt; @@ -295,7 +295,8 @@ unset target_list_exclude<br>&gt; &gt; <br>&gt; &gt;  brlapi=&quot;&quot;<br>&gt; &gt;  curl=&quot;&quot;<br>&gt; &gt; -curses=&quot;&quot;<br>&gt; &gt; +iconv=&quot;auto&quot;<br>&gt; &gt; +curses=&quot;auto&quot;<br>&gt; &gt;  docs=&quot;&quot;<br>&gt; &gt;  fdt=&quot;auto&quot;<br>&gt; &gt;  netmap=&quot;no&quot;<br>&gt; &gt; @@ -1173,13 +1174,13 @@ for opt do<br>&gt; &gt;    ;;<br>&gt; &gt;    --disable-safe-stack) safe_stack=&quot;no&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; -  --disable-curses) curses=&quot;no&quot;<br>&gt; &gt; +  --disable-curses) curses=&quot;disabled&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; -  --enable-curses) curses=&quot;yes&quot;<br>&gt; &gt; +  --enable-curses) curses=&quot;enabled&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; -  --disable-iconv) iconv=&quot;no&quot;<br>&gt; &gt; +  --disable-iconv) iconv=&quot;disabled&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; -  --enable-iconv) iconv=&quot;yes&quot;<br>&gt; &gt; +  --enable-iconv) iconv=&quot;enabled&quot;<br>&gt; &gt;    ;;<br>&gt; &gt;    --disable-curl) curl=&quot;no&quot;<br>&gt; &gt;    ;;<br>&gt; &gt; @@ -3440,102 +3441,6 @@ EOF<br>&gt; &gt;    fi<br>&gt; &gt;  fi<br>&gt; &gt; <br>&gt; &gt; -##########################################<br>&gt; &gt; -# iconv probe<br>&gt; &gt; -if test &quot;$iconv&quot; != &quot;no&quot; ; then<br>&gt; &gt; -  cat &gt; $TMPC &lt;&lt; EOF<br>&gt; &gt; -#include &lt;iconv.h&gt;<br>&gt; &gt; -int main(void) {<br>&gt; &gt; -  iconv_t conv = iconv_open(&quot;WCHAR_T&quot;, &quot;UCS-2&quot;);<br>&gt; &gt; -  return conv != (iconv_t) -1;<br>&gt; &gt; -}<br>&gt; &gt; -EOF<br>&gt; &gt; -  iconv_prefix_list=&quot;/usr/local:/usr&quot;<br>&gt; &gt; -  iconv_lib_list=&quot;:-liconv&quot;<br>&gt; &gt; -  IFS=:<br>&gt; &gt; -  for iconv_prefix in $iconv_prefix_list; do<br>&gt; &gt; -    IFS=:<br>&gt; &gt; -    iconv_cflags=&quot;-I$iconv_prefix/include&quot;<br>&gt; &gt; -    iconv_ldflags=&quot;-L$iconv_prefix/lib&quot;<br>&gt; &gt; -    for iconv_link in $iconv_lib_list; do<br>&gt; &gt; -      unset IFS<br>&gt; &gt; -      iconv_lib=&quot;$iconv_ldflags $iconv_link&quot;<br>&gt; &gt; -      echo &quot;looking at iconv in &#39;$iconv_cflags&#39; &#39;$iconv_lib&#39;&quot; &gt;&gt;<br>&gt; &gt; config.log<br>&gt; &gt; -      if compile_prog &quot;$iconv_cflags&quot; &quot;$iconv_lib&quot; ; then<br>&gt; &gt; -        iconv_found=yes<br>&gt; &gt; -        break<br>&gt; &gt; -      fi<br>&gt; &gt; -    done<br>&gt; &gt; -    if test &quot;$iconv_found&quot; = yes ; then<br>&gt; &gt; -      break<br>&gt; &gt; -    fi<br>&gt; &gt; -  done<br>&gt; &gt; -  if test &quot;$iconv_found&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -    iconv=yes<br>&gt; &gt; -  else<br>&gt; &gt; -    if test &quot;$iconv&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -      feature_not_found &quot;iconv&quot; &quot;Install iconv devel&quot;<br>&gt; &gt; -    fi<br>&gt; &gt; -    iconv=no<br>&gt; &gt; -  fi<br>&gt; &gt; -fi<br>&gt; &gt; -<br>&gt; &gt; -##########################################<br>&gt; &gt; -# curses probe<br>&gt; &gt; -if test &quot;$iconv&quot; = &quot;no&quot; ; then<br>&gt; &gt; -  # curses will need iconv<br>&gt; &gt; -  curses=no<br>&gt; &gt; -fi<br>&gt; &gt; -if test &quot;$curses&quot; != &quot;no&quot; ; then<br>&gt; &gt; -  if test &quot;$mingw32&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -    curses_inc_list=&quot;$($pkg_config --cflags ncurses 2&gt;/dev/null):&quot;<br>&gt; &gt; -    curses_lib_list=&quot;$($pkg_config --libs ncurses 2&gt;/dev/null):-<br>&gt; &gt; lpdcurses&quot;<br>&gt; &gt; -  else<br>&gt; &gt; -    curses_inc_list=&quot;$($pkg_config --cflags ncursesw 2&gt;/dev/null):-<br>&gt; &gt; I/usr/include/ncursesw:&quot;<br>&gt; &gt; -    curses_lib_list=&quot;$($pkg_config --libs ncursesw 2&gt;/dev/null):-<br>&gt; &gt; lncursesw:-lcursesw&quot;<br>&gt; &gt; -  fi<br>&gt; &gt; -  curses_found=no<br>&gt; &gt; -  cat &gt; $TMPC &lt;&lt; EOF<br>&gt; &gt; -#include &lt;locale.h&gt;<br>&gt; &gt; -#include &lt;curses.h&gt;<br>&gt; &gt; -#include &lt;wchar.h&gt;<br>&gt; &gt; -int main(void) {<br>&gt; &gt; -  wchar_t wch = L&#39;w&#39;;<br>&gt; &gt; -  setlocale(LC_ALL, &quot;&quot;);<br>&gt; &gt; -  resize_term(0, 0);<br>&gt; &gt; -  addwstr(L&quot;wide chars\n&quot;);<br>&gt; &gt; -  addnwstr(&amp;wch, 1);<br>&gt; &gt; -  add_wch(WACS_DEGREE);<br>&gt; &gt; -  return 0;<br>&gt; &gt; -}<br>&gt; &gt; -EOF<br>&gt; &gt; -  IFS=:<br>&gt; &gt; -  for curses_inc in $curses_inc_list; do<br>&gt; &gt; -    # Make sure we get the wide character prototypes<br>&gt; &gt; -    curses_inc=&quot;-DNCURSES_WIDECHAR $curses_inc&quot;<br>&gt; &gt; -    IFS=:<br>&gt; &gt; -    for curses_lib in $curses_lib_list; do<br>&gt; &gt; -      unset IFS<br>&gt; &gt; -      if compile_prog &quot;$curses_inc&quot; &quot;$curses_lib&quot; ; then<br>&gt; &gt; -        curses_found=yes<br>&gt; &gt; -        break<br>&gt; &gt; -      fi<br>&gt; &gt; -    done<br>&gt; &gt; -    if test &quot;$curses_found&quot; = yes ; then<br>&gt; &gt; -      break<br>&gt; &gt; -    fi<br>&gt; &gt; -  done<br>&gt; &gt; -  unset IFS<br>&gt; &gt; -  if test &quot;$curses_found&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -    curses=yes<br>&gt; &gt; -  else<br>&gt; &gt; -    if test &quot;$curses&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -      feature_not_found &quot;curses&quot; &quot;Install ncurses devel&quot;<br>&gt; &gt; -    fi<br>&gt; &gt; -    curses=no<br>&gt; &gt; -  fi<br>&gt; &gt; -fi<br>&gt; &gt; -<br>&gt; &gt;  ##########################################<br>&gt; &gt;  # curl probe<br>&gt; &gt;  if test &quot;$curl&quot; != &quot;no&quot; ; then<br>&gt; &gt; @@ -6200,16 +6105,6 @@ if test &quot;$have_x11&quot; = &quot;yes&quot; &amp;&amp; test<br>&gt; &gt; &quot;$need_x11&quot; = &quot;yes&quot;; then<br>&gt; &gt;    echo &quot;X11_CFLAGS=$x11_cflags&quot; &gt;&gt; $config_host_mak<br>&gt; &gt;    echo &quot;X11_LIBS=$x11_libs&quot; &gt;&gt; $config_host_mak<br>&gt; &gt;  fi<br>&gt; &gt; -if test &quot;$iconv&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -  echo &quot;CONFIG_ICONV=y&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -  echo &quot;ICONV_CFLAGS=$iconv_cflags&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -  echo &quot;ICONV_LIBS=$iconv_lib&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -fi<br>&gt; &gt; -if test &quot;$curses&quot; = &quot;yes&quot; ; then<br>&gt; &gt; -  echo &quot;CONFIG_CURSES=y&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -  echo &quot;CURSES_CFLAGS=$curses_inc&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -  echo &quot;CURSES_LIBS=$curses_lib&quot; &gt;&gt; $config_host_mak<br>&gt; &gt; -fi<br>&gt; &gt;  if test &quot;$pipe2&quot; = &quot;yes&quot; ; then<br>&gt; &gt;    echo &quot;CONFIG_PIPE2=y&quot; &gt;&gt; $config_host_mak<br>&gt; &gt;  fi<br>&gt; &gt; @@ -7181,6 +7076,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \<br>&gt; &gt;          -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg<br>&gt; &gt; -Dvnc_png=$vnc_png \<br>&gt; &gt;          -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \<br>&gt; &gt;          -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \<br>&gt; &gt; +        -Diconv=$iconv -Dcurses=$curses \<br>&gt; &gt;          $cross_arg \<br>&gt; &gt;          &quot;$PWD&quot; &quot;$source_path&quot;<br>&gt; &gt; <br>&gt; &gt; diff --git a/meson_options.txt b/meson_options.txt<br>&gt; &gt; index 1d3c94840a90..e6cb1e589b4e 100644<br>&gt; &gt; --- a/meson_options.txt<br>&gt; &gt; +++ b/meson_options.txt<br>&gt; &gt; @@ -32,6 +32,10 @@ option(&#39;cocoa&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt;         description: &#39;Cocoa user interface (macOS only)&#39;)<br>&gt; &gt;  option(&#39;mpath&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt;         description: &#39;Multipath persistent reservation passthrough&#39;)<br>&gt; &gt; +option(&#39;iconv&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt; +       description: &#39;Font glyph conversion support&#39;)<br>&gt; &gt; +option(&#39;curses&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt; +       description: &#39;curses UI&#39;)<br>&gt; &gt;  option(&#39;sdl&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt;         description: &#39;SDL user interface&#39;)<br>&gt; &gt;  option(&#39;sdl_image&#39;, type : &#39;feature&#39;, value : &#39;auto&#39;,<br>&gt; &gt; diff --git a/meson.build b/meson.build<br>&gt; &gt; index ad6c7c90c787..1a4a48249243 100644<br>&gt; &gt; --- a/meson.build<br>&gt; &gt; +++ b/meson.build<br>&gt; &gt; @@ -426,6 +426,74 @@ if targetos == &#39;linux&#39; and have_tools and not<br>&gt; &gt; get_option(&#39;mpath&#39;).disabled()<br>&gt; &gt;    endif<br>&gt; &gt;  endif<br>&gt; &gt; <br>&gt; &gt; +iconv = not_found<br>&gt; &gt; +if not get_option(&#39;iconv&#39;).disabled()<br>&gt; &gt; +  libiconv = cc.find_library(&#39;iconv&#39;,<br>&gt; &gt; +                             required: false,<br>&gt; &gt; +                             static: enable_static)<br>&gt; &gt; +  if libiconv.found()<br>&gt; &gt; +    if cc.links(&#39;&#39;&#39;<br>&gt; &gt; +      #include &lt;iconv.h&gt;<br>&gt; &gt; +      int main(void) {<br>&gt; &gt; +        iconv_t conv = iconv_open(&quot;WCHAR_T&quot;, &quot;UCS-2&quot;);<br>&gt; &gt; +        return conv != (iconv_t) -1;<br>&gt; &gt; +      }&#39;&#39;&#39;, dependencies: [libiconv])<br>&gt; &gt; +      iconv = declare_dependency(dependencies: [libiconv])<br>&gt; &gt; +    endif<br>&gt; &gt; +  endif<br>&gt; &gt; +endif<br>&gt; &gt; +if get_option(&#39;iconv&#39;).enabled() and not iconv.found()<br>&gt; &gt; +  error(&#39;Cannot detect iconv API&#39;)<br>&gt; &gt; +endif<br>&gt; &gt; +<br>&gt; &gt; +curses = not_found<br>&gt; &gt; +if iconv.found() and not get_option(&#39;curses&#39;).disabled()<br>&gt; &gt; +  curses_libname_list = [&#39;ncursesw&#39;, &#39;ncurses&#39;, &#39;cursesw&#39;,<br>&gt; &gt; &#39;pdcurses&#39;]<br>&gt; &gt; +  curses_test = &#39;&#39;&#39;<br>&gt; &gt; +    #include &lt;locale.h&gt;<br>&gt; &gt; +    #include &lt;curses.h&gt;<br>&gt; &gt; +    #include &lt;wchar.h&gt;<br>&gt; &gt; +    int main(void) {<br>&gt; &gt; +      wchar_t wch = L&#39;w&#39;;<br>&gt; &gt; +      setlocale(LC_ALL, &quot;&quot;);<br>&gt; &gt; +      resize_term(0, 0);<br>&gt; &gt; +      addwstr(L&quot;wide chars\n&quot;);<br>&gt; &gt; +      addnwstr(&amp;wch, 1);<br>&gt; &gt; +      add_wch(WACS_DEGREE);<br>&gt; &gt; +      return 0;<br>&gt; &gt; +    }&#39;&#39;&#39;<br>&gt; &gt; +  foreach curses_libname : curses_libname_list<br>&gt; &gt; +      libcurses = dependency(curses_libname,<br>&gt; &gt; +                             required: false,<br>&gt; &gt; +                             method: &#39;pkg-config&#39;,<br>&gt; &gt; +                             static: enable_static)<br>&gt; &gt; +<br>&gt; &gt; +      if not libcurses.found()<br>&gt; &gt; +        dirs = [&#39;/usr/include/ncursesw&#39;]<br>&gt; &gt; +        if targetos == &#39;windows&#39;<br>&gt; &gt; +          dirs = []<br>&gt; &gt; +        endif<br>&gt; &gt; +        libcurses = cc.find_library(curses_libname,<br>&gt; &gt; +                                    required: false,<br>&gt; &gt; +                                    dirs: dirs,<br>&gt; &gt; +                                    static: enable_static)<br>&gt; &gt; +      endif<br>&gt; &gt; +      if libcurses.found()<br>&gt; &gt; +        if cc.links(curses_test, dependencies: [libcurses])<br>&gt; &gt; +          curses = declare_dependency(compile_args: &#39;-<br>&gt; &gt; DNCURSES_WIDECHAR&#39;, dependencies: [libcurses])<br>&gt; &gt; +          break<br>&gt; &gt; +        endif<br>&gt; &gt; +      endif<br>&gt; &gt; +  endforeach<br>&gt; &gt; +endif<br>&gt; &gt; +if get_option(&#39;curses&#39;).enabled() and not curses.found()<br>&gt; &gt; +  if not iconv.found()<br>&gt; &gt; +    error(&#39;Cannot detect iconv API&#39;)<br>&gt; &gt; +  else<br>&gt; &gt; +    error(&#39;Cannot detect curses API&#39;)<br>&gt; &gt; +  endif<br>&gt; &gt; +endif<br>&gt; &gt; +<br>&gt; &gt;  brlapi = not_found<br>&gt; &gt;  if &#39;CONFIG_BRLAPI&#39; in config_host<br>&gt; &gt;    brlapi = declare_dependency(link_args:<br>&gt; &gt; config_host[&#39;BRLAPI_LIBS&#39;].split())<br>&gt; &gt; @@ -504,16 +572,6 @@ if &#39;CONFIG_X11&#39; in config_host<br>&gt; &gt;    x11 = declare_dependency(compile_args:<br>&gt; &gt; config_host[&#39;X11_CFLAGS&#39;].split(),<br>&gt; &gt;                             link_args:<br>&gt; &gt; config_host[&#39;X11_LIBS&#39;].split())<br>&gt; &gt;  endif<br>&gt; &gt; -curses = not_found<br>&gt; &gt; -if &#39;CONFIG_CURSES&#39; in config_host<br>&gt; &gt; -  curses = declare_dependency(compile_args:<br>&gt; &gt; config_host[&#39;CURSES_CFLAGS&#39;].split(),<br>&gt; &gt; -                              link_args:<br>&gt; &gt; config_host[&#39;CURSES_LIBS&#39;].split())<br>&gt; &gt; -endif<br>&gt; &gt; -iconv = not_found<br>&gt; &gt; -if &#39;CONFIG_ICONV&#39; in config_host<br>&gt; &gt; -  iconv = declare_dependency(compile_args:<br>&gt; &gt; config_host[&#39;ICONV_CFLAGS&#39;].split(),<br>&gt; &gt; -                             link_args:<br>&gt; &gt; config_host[&#39;ICONV_LIBS&#39;].split())<br>&gt; &gt; -endif<br>&gt; &gt;  vnc = not_found<br>&gt; &gt;  png = not_found<br>&gt; &gt;  jpeg = not_found<br>&gt; &gt; @@ -622,6 +680,7 @@ config_host_data.set(&#39;CONFIG_COCOA&#39;,<br>&gt; &gt; cocoa.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_LIBUDEV&#39;, libudev.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_MPATH&#39;, mpathpersist.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_MPATH_NEW_API&#39;, mpathpersist_new_api)<br>&gt; &gt; +config_host_data.set(&#39;CONFIG_CURSES&#39;, curses.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_SDL&#39;, sdl.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_SDL_IMAGE&#39;, sdl_image.found())<br>&gt; &gt;  config_host_data.set(&#39;CONFIG_VNC&#39;, vnc.found())<br>&gt; &gt; @@ -1905,8 +1964,8 @@ if config_host.has_key(&#39;CONFIG_NETTLE&#39;)<br>&gt; &gt;  endif<br>&gt; &gt;  summary_info +=<br>&gt; &gt; {&#39;libtasn1&#39;:          config_host.has_key(&#39;CONFIG_TASN1&#39;)}<br>&gt; &gt;  summary_info +=<br>&gt; &gt; {&#39;PAM&#39;:               config_host.has_key(&#39;CONFIG_AUTH_PAM&#39;)}<br>&gt; &gt; -summary_info += {&#39;iconv<br>&gt; &gt; support&#39;:     config_host.has_key(&#39;CONFIG_ICONV&#39;)}<br>&gt; &gt; -summary_info += {&#39;curses<br>&gt; &gt; support&#39;:    config_host.has_key(&#39;CONFIG_CURSES&#39;)}<br>&gt; &gt; +summary_info += {&#39;iconv support&#39;:     iconv.found()}<br>&gt; &gt; +summary_info += {&#39;curses support&#39;:    curses.found()}<br>&gt; &gt;  # TODO: add back version<br>&gt; &gt;  summary_info += {&#39;virgl<br>&gt; &gt; support&#39;:     config_host.has_key(&#39;CONFIG_VIRGL&#39;)}<br>&gt; &gt;  summary_info += {&#39;curl<br>&gt; &gt; support&#39;:      config_host.has_key(&#39;CONFIG_CURL&#39;)}<br>&gt; &gt; diff --git a/ui/meson.build b/ui/meson.build<br>&gt; &gt; index 8a080c38e325..78ad792ffb8d 100644<br>&gt; &gt; --- a/ui/meson.build<br>&gt; &gt; +++ b/ui/meson.build<br>&gt; &gt; @@ -39,7 +39,7 @@ specific_ss.add(when: [&#39;CONFIG_SOFTMMU&#39;], if_true:<br>&gt; &gt; opengl)<br>&gt; &gt; <br>&gt; &gt;  ui_modules = {}<br>&gt; &gt; <br>&gt; &gt; -if config_host.has_key(&#39;CONFIG_CURSES&#39;)<br>&gt; &gt; +if curses.found()<br>&gt; &gt;    curses_ss = ss.source_set()<br>&gt; &gt;    curses_ss.add(when: [curses, iconv], if_true: [files(&#39;curses.c&#39;),<br>&gt; &gt; pixman])<br>&gt; &gt;    ui_modules += {&#39;curses&#39; : curses_ss}<br>&gt;<br>&gt; I find that this change causes a configure failure when choosing either<br>&gt; --enable-iconv or --enable-curses as follows:<br>&gt;<br>&gt; ../configure --enable-curses results in<br>&gt; ../meson.build:491:4: ERROR: Problem encountered: Cannot detect iconv<br>&gt; API<br>&gt;<br>&gt; ../configure --enable-iconv results in<br>&gt; ../meson.build:446:2: ERROR: Problem encountered: Cannot detect iconv<br>&gt; API<br>&gt;<br>&gt; I haven&#39;t yet learned meson well enough to identify further what is<br>&gt; going wrong.<br>&gt;<br>&gt; Can someone take a look at what might be failing, or give me some clue<br>&gt; what I can check on or report on from my end which would be helpful to<br>&gt; resolve this?<br>&gt; I am running openSUSE Tumbleweed, by the way.<br>&gt;<br>&gt; Thanks,<br>&gt;<br>&gt; Bruce<br>&gt;<br><br><br>--<br>         此致<br>礼<br>罗勇刚<br>Yours<br>    sincerely,<br>Yonggang Luo</div>
Bruce Rogers Oct. 14, 2020, 8:10 p.m. UTC | #4
I believe we shouldn't be conditionalizing running the iconv c program detection
on the iconv library having been found. At least that's my semi-uninformed
analysis so far.

- Bruce
diff mbox series

Patch

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}