Blame m4/ax_with_curses.m4

Packit 437b5e
# ===========================================================================
Packit 437b5e
#      http://www.gnu.org/software/autoconf-archive/ax_with_curses.html
Packit 437b5e
# ===========================================================================
Packit 437b5e
#
Packit 437b5e
# SYNOPSIS
Packit 437b5e
#
Packit 437b5e
#   AX_WITH_CURSES
Packit 437b5e
#
Packit 437b5e
# DESCRIPTION
Packit 437b5e
#
Packit 437b5e
#   This macro checks whether a SysV or X/Open-compatible Curses library is
Packit 437b5e
#   present, along with the associated header file.  The NcursesW
Packit 437b5e
#   (wide-character) library is searched for first, followed by Ncurses,
Packit 437b5e
#   then the system-default plain Curses.  The first library found is the
Packit 437b5e
#   one returned.
Packit 437b5e
#
Packit 437b5e
#   The following options are understood: --with-ncursesw, --with-ncurses,
Packit 437b5e
#   --without-ncursesw, --without-ncurses.  The "--with" options force the
Packit 437b5e
#   macro to use that particular library, terminating with an error if not
Packit 437b5e
#   found.  The "--without" options simply skip the check for that library.
Packit 437b5e
#   The effect on the search pattern is:
Packit 437b5e
#
Packit 437b5e
#     (no options)                           - NcursesW, Ncurses, Curses
Packit 437b5e
#     --with-ncurses     --with-ncursesw     - NcursesW only [*]
Packit 437b5e
#     --without-ncurses  --with-ncursesw     - NcursesW only [*]
Packit 437b5e
#                        --with-ncursesw     - NcursesW only [*]
Packit 437b5e
#     --with-ncurses     --without-ncursesw  - Ncurses only [*]
Packit 437b5e
#     --with-ncurses                         - NcursesW, Ncurses [**]
Packit 437b5e
#     --without-ncurses  --without-ncursesw  - Curses only
Packit 437b5e
#                        --without-ncursesw  - Ncurses, Curses
Packit 437b5e
#     --without-ncurses                      - NcursesW, Curses
Packit 437b5e
#
Packit 437b5e
#   [*]  If the library is not found, abort the configure script.
Packit 437b5e
#
Packit 437b5e
#   [**] If the second library (Ncurses) is not found, abort configure.
Packit 437b5e
#
Packit 437b5e
#   The following preprocessor symbols may be defined by this macro if the
Packit 437b5e
#   appropriate conditions are met:
Packit 437b5e
#
Packit 437b5e
#     HAVE_CURSES             - if any SysV or X/Open Curses library found
Packit 437b5e
#     HAVE_CURSES_ENHANCED    - if library supports X/Open Enhanced functions
Packit 437b5e
#     HAVE_CURSES_COLOR       - if library supports color (enhanced functions)
Packit 437b5e
#     HAVE_CURSES_OBSOLETE    - if library supports certain obsolete features
Packit 437b5e
#     HAVE_NCURSESW           - if NcursesW (wide char) library is to be used
Packit 437b5e
#     HAVE_NCURSES            - if the Ncurses library is to be used
Packit 437b5e
#
Packit 437b5e
#     HAVE_CURSES_H           - if <curses.h> is present and should be used
Packit 437b5e
#     HAVE_NCURSESW_H         - if <ncursesw.h> should be used
Packit 437b5e
#     HAVE_NCURSES_H          - if <ncurses.h> should be used
Packit 437b5e
#     HAVE_NCURSESW_CURSES_H  - if <ncursesw/curses.h> should be used
Packit 437b5e
#     HAVE_NCURSES_CURSES_H   - if <ncurses/curses.h> should be used
Packit 437b5e
#
Packit 437b5e
#   (These preprocessor symbols are discussed later in this document.)
Packit 437b5e
#
Packit 437b5e
#   The following output variable is defined by this macro; it is precious
Packit 437b5e
#   and may be overridden on the ./configure command line:
Packit 437b5e
#
Packit 437b5e
#     CURSES_LIB  - library to add to xxx_LDADD
Packit 437b5e
#
Packit 437b5e
#   The library listed in CURSES_LIB is NOT added to LIBS by default. You
Packit 437b5e
#   need to add CURSES_LIB to the appropriate xxx_LDADD line in your
Packit 437b5e
#   Makefile.am.  For example:
Packit 437b5e
#
Packit 437b5e
#     prog_LDADD = @CURSES_LIB@
Packit 437b5e
#
Packit 437b5e
#   If CURSES_LIB is set on the configure command line (such as by running
Packit 437b5e
#   "./configure CURSES_LIB=-lmycurses"), then the only header searched for
Packit 437b5e
#   is <curses.h>.  The user may use the CPPFLAGS precious variable to
Packit 437b5e
#   override the standard #include search path.  If the user needs to
Packit 437b5e
#   specify an alternative path for a library (such as for a non-standard
Packit 437b5e
#   NcurseW), the user should use the LDFLAGS variable.
Packit 437b5e
#
Packit 437b5e
#   The following shell variables may be defined by this macro:
Packit 437b5e
#
Packit 437b5e
#     ax_cv_curses           - set to "yes" if any Curses library found
Packit 437b5e
#     ax_cv_curses_enhanced  - set to "yes" if Enhanced functions present
Packit 437b5e
#     ax_cv_curses_color     - set to "yes" if color functions present
Packit 437b5e
#     ax_cv_curses_obsolete  - set to "yes" if obsolete features present
Packit 437b5e
#
Packit 437b5e
#     ax_cv_ncursesw      - set to "yes" if NcursesW library found
Packit 437b5e
#     ax_cv_ncurses       - set to "yes" if Ncurses library found
Packit 437b5e
#     ax_cv_plaincurses   - set to "yes" if plain Curses library found
Packit 437b5e
#     ax_cv_curses_which  - set to "ncursesw", "ncurses", "plaincurses" or "no"
Packit 437b5e
#
Packit 437b5e
#   These variables can be used in your configure.ac to determine the level
Packit 437b5e
#   of support you need from the Curses library.  For example, if you must
Packit 437b5e
#   have either Ncurses or NcursesW, you could include:
Packit 437b5e
#
Packit 437b5e
#     AX_WITH_CURSES
Packit 437b5e
#     if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then
Packit 437b5e
#         AX_MSG_ERROR([requires either NcursesW or Ncurses library])
Packit 437b5e
#     fi
Packit 437b5e
#
Packit 437b5e
#   If any Curses library will do (but one must be present and must support
Packit 437b5e
#   color), you could use:
Packit 437b5e
#
Packit 437b5e
#     AX_WITH_CURSES
Packit 437b5e
#     if test "x$ax_cv_curses" != xyes || test "x$ax_cv_curses_color" != xyes; then
Packit 437b5e
#         AC_MSG_ERROR([requires an X/Open-compatible Curses library with color])
Packit 437b5e
#     fi
Packit 437b5e
#
Packit 437b5e
#   Certain preprocessor symbols and shell variables defined by this macro
Packit 437b5e
#   can be used to determine various features of the Curses library.  In
Packit 437b5e
#   particular, HAVE_CURSES and ax_cv_curses are defined if the Curses
Packit 437b5e
#   library found conforms to the traditional SysV and/or X/Open Base Curses
Packit 437b5e
#   definition.  Any working Curses library conforms to this level.
Packit 437b5e
#
Packit 437b5e
#   HAVE_CURSES_ENHANCED and ax_cv_curses_enhanced are defined if the
Packit 437b5e
#   library supports the X/Open Enhanced Curses definition.  In particular,
Packit 437b5e
#   the wide-character types attr_t, cchar_t and wint_t, the functions
Packit 437b5e
#   wattr_set() and wget_wch() and the macros WA_NORMAL and _XOPEN_CURSES
Packit 437b5e
#   are checked.  The Ncurses library does NOT conform to this definition,
Packit 437b5e
#   although NcursesW does.
Packit 437b5e
#
Packit 437b5e
#   HAVE_CURSES_COLOR and ax_cv_curses_color are defined if the library
Packit 437b5e
#   supports color functions and macros such as COLOR_PAIR, A_COLOR,
Packit 437b5e
#   COLOR_WHITE, COLOR_RED and init_pair().  These are NOT part of the
Packit 437b5e
#   X/Open Base Curses definition, but are part of the Enhanced set of
Packit 437b5e
#   functions.  The Ncurses library DOES support these functions, as does
Packit 437b5e
#   NcursesW.
Packit 437b5e
#
Packit 437b5e
#   HAVE_CURSES_OBSOLETE and ax_cv_curses_obsolete are defined if the
Packit 437b5e
#   library supports certain features present in SysV and BSD Curses but not
Packit 437b5e
#   defined in the X/Open definition.  In particular, the functions
Packit 437b5e
#   getattrs(), getcurx() and getmaxx() are checked.
Packit 437b5e
#
Packit 437b5e
#   To use the HAVE_xxx_H preprocessor symbols, insert the following into
Packit 437b5e
#   your system.h (or equivalent) header file:
Packit 437b5e
#
Packit 437b5e
#     #if defined HAVE_NCURSESW_CURSES_H
Packit 437b5e
#     #  include <ncursesw/curses.h>
Packit 437b5e
#     #elif defined HAVE_NCURSESW_H
Packit 437b5e
#     #  include <ncursesw.h>
Packit 437b5e
#     #elif defined HAVE_NCURSES_CURSES_H
Packit 437b5e
#     #  include <ncurses/curses.h>
Packit 437b5e
#     #elif defined HAVE_NCURSES_H
Packit 437b5e
#     #  include <ncurses.h>
Packit 437b5e
#     #elif defined HAVE_CURSES_H
Packit 437b5e
#     #  include <curses.h>
Packit 437b5e
#     #else
Packit 437b5e
#     #  error "SysV or X/Open-compatible Curses header file required"
Packit 437b5e
#     #endif
Packit 437b5e
#
Packit 437b5e
#   For previous users of this macro: you should not need to change anything
Packit 437b5e
#   in your configure.ac or Makefile.am, as the previous (serial 10)
Packit 437b5e
#   semantics are still valid.  However, you should update your system.h (or
Packit 437b5e
#   equivalent) header file to the fragment shown above. You are encouraged
Packit 437b5e
#   also to make use of the extended functionality provided by this version
Packit 437b5e
#   of AX_WITH_CURSES, as well as in the additional macros
Packit 437b5e
#   AX_WITH_CURSES_PANEL, AX_WITH_CURSES_MENU and AX_WITH_CURSES_FORM.
Packit 437b5e
#
Packit 437b5e
# LICENSE
Packit 437b5e
#
Packit 437b5e
#   Copyright (c) 2009 Mark Pulford <mark@kyne.com.au>
Packit 437b5e
#   Copyright (c) 2009 Damian Pietras <daper@daper.net>
Packit 437b5e
#   Copyright (c) 2012 Reuben Thomas <rrt@sc3d.org>
Packit 437b5e
#   Copyright (c) 2011 John Zaitseff <J.Zaitseff@zap.org.au>
Packit 437b5e
#
Packit 437b5e
#   This program is free software: you can redistribute it and/or modify it
Packit 437b5e
#   under the terms of the GNU General Public License as published by the
Packit 437b5e
#   Free Software Foundation, either version 3 of the License, or (at your
Packit 437b5e
#   option) any later version.
Packit 437b5e
#
Packit 437b5e
#   This program is distributed in the hope that it will be useful, but
Packit 437b5e
#   WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 437b5e
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Packit 437b5e
#   Public License for more details.
Packit 437b5e
#
Packit 437b5e
#   You should have received a copy of the GNU General Public License along
Packit 437b5e
#   with this program. If not, see <http://www.gnu.org/licenses/>.
Packit 437b5e
#
Packit 437b5e
#   As a special exception, the respective Autoconf Macro's copyright owner
Packit 437b5e
#   gives unlimited permission to copy, distribute and modify the configure
Packit 437b5e
#   scripts that are the output of Autoconf when processing the Macro. You
Packit 437b5e
#   need not follow the terms of the GNU General Public License when using
Packit 437b5e
#   or distributing such scripts, even though portions of the text of the
Packit 437b5e
#   Macro appear in them. The GNU General Public License (GPL) does govern
Packit 437b5e
#   all other use of the material that constitutes the Autoconf Macro.
Packit 437b5e
#
Packit 437b5e
#   This special exception to the GPL applies to versions of the Autoconf
Packit 437b5e
#   Macro released by the Autoconf Archive. When you make and distribute a
Packit 437b5e
#   modified version of the Autoconf Macro, you may extend this special
Packit 437b5e
#   exception to the GPL to apply to your modified version as well.
Packit 437b5e
Packit 437b5e
#serial 13
Packit 437b5e
Packit 437b5e
AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
Packit 437b5e
AC_DEFUN([AX_WITH_CURSES], [
Packit 437b5e
    AC_ARG_VAR([CURSES_LIB], [linker library for Curses, e.g. -lcurses])
Packit 437b5e
    AC_ARG_WITH([ncurses], [AS_HELP_STRING([--with-ncurses],
Packit 437b5e
        [force the use of Ncurses or NcursesW])],
Packit 437b5e
        [], [with_ncurses=check])
Packit 437b5e
    AC_ARG_WITH([ncursesw], [AS_HELP_STRING([--without-ncursesw],
Packit 437b5e
        [do not use NcursesW (wide character support)])],
Packit 437b5e
        [], [with_ncursesw=check])
Packit 437b5e
Packit 437b5e
    ax_saved_LIBS=$LIBS
Packit 437b5e
    AS_IF([test "x$with_ncurses" = xyes || test "x$with_ncursesw" = xyes],
Packit 437b5e
        [ax_with_plaincurses=no], [ax_with_plaincurses=check])
Packit 437b5e
Packit 437b5e
    ax_cv_curses_which=no
Packit 437b5e
Packit 437b5e
    # Test for NcursesW
Packit 437b5e
Packit 437b5e
    AS_IF([test "x$CURSES_LIB" = x && test "x$with_ncursesw" != xno], [
Packit 437b5e
        LIBS="$ax_saved_LIBS -lncursesw"
Packit 437b5e
Packit 437b5e
        AC_CACHE_CHECK([for NcursesW wide-character library], [ax_cv_ncursesw], [
Packit 437b5e
            AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
Packit 437b5e
                [ax_cv_ncursesw=yes], [ax_cv_ncursesw=no])
Packit 437b5e
        ])
Packit 437b5e
        AS_IF([test "x$ax_cv_ncursesw" = xno && test "x$with_ncursesw" = xyes], [
Packit 437b5e
            AC_MSG_ERROR([--with-ncursesw specified but could not find NcursesW library])
Packit 437b5e
        ])
Packit 437b5e
Packit 437b5e
        AS_IF([test "x$ax_cv_ncursesw" = xyes], [
Packit 437b5e
            ax_cv_curses=yes
Packit 437b5e
            ax_cv_curses_which=ncursesw
Packit 437b5e
            CURSES_LIB="-lncursesw"
Packit 437b5e
            AC_DEFINE([HAVE_NCURSESW], [1], [Define to 1 if the NcursesW library is present])
Packit 437b5e
            AC_DEFINE([HAVE_CURSES],   [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
Packit 437b5e
Packit 437b5e
            AC_CACHE_CHECK([for working ncursesw/curses.h], [ax_cv_header_ncursesw_curses_h], [
Packit 437b5e
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                        @%:@define _XOPEN_SOURCE_EXTENDED 1
Packit 437b5e
                        @%:@include <ncursesw/curses.h>
Packit 437b5e
                    ]], [[
Packit 437b5e
                        chtype a = A_BOLD;
Packit 437b5e
                        int b = KEY_LEFT;
Packit 437b5e
                        chtype c = COLOR_PAIR(1) & A_COLOR;
Packit 437b5e
                        attr_t d = WA_NORMAL;
Packit 437b5e
                        cchar_t e;
Packit 437b5e
                        wint_t f;
Packit 437b5e
                        int g = getattrs(stdscr);
Packit 437b5e
                        int h = getcurx(stdscr) + getmaxx(stdscr);
Packit 437b5e
                        initscr();
Packit 437b5e
                        init_pair(1, COLOR_WHITE, COLOR_RED);
Packit 437b5e
                        wattr_set(stdscr, d, 0, NULL);
Packit 437b5e
                        wget_wch(stdscr, &f);
Packit 437b5e
                    ]])],
Packit 437b5e
                    [ax_cv_header_ncursesw_curses_h=yes],
Packit 437b5e
                    [ax_cv_header_ncursesw_curses_h=no])
Packit 437b5e
            ])
Packit 437b5e
            AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xyes], [
Packit 437b5e
                ax_cv_curses_enhanced=yes
Packit 437b5e
                ax_cv_curses_color=yes
Packit 437b5e
                ax_cv_curses_obsolete=yes
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_ENHANCED],   [1], [Define to 1 if library supports X/Open Enhanced functions])
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_COLOR],      [1], [Define to 1 if library supports color (enhanced functions)])
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_OBSOLETE],   [1], [Define to 1 if library supports certain obsolete features])
Packit 437b5e
                AC_DEFINE([HAVE_NCURSESW_CURSES_H], [1], [Define to 1 if <ncursesw/curses.h> is present])
