diff --git a/Include/py_curses.h b/Include/py_curses.h --- a/Include/py_curses.h +++ b/Include/py_curses.h @@ -39,35 +39,32 @@ #endif #ifndef _WINT_T #define _WINT_T #endif #endif #endif #endif -#ifdef HAVE_NCURSES_H +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif HAVE_NCURSES_H #include #else #include #ifdef HAVE_TERM_H /* for tigetstr, which is not declared in SysV curses */ #include #endif #endif -#ifdef HAVE_NCURSES_H -/* configure was checking , but we will - use , which has all these features. */ -#ifndef WINDOW_HAS_FLAGS -#define WINDOW_HAS_FLAGS 1 -#endif -#ifndef MVWDELCH_IS_EXPRESSION -#define MVWDELCH_IS_EXPRESSION 1 -#endif +#if defined(HAVE_NCURSESW_NCURSES_H) || defined(HAVE_NCURSES_NCURSES_H) || defined(HAVE_NCURSES_H) +#define HAVE_NCURSES #endif #ifdef __cplusplus extern "C" { #endif #define PyCurses_API_pointers 4 diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -9,17 +9,23 @@ static const char PyCursesVersion[] = "2.1"; /* Includes */ #include "Python.h" #include "py_curses.h" +#ifdef HAVE_NCURSESW_PANEL_H +#include +#elif defined(HAVE_NCURSES_PANEL_H) +#include +#else #include +#endif typedef struct { PyObject *PyCursesError; PyObject *PyCursesPanel_Type; } _curses_panelstate; #define _curses_panelstate(o) ((_curses_panelstate *)PyModule_GetState(o)) diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -120,17 +120,17 @@ extern int setupterm(char *,int,int *); #ifdef __sgi #include #endif #ifdef HAVE_LANGINFO_H #include #endif -#if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5)) +#if !defined(HAVE_NCURSES) && (defined(sgi) || defined(__sun) || defined(SCO5)) #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ typedef chtype attr_t; /* No attr_t type is available */ #endif #if defined(_AIX) #define STRICT_SYSV_CURSES #endif @@ -913,17 +913,17 @@ PyCursesWindow_Box(PyCursesWindowObject if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2)) return NULL; } box(self->win,ch1,ch2); Py_INCREF(Py_None); return Py_None; } -#if defined(HAVE_NCURSES_H) || defined(MVWDELCH_IS_EXPRESSION) +#ifdef MVWDELCH_IS_EXPRESSION #define py_mvwdelch mvwdelch #else int py_mvwdelch(WINDOW *w, int y, int x) { mvwdelch(w,y,x); /* On HP/UX, mvwdelch already returns. On other systems, we may well run into this return statement. */ return 0; @@ -2449,17 +2449,17 @@ PyCurses_InitScr(PyObject *self) SetDictInt("ACS_LRCORNER", (ACS_LRCORNER)); SetDictInt("ACS_LTEE", (ACS_LTEE)); SetDictInt("ACS_RTEE", (ACS_RTEE)); SetDictInt("ACS_BTEE", (ACS_BTEE)); SetDictInt("ACS_TTEE", (ACS_TTEE)); SetDictInt("ACS_HLINE", (ACS_HLINE)); SetDictInt("ACS_VLINE", (ACS_VLINE)); SetDictInt("ACS_PLUS", (ACS_PLUS)); -#if !defined(__hpux) || defined(HAVE_NCURSES_H) +#if !defined(__hpux) || defined(HAVE_NCURSES) /* On HP/UX 11, these are of type cchar_t, which is not an integral type. If this is a problem on more platforms, a configure test should be added to determine whether ACS_S1 is of integral type. */ SetDictInt("ACS_S1", (ACS_S1)); SetDictInt("ACS_S9", (ACS_S9)); SetDictInt("ACS_DIAMOND", (ACS_DIAMOND)); SetDictInt("ACS_CKBOARD", (ACS_CKBOARD)); diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -4915,84 +4915,94 @@ st.st_mtimespec.tv_nsec = 1; AC_MSG_RESULT($ac_cv_stat_tv_nsec2) if test "$ac_cv_stat_tv_nsec2" = yes then AC_DEFINE(HAVE_STAT_TV_NSEC2, 1, [Define if you have struct stat.st_mtimensec]) fi # first curses header check -ac_save_cppflags="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" - -AC_CHECK_HEADERS(curses.h ncurses.h) +AC_CHECK_HEADERS(curses.h ncurses.h ncursesw/ncurses.h ncurses/ncurses.h panel.h ncursesw/panel.h ncurses/panel.h) # On Solaris, term.h requires curses.h AC_CHECK_HEADERS(term.h,,,[ #ifdef HAVE_CURSES_H #include #endif ]) +AC_DEFUN([AC_LANG_CURSES_PROGRAM], [ +AC_LANG_PROGRAM([[ +#ifdef HAVE_NCURSESW_NCURSES_H +#include +#elif defined(HAVE_NCURSES_NCURSES_H) +#include +#elif defined(HAVE_NCURSES_H) +#include +#else +#include +#endif +]],[$1]) +]) + # On HP/UX 11.0, mvwdelch is a block with a return statement AC_MSG_CHECKING(whether mvwdelch is an expression) AC_CACHE_VAL(ac_cv_mvwdelch_is_expression, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[ int rtn; rtn = mvwdelch(0,0,0); ]])], [ac_cv_mvwdelch_is_expression=yes], [ac_cv_mvwdelch_is_expression=no])) AC_MSG_RESULT($ac_cv_mvwdelch_is_expression) if test "$ac_cv_mvwdelch_is_expression" = yes then AC_DEFINE(MVWDELCH_IS_EXPRESSION, 1, [Define if mvwdelch in curses.h is an expression.]) fi AC_MSG_CHECKING(whether WINDOW has _flags) AC_CACHE_VAL(ac_cv_window_has_flags, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[ WINDOW *w; w->_flags = 0; ]])], [ac_cv_window_has_flags=yes], [ac_cv_window_has_flags=no])) AC_MSG_RESULT($ac_cv_window_has_flags) if test "$ac_cv_window_has_flags" = yes then AC_DEFINE(WINDOW_HAS_FLAGS, 1, [Define if WINDOW in curses.h offers a field _flags.]) fi AC_MSG_CHECKING(for is_term_resized) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=is_term_resized]])], +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[void *x=is_term_resized]])], [AC_DEFINE(HAVE_CURSES_IS_TERM_RESIZED, 1, Define if you have the 'is_term_resized' function.) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)] ) AC_MSG_CHECKING(for resize_term) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resize_term]])], +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[void *x=resize_term]])], [AC_DEFINE(HAVE_CURSES_RESIZE_TERM, 1, Define if you have the 'resize_term' function.) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)] ) AC_MSG_CHECKING(for resizeterm) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[void *x=resizeterm]])], +AC_COMPILE_IFELSE([AC_LANG_CURSES_PROGRAM([[void *x=resizeterm]])], [AC_DEFINE(HAVE_CURSES_RESIZETERM, 1, Define if you have the 'resizeterm' function.) AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)] ) # last curses configure check -CPPFLAGS=$ac_save_cppflags AC_MSG_NOTICE([checking for device files]) dnl NOTE: Inform user how to proceed with files when cross compiling. if test "x$cross_compiling" = xyes; then if test "${ac_cv_file__dev_ptmx+set}" != set; then AC_MSG_CHECKING([for /dev/ptmx]) AC_MSG_RESULT([not set]) diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -1343,17 +1343,16 @@ class PyBuildExt(build_ext): # Curses support, requiring the System V version of curses, often # provided by the ncurses library. curses_defines = [] curses_includes = [] panel_library = 'panel' if curses_library == 'ncursesw': curses_defines.append(('HAVE_NCURSESW', '1')) - curses_includes.append('/usr/include/ncursesw') # Bug 1464056: If _curses.so links with ncursesw, # _curses_panel.so must link with panelw. panel_library = 'panelw' if host_platform == 'darwin': # On OS X, there is no separate /usr/lib/libncursesw nor # libpanelw. If we are here, we found a locally-supplied # version of libncursesw. There should be also be a # libpanelw. _XOPEN_SOURCE defines are usually excluded