meson.build: Support ncurses on MacOS and OpenBSD
PATCH v2 1/1 meson.build: Support ncurses on MacOS and OpenBSD
MacOS provides header files for curses 5.7 with support for wide characters, but requires _XOPEN_SOURCE_EXTENDED=1 to activate that.
By default those old header files are used even if there is a newer Homebrew installation of ncurses 6.2 available.
Change also the old macro definition of NCURSES_WIDECHAR and set it to 1 like it is done in newer versions of curses.h when _XOPEN_SOURCE_EXTENDED=1 is defined.
OpenBSD has the same version of ncurses and needs the same fix.
---
v2:
- Only define _XOPEN_SOURCE_EXTENDED when curses.h is used.
- Extended to fix OpenBSD, too (untested!)
meson.build | 5 ++++- ui/curses.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)
meson.build +4 -1
@@ -681,6 +681,9 @@ iconv = not_found curses = not_found if have_system and not get_option('curses').disabled() curses_test = ''' + #if defined(__APPLE__) || defined(__OpenBSD__) + #define _XOPEN_SOURCE_EXTENDED 1 + #endif #include <locale.h> #include <curses.h> #include <wchar.h>
@@ -704,7 +707,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=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])
ui/curses.c +4 -0
@@ -38,6 +38,10 @@#include "ui/input.h" #include "sysemu/sysemu.h" +#if defined(__APPLE__) || defined(__OpenBSD__) +#define _XOPEN_SOURCE_EXTENDED 1 +#endif +/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */ #undef KEY_EVENT#include <curses.h>
Signature · 1 line
2.30.2
Quoted 17 lines · Stefan Weil
MacOS provides header files for curses 5.7 with support for wide characters, but requires _XOPEN_SOURCE_EXTENDED=1 to activate that.
By default those old header files are used even if there is a newer Homebrew installation of ncurses 6.2 available.
Change also the old macro definition of
NCURSES_WIDECHARand set it to 1 like it is done in newer versions ofcurses.hwhen _XOPEN_SOURCE_EXTENDED=1 is defined.OpenBSD has the same version of ncurses and needs the same fix.
Suggested-by Daniel P. Berrangé <[email protected]>Signed-off-by Stefan Weil <[email protected]>---
Quoted 7 lines
v2:
- Only define_XOPEN_SOURCE_EXTENDEDwhencurses.his used.
- Extended to fix OpenBSD, too (untested!)meson.build | 5 ++++- ui/curses.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)
Regards,
Daniel
Signature · 3 lines
|: 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 :|
Quoted 17 lines · Stefan Weil
MacOS provides header files for curses 5.7 with support for wide characters, but requires _XOPEN_SOURCE_EXTENDED=1 to activate that.
By default those old header files are used even if there is a newer Homebrew installation of ncurses 6.2 available.
Change also the old macro definition of
NCURSES_WIDECHARand set it to 1 like it is done in newer versions ofcurses.hwhen _XOPEN_SOURCE_EXTENDED=1 is defined.OpenBSD has the same version of ncurses and needs the same fix.
Suggested-by Daniel P. Berrangé <[email protected]>Signed-off-by Stefan Weil <[email protected]>---
Quoted 7 lines
v2:
- Only define_XOPEN_SOURCE_EXTENDEDwhencurses.his used.
- Extended to fix OpenBSD, too (untested!)meson.build | 5 ++++- ui/curses.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)
Paolo Bonzini
AppliedQuoted 11 lines · Stefan Weil
MacOS provides header files for curses 5.7 with support for wide characters, but requires _XOPEN_SOURCE_EXTENDED=1 to activate that.
By default those old header files are used even if there is a newer Homebrew installation of ncurses 6.2 available.
Change also the old macro definition of
NCURSES_WIDECHARand set it to 1 like it is done in newer versions ofcurses.hwhen _XOPEN_SOURCE_EXTENDED=1 is defined.
Quoted 5 lines
OpenBSD has the same version of ncurses and needs the same fix.
Suggested-by Daniel P. Berrangé <[email protected]>Signed-off-by Stefan Weil <[email protected]>---
Queued, thanks.
Paolo
Quoted 47 lines
v2:
- Only define_XOPEN_SOURCE_EXTENDEDwhencurses.his used.
- Extended to fix OpenBSD, too (untested!)meson.build | 5 ++++- ui/curses.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-)meson.build +4
-1@@ -681,6 +681,9 @@ iconv = not_found curses = not_found if have_system and not get_option('curses').disabled() curses_test = ''' + #if defined(__APPLE__) || defined(__OpenBSD__) + #define _XOPEN_SOURCE_EXTENDED 1 + #endif #include <locale.h> #include <curses.h> #include <wchar.h>@@ -704,7 +707,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=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])ui/curses.c +4
-0@@ -38,6 +38,10 @@#include "ui/input.h" #include "sysemu/sysemu.h" +#if defined(__APPLE__) || defined(__OpenBSD__) +#define _XOPEN_SOURCE_EXTENDED 1 +#endif +/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */ #undef KEY_EVENT#include <curses.h>