Packit 437b5e
            ])
Packit 437b5e
Packit 437b5e
            AC_CACHE_CHECK([for working ncursesw.h], [ax_cv_header_ncursesw_h], [
Packit 437b5e
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                        @%:@define _XOPEN_SOURCE_EXTENDED 1
Packit 437b5e
                        @%:@include <ncursesw.h>
Packit 437b5e
                    ]], [[
Packit 437b5e
                        chtype a = A_BOLD;
Packit 437b5e
                        int b = KEY_LEFT;
Packit 437b5e
                        chtype c = COLOR_PAIR(1) & A_COLOR;
Packit 437b5e
                        attr_t d = WA_NORMAL;
Packit 437b5e
                        cchar_t e;
Packit 437b5e
                        wint_t f;
Packit 437b5e
                        int g = getattrs(stdscr);
Packit 437b5e
                        int h = getcurx(stdscr) + getmaxx(stdscr);
Packit 437b5e
                        initscr();
Packit 437b5e
                        init_pair(1, COLOR_WHITE, COLOR_RED);
Packit 437b5e
                        wattr_set(stdscr, d, 0, NULL);
Packit 437b5e
                        wget_wch(stdscr, &f);
Packit 437b5e
                    ]])],
Packit 437b5e
                    [ax_cv_header_ncursesw_h=yes],
