All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Laszlo Ersek <lersek@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	patches@linaro.org, "Stefan Weil" <sw@weilnetz.de>,
	"Chad Joan" <chadjoan@gmail.com>,
	qemu-devel@nongnu.org, "Rainer Müller" <raimue@codingfarm.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses
Date: Mon, 7 Jun 2021 14:05:52 +0100	[thread overview]
Message-ID: <YL4ZsOVbMsQpDSlk@redhat.com> (raw)
In-Reply-To: <32204168-460d-237c-c542-1a1f3757db6d@redhat.com>

On Mon, Jun 07, 2021 at 02:57:41PM +0200, Laszlo Ersek wrote:
> On 06/06/21 20:13, Stefan Weil wrote:
> > Am 02.06.17 um 16:35 schrieb Peter Maydell:
> > 
> >> We want the wide character functions from the ncurses header.
> >> Unfortunately it doesn't provide them by default, but only
> >> if either:
> >>   * NCURSES_WIDECHAR is defined (for ncurses 20111030 and up)
> >>   * _XOPEN_SOURCE/_XOPEN_SOURCE_EXTENDED are suitably defined
> >>
> >> So far we have been implicitly relying on the latter, because
> >> for GNU libc when we define _GNU_SOURCE this causes libc
> >> to define the _XOPEN_SOURCE macros for us. Unfortunately
> >> this doesn't work on all libcs, because some (like OSX and
> >> musl libc) do not define _XOPEN_SOURCE when _GNU_SOURCE
> >> is defined.
> >>
> >> We can't fix this by defining _XOPEN_SOURCE ourselves, because
> >> that also means "and don't provide any functions that aren't in
> >> that standard", and not all libcs provide any way to override
> >> that to also get the non-standard functions. In particular
> >> FreeBSD has no such mechanism, and OSX's _DARWIN_C_SOURCE
> >> doesn't reenable everything (for instance getpagesize()
> >> is still not prototyped if _DARWIN_C_SOURCE and _XOPEN_SOURCE
> >> are both defined).
> >>
> >> So we have to define NCURSES_WIDECHAR. (This will only work
> >> if your ncurses is at least 20111030, as older versions
> >> don't honour this macro.)
> > 
> > 
> > I answer to this very old e-mail because I noticed today that defining
> > NCURSES_WIDECHAR does not work with the latest MacOS on M1:
> > 
> > Apple still delivers a curses.h which indicates NCURSES_VERSION "5.7"
> > (20081102). It does not know NCURSES_WIDECHAR, but support for curses
> > can be enabled with _XOPEN_SOURCE_EXTENDED=1.
> > 
> > I used this patch for git master:
> > 
> > diff --git a/meson.build b/meson.build
> > index 626cf932c1..513332a76d 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -606,7 +606,7 @@ if have_system and not get_option('curses').disabled()
> >      endif
> >    endforeach
> >    msg = get_option('curses').enabled() ? 'curses library not found' : ''
> > -  curses_compile_args = ['-DNCURSES_WIDECHAR']
> > +  curses_compile_args = ['-DNCURSES_WIDECHAR',
> > '-D_XOPEN_SOURCE_EXTENDED=1']
> >    if curses.found()
> >      if cc.links(curses_test, args: curses_compile_args, dependencies:
> > [curses])
> >        curses = declare_dependency(compile_args: curses_compile_args,
> > dependencies: [curses])
> > 
> > 
> > Then curses is detected and works when configure is given the right
> > PKG_CONFIG_PATH:
> > 
> > PKG_CONFIG_PATH=/opt/homebrew/Library/Homebrew/os/mac/pkgconfig/11
> > ./configure
> 
> _XOPEN_SOURCE_EXTENDED is only supposed to make a difference in SUSv2.
> If MacOS needs it, whatever, but I don't view it as a good idea for any
> other host OS.

Easy to do with

  if host_machine.system() == 'darwin'
    curses_compile_args = [ '-D_XOPEN_SOURCE_EXTENDED=1']
  else
    curses_compile_args = ['-DNCURSES_WIDECHAR']
  endif

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



      reply	other threads:[~2021-06-07 13:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 14:35 [Qemu-devel] [PATCH] configure: Define NCURSES_WIDECHAR if we're using curses Peter Maydell
2017-06-02 21:58 ` Laszlo Ersek
2017-06-03  9:43   ` Kamil Rytarowski
2017-06-03 16:08     ` Laszlo Ersek
2017-06-03 10:13 ` Rainer Müller
2017-06-03 10:17   ` Kamil Rytarowski
2017-06-26 13:31 ` Peter Maydell
2021-06-06 18:13 ` Stefan Weil
2021-06-07 12:57   ` Laszlo Ersek
2021-06-07 13:05     ` Daniel P. Berrangé [this message]

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=YL4ZsOVbMsQpDSlk@redhat.com \
    --to=berrange@redhat.com \
    --cc=chadjoan@gmail.com \
    --cc=lersek@redhat.com \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raimue@codingfarm.de \
    --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.