Packit 437b5e
                    [ax_cv_header_ncursesw_h=no])
Packit 437b5e
            ])
Packit 437b5e
            AS_IF([test "x$ax_cv_header_ncursesw_h" = xyes], [
Packit 437b5e
                ax_cv_curses_enhanced=yes
Packit 437b5e
                ax_cv_curses_color=yes
Packit 437b5e
                ax_cv_curses_obsolete=yes
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
Packit 437b5e
                AC_DEFINE([HAVE_NCURSESW_H],      [1], [Define to 1 if <ncursesw.h> is present])
Packit 437b5e
            ])
Packit 437b5e
Packit 437b5e
            AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h_with_ncursesw], [
Packit 437b5e
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                        @%:@define _XOPEN_SOURCE_EXTENDED 1
Packit 437b5e
                        @%:@include <ncurses.h>
Packit 437b5e
                    ]], [[
Packit 437b5e
                        chtype a = A_BOLD;
Packit 437b5e
                        int b = KEY_LEFT;
Packit 437b5e
                        chtype c = COLOR_PAIR(1) & A_COLOR;
Packit 437b5e
                        attr_t d = WA_NORMAL;
Packit 437b5e
                        cchar_t e;
Packit 437b5e
                        wint_t f;
Packit 437b5e
                        int g = getattrs(stdscr);
Packit 437b5e
                        int h = getcurx(stdscr) + getmaxx(stdscr);
Packit 437b5e
                        initscr();
Packit 437b5e
                        init_pair(1, COLOR_WHITE, COLOR_RED);
Packit 437b5e
                        wattr_set(stdscr, d, 0, NULL);
Packit 437b5e
                        wget_wch(stdscr, &f);
Packit 437b5e
                    ]])],
Packit 437b5e
                    [ax_cv_header_ncurses_h_with_ncursesw=yes],
Packit 437b5e
                    [ax_cv_header_ncurses_h_with_ncursesw=no])
Packit 437b5e
            ])
Packit 437b5e
            AS_IF([test "x$ax_cv_header_ncurses_h_with_ncursesw" = xyes], [
Packit 437b5e
                ax_cv_curses_enhanced=yes
Packit 437b5e
                ax_cv_curses_color=yes
Packit 437b5e
                ax_cv_curses_obsolete=yes
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
Packit 437b5e
                AC_DEFINE([HAVE_NCURSES_H],       [1], [Define to 1 if <ncurses.h> is present])
Packit 437b5e
            ])
Packit 437b5e
Packit 437b5e
            AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xno && test "x$ax_cv_header_ncursesw_h" = xno && test "x$ax_cv_header_ncurses_h_with_ncursesw" = xno], [
Packit 437b5e
                AC_MSG_WARN([could not find a working ncursesw/curses.h, ncursesw.h or ncurses.h])
Packit 437b5e
            ])
Packit 437b5e
        ])
Packit 437b5e
    ])
Packit 437b5e
Packit 437b5e
    # Test for Ncurses
Packit 437b5e
Packit 437b5e
    AS_IF([test "x$CURSES_LIB" = x && test "x$with_ncurses" != xno && test "x$ax_cv_curses_which" = xno], [
Packit 437b5e
        LIBS="$ax_saved_LIBS -lncurses"
Packit 437b5e
Packit 437b5e
        AC_CACHE_CHECK([for Ncurses library], [ax_cv_ncurses], [
Packit 437b5e
            AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
Packit 437b5e
                [ax_cv_ncurses=yes], [ax_cv_ncurses=no])
Packit 437b5e
        ])
Packit 437b5e
        AS_IF([test "x$ax_cv_ncurses" = xno && test "x$with_ncurses" = xyes], [
Packit 437b5e
            AC_MSG_ERROR([--with-ncurses specified but could not find Ncurses library])
Packit 437b5e
        ])
Packit 437b5e
Packit 437b5e
        AS_IF([test "x$ax_cv_ncurses" = xyes], [
Packit 437b5e
            ax_cv_curses=yes
Packit 437b5e
            ax_cv_curses_which=ncurses
Packit 437b5e
            CURSES_LIB="-lncurses"
Packit 437b5e
            AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if the Ncurses library is present])
Packit 437b5e
            AC_DEFINE([HAVE_CURSES],  [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
Packit 437b5e
Packit 437b5e
            AC_CACHE_CHECK([for working ncurses/curses.h], [ax_cv_header_ncurses_curses_h], [
Packit 437b5e
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                        @%:@include <ncurses/curses.h>
Packit 437b5e
                    ]], [[
Packit 437b5e
                        chtype a = A_BOLD;
Packit 437b5e
                        int b = KEY_LEFT;
Packit 437b5e
                        chtype c = COLOR_PAIR(1) & A_COLOR;
Packit 437b5e
                        int g = getattrs(stdscr);
Packit 437b5e
                        int h = getcurx(stdscr) + getmaxx(stdscr);
Packit 437b5e
                        initscr();
Packit 437b5e
                        init_pair(1, COLOR_WHITE, COLOR_RED);
Packit 437b5e
                    ]])],
Packit 437b5e
                    [ax_cv_header_ncurses_curses_h=yes],
Packit 437b5e
                    [ax_cv_header_ncurses_curses_h=no])
Packit 437b5e
            ])
Packit 437b5e
            AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xyes], [
Packit 437b5e
                ax_cv_curses_color=yes
Packit 437b5e
                ax_cv_curses_obsolete=yes
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_COLOR],     [1], [Define to 1 if library supports color (enhanced functions)])
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_OBSOLETE],  [1], [Define to 1 if library supports certain obsolete features])
Packit 437b5e
                AC_DEFINE([HAVE_NCURSES_CURSES_H], [1], [Define to 1 if <ncurses/curses.h> is present])
Packit 437b5e
            ])
Packit 437b5e
Packit 437b5e
            AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h], [
Packit 437b5e
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                        @%:@include <ncurses.h>
Packit 437b5e
                    ]], [[
Packit 437b5e
                        chtype a = A_BOLD;
Packit 437b5e
                        int b = KEY_LEFT;
Packit 437b5e
                        chtype c = COLOR_PAIR(1) & A_COLOR;
Packit 437b5e
                        int g = getattrs(stdscr);
Packit 437b5e
                        int h = getcurx(stdscr) + getmaxx(stdscr);
Packit 437b5e
                        initscr();
Packit 437b5e
                        init_pair(1, COLOR_WHITE, COLOR_RED);
Packit 437b5e
                    ]])],
Packit 437b5e
                    [ax_cv_header_ncurses_h=yes],
Packit 437b5e
                    [ax_cv_header_ncurses_h=no])
Packit 437b5e
            ])
Packit 437b5e
            AS_IF([test "x$ax_cv_header_ncurses_h" = xyes], [
Packit 437b5e
                ax_cv_curses_color=yes
Packit 437b5e
                ax_cv_curses_obsolete=yes
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
Packit 437b5e
                AC_DEFINE([HAVE_NCURSES_H],       [1], [Define to 1 if <ncurses.h> is present])
Packit 437b5e
            ])
Packit 437b5e
Packit 437b5e
            AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xno && test "x$ax_cv_header_ncurses_h" = xno], [
Packit 437b5e
                AC_MSG_WARN([could not find a working ncurses/curses.h or ncurses.h])
Packit 437b5e
            ])
Packit 437b5e
        ])
Packit 437b5e
    ])
Packit 437b5e
Packit 437b5e
    # Test for plain Curses (or if CURSES_LIB was set by user)
Packit 437b5e
Packit 437b5e
    AS_IF([test "x$with_plaincurses" != xno && test "x$ax_cv_curses_which" = xno], [
Packit 437b5e
        AS_IF([test "x$CURSES_LIB" != x], [
Packit 437b5e
            LIBS="$ax_saved_LIBS $CURSES_LIB"
Packit 437b5e
        ], [
Packit 437b5e
            LIBS="$ax_saved_LIBS -lcurses"
Packit 437b5e
        ])
Packit 437b5e
Packit 437b5e
        AC_CACHE_CHECK([for Curses library], [ax_cv_plaincurses], [
Packit 437b5e
            AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
Packit 437b5e
                [ax_cv_plaincurses=yes], [ax_cv_plaincurses=no])
Packit 437b5e
        ])
Packit 437b5e
Packit 437b5e
        AS_IF([test "x$ax_cv_plaincurses" = xyes], [
Packit 437b5e
            ax_cv_curses=yes
Packit 437b5e
            ax_cv_curses_which=plaincurses
Packit 437b5e
            AS_IF([test "x$CURSES_LIB" = x], [
Packit 437b5e
                CURSES_LIB="-lcurses"
Packit 437b5e
            ])
Packit 437b5e
            AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
Packit 437b5e
Packit 437b5e
            # Check for base conformance (and header file)
Packit 437b5e
Packit 437b5e
            AC_CACHE_CHECK([for working curses.h], [ax_cv_header_curses_h], [
Packit 437b5e
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                        @%:@include <curses.h>
Packit 437b5e
                    ]], [[
Packit 437b5e
                        chtype a = A_BOLD;
Packit 437b5e
                        int b = KEY_LEFT;
Packit 437b5e
                        initscr();
Packit 437b5e
                    ]])],
Packit 437b5e
                    [ax_cv_header_curses_h=yes],
Packit 437b5e
                    [ax_cv_header_curses_h=no])
Packit 437b5e
            ])
Packit 437b5e
            AS_IF([test "x$ax_cv_header_curses_h" = xyes], [
Packit 437b5e
                AC_DEFINE([HAVE_CURSES_H], [1], [Define to 1 if <curses.h> is present])
Packit 437b5e
Packit 437b5e
                # Check for X/Open Enhanced conformance
Packit 437b5e
Packit 437b5e
                AC_CACHE_CHECK([for X/Open Enhanced Curses conformance], [ax_cv_plaincurses_enhanced], [
Packit 437b5e
                    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                            @%:@define _XOPEN_SOURCE_EXTENDED 1
Packit 437b5e
                            @%:@include <curses.h>
Packit 437b5e
                            @%:@ifndef _XOPEN_CURSES
Packit 437b5e
                            @%:@error "this Curses library is not enhanced"
Packit 437b5e
                            "this Curses library is not enhanced"
Packit 437b5e
                            @%:@endif
Packit 437b5e
                        ]], [[
Packit 437b5e
                            chtype a = A_BOLD;
Packit 437b5e
                            int b = KEY_LEFT;
Packit 437b5e
                            chtype c = COLOR_PAIR(1) & A_COLOR;
Packit 437b5e
                            attr_t d = WA_NORMAL;
Packit 437b5e
                            cchar_t e;
Packit 437b5e
                            wint_t f;
Packit 437b5e
                            initscr();
Packit 437b5e
                            init_pair(1, COLOR_WHITE, COLOR_RED);
Packit 437b5e
                            wattr_set(stdscr, d, 0, NULL);
Packit 437b5e
                            wget_wch(stdscr, &f);
Packit 437b5e
                        ]])],
Packit 437b5e
                        [ax_cv_plaincurses_enhanced=yes],
Packit 437b5e
                        [ax_cv_plaincurses_enhanced=no])
Packit 437b5e
                ])
Packit 437b5e
                AS_IF([test "x$ax_cv_plaincurses_enhanced" = xyes], [
Packit 437b5e
                    ax_cv_curses_enhanced=yes
Packit 437b5e
                    ax_cv_curses_color=yes
Packit 437b5e
                    AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
Packit 437b5e
                    AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
Packit 437b5e
                ])
Packit 437b5e
Packit 437b5e
                # Check for color functions
Packit 437b5e
Packit 437b5e
                AC_CACHE_CHECK([for Curses color functions], [ax_cv_plaincurses_color], [
Packit 437b5e
                    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                        @%:@define _XOPEN_SOURCE_EXTENDED 1
Packit 437b5e
                        @%:@include <curses.h>
Packit 437b5e
                        ]], [[
Packit 437b5e
                            chtype a = A_BOLD;
Packit 437b5e
                            int b = KEY_LEFT;
Packit 437b5e
                            chtype c = COLOR_PAIR(1) & A_COLOR;
Packit 437b5e
                            initscr();
Packit 437b5e
                            init_pair(1, COLOR_WHITE, COLOR_RED);
Packit 437b5e
                        ]])],
Packit 437b5e
                        [ax_cv_plaincurses_color=yes],
Packit 437b5e
                        [ax_cv_plaincurses_color=no])
Packit 437b5e
                ])
Packit 437b5e
                AS_IF([test "x$ax_cv_plaincurses_color" = xyes], [
Packit 437b5e
                    ax_cv_curses_color=yes
Packit 437b5e
                    AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
Packit 437b5e
                ])
Packit 437b5e
Packit 437b5e
                # Check for obsolete functions
Packit 437b5e
Packit 437b5e
                AC_CACHE_CHECK([for obsolete Curses functions], [ax_cv_plaincurses_obsolete], [
Packit 437b5e
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[
Packit 437b5e
                        @%:@include <curses.h>
Packit 437b5e
                    ]], [[
Packit 437b5e
                        chtype a = A_BOLD;
Packit 437b5e
                        int b = KEY_LEFT;
Packit 437b5e
                        int g = getattrs(stdscr);
Packit 437b5e
                        int h = getcurx(stdscr) + getmaxx(stdscr);
Packit 437b5e
                        initscr();
Packit 437b5e
                    ]])],
Packit 437b5e
                    [ax_cv_plaincurses_obsolete=yes],
Packit 437b5e
                    [ax_cv_plaincurses_obsolete=no])
Packit 437b5e
                ])
Packit 437b5e
                AS_IF([test "x$ax_cv_plaincurses_obsolete" = xyes], [
Packit 437b5e
                    ax_cv_curses_obsolete=yes
Packit 437b5e
                    AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
Packit 437b5e
                ])
Packit 437b5e
            ])
Packit 437b5e
Packit 437b5e
            AS_IF([test "x$ax_cv_header_curses_h" = xno], [
Packit 437b5e
                AC_MSG_WARN([could not find a working curses.h])
Packit 437b5e
            ])
Packit 437b5e
        ])
Packit 437b5e
    ])
Packit 437b5e
Packit 437b5e
    AS_IF([test "x$ax_cv_curses"          != xyes], [ax_cv_curses=no])
Packit 437b5e
    AS_IF([test "x$ax_cv_curses_enhanced" != xyes], [ax_cv_curses_enhanced=no])
Packit 437b5e
    AS_IF([test "x$ax_cv_curses_color"    != xyes], [ax_cv_curses_color=no])
Packit 437b5e
    AS_IF([test "x$ax_cv_curses_obsolete" != xyes], [ax_cv_curses_obsolete=no])
Packit 437b5e
Packit 437b5e
    LIBS=$ax_saved_LIBS
Packit 437b5e
])dnl