Annotation of embedaddon/bmon/m4/ax_with_curses.m4, revision 1.1.1.1

1.1       misho       1: # ===========================================================================
                      2: #      http://www.gnu.org/software/autoconf-archive/ax_with_curses.html
                      3: # ===========================================================================
                      4: #
                      5: # SYNOPSIS
                      6: #
                      7: #   AX_WITH_CURSES
                      8: #
                      9: # DESCRIPTION
                     10: #
                     11: #   This macro checks whether a SysV or X/Open-compatible Curses library is
                     12: #   present, along with the associated header file.  The NcursesW
                     13: #   (wide-character) library is searched for first, followed by Ncurses,
                     14: #   then the system-default plain Curses.  The first library found is the
                     15: #   one returned.
                     16: #
                     17: #   The following options are understood: --with-ncursesw, --with-ncurses,
                     18: #   --without-ncursesw, --without-ncurses.  The "--with" options force the
                     19: #   macro to use that particular library, terminating with an error if not
                     20: #   found.  The "--without" options simply skip the check for that library.
                     21: #   The effect on the search pattern is:
                     22: #
                     23: #     (no options)                           - NcursesW, Ncurses, Curses
                     24: #     --with-ncurses     --with-ncursesw     - NcursesW only [*]
                     25: #     --without-ncurses  --with-ncursesw     - NcursesW only [*]
                     26: #                        --with-ncursesw     - NcursesW only [*]
                     27: #     --with-ncurses     --without-ncursesw  - Ncurses only [*]
                     28: #     --with-ncurses                         - NcursesW, Ncurses [**]
                     29: #     --without-ncurses  --without-ncursesw  - Curses only
                     30: #                        --without-ncursesw  - Ncurses, Curses
                     31: #     --without-ncurses                      - NcursesW, Curses
                     32: #
                     33: #   [*]  If the library is not found, abort the configure script.
                     34: #
                     35: #   [**] If the second library (Ncurses) is not found, abort configure.
                     36: #
                     37: #   The following preprocessor symbols may be defined by this macro if the
                     38: #   appropriate conditions are met:
                     39: #
                     40: #     HAVE_CURSES             - if any SysV or X/Open Curses library found
                     41: #     HAVE_CURSES_ENHANCED    - if library supports X/Open Enhanced functions
                     42: #     HAVE_CURSES_COLOR       - if library supports color (enhanced functions)
                     43: #     HAVE_CURSES_OBSOLETE    - if library supports certain obsolete features
                     44: #     HAVE_NCURSESW           - if NcursesW (wide char) library is to be used
                     45: #     HAVE_NCURSES            - if the Ncurses library is to be used
                     46: #
                     47: #     HAVE_CURSES_H           - if <curses.h> is present and should be used
                     48: #     HAVE_NCURSESW_H         - if <ncursesw.h> should be used
                     49: #     HAVE_NCURSES_H          - if <ncurses.h> should be used
                     50: #     HAVE_NCURSESW_CURSES_H  - if <ncursesw/curses.h> should be used
                     51: #     HAVE_NCURSES_CURSES_H   - if <ncurses/curses.h> should be used
                     52: #
                     53: #   (These preprocessor symbols are discussed later in this document.)
                     54: #
                     55: #   The following output variable is defined by this macro; it is precious
                     56: #   and may be overridden on the ./configure command line:
                     57: #
                     58: #     CURSES_LIB  - library to add to xxx_LDADD
                     59: #
                     60: #   The library listed in CURSES_LIB is NOT added to LIBS by default. You
                     61: #   need to add CURSES_LIB to the appropriate xxx_LDADD line in your
                     62: #   Makefile.am.  For example:
                     63: #
                     64: #     prog_LDADD = @CURSES_LIB@
                     65: #
                     66: #   If CURSES_LIB is set on the configure command line (such as by running
                     67: #   "./configure CURSES_LIB=-lmycurses"), then the only header searched for
                     68: #   is <curses.h>.  The user may use the CPPFLAGS precious variable to
                     69: #   override the standard #include search path.  If the user needs to
                     70: #   specify an alternative path for a library (such as for a non-standard
                     71: #   NcurseW), the user should use the LDFLAGS variable.
                     72: #
                     73: #   The following shell variables may be defined by this macro:
                     74: #
                     75: #     ax_cv_curses           - set to "yes" if any Curses library found
                     76: #     ax_cv_curses_enhanced  - set to "yes" if Enhanced functions present
                     77: #     ax_cv_curses_color     - set to "yes" if color functions present
                     78: #     ax_cv_curses_obsolete  - set to "yes" if obsolete features present
                     79: #
                     80: #     ax_cv_ncursesw      - set to "yes" if NcursesW library found
                     81: #     ax_cv_ncurses       - set to "yes" if Ncurses library found
                     82: #     ax_cv_plaincurses   - set to "yes" if plain Curses library found
                     83: #     ax_cv_curses_which  - set to "ncursesw", "ncurses", "plaincurses" or "no"
                     84: #
                     85: #   These variables can be used in your configure.ac to determine the level
                     86: #   of support you need from the Curses library.  For example, if you must
                     87: #   have either Ncurses or NcursesW, you could include:
                     88: #
                     89: #     AX_WITH_CURSES
                     90: #     if test "x$ax_cv_ncursesw" != xyes && test "x$ax_cv_ncurses" != xyes; then
                     91: #         AX_MSG_ERROR([requires either NcursesW or Ncurses library])
                     92: #     fi
                     93: #
                     94: #   If any Curses library will do (but one must be present and must support
                     95: #   color), you could use:
                     96: #
                     97: #     AX_WITH_CURSES
                     98: #     if test "x$ax_cv_curses" != xyes || test "x$ax_cv_curses_color" != xyes; then
                     99: #         AC_MSG_ERROR([requires an X/Open-compatible Curses library with color])
                    100: #     fi
                    101: #
                    102: #   Certain preprocessor symbols and shell variables defined by this macro
                    103: #   can be used to determine various features of the Curses library.  In
                    104: #   particular, HAVE_CURSES and ax_cv_curses are defined if the Curses
                    105: #   library found conforms to the traditional SysV and/or X/Open Base Curses
                    106: #   definition.  Any working Curses library conforms to this level.
                    107: #
                    108: #   HAVE_CURSES_ENHANCED and ax_cv_curses_enhanced are defined if the
                    109: #   library supports the X/Open Enhanced Curses definition.  In particular,
                    110: #   the wide-character types attr_t, cchar_t and wint_t, the functions
                    111: #   wattr_set() and wget_wch() and the macros WA_NORMAL and _XOPEN_CURSES
                    112: #   are checked.  The Ncurses library does NOT conform to this definition,
                    113: #   although NcursesW does.
                    114: #
                    115: #   HAVE_CURSES_COLOR and ax_cv_curses_color are defined if the library
                    116: #   supports color functions and macros such as COLOR_PAIR, A_COLOR,
                    117: #   COLOR_WHITE, COLOR_RED and init_pair().  These are NOT part of the
                    118: #   X/Open Base Curses definition, but are part of the Enhanced set of
                    119: #   functions.  The Ncurses library DOES support these functions, as does
                    120: #   NcursesW.
                    121: #
                    122: #   HAVE_CURSES_OBSOLETE and ax_cv_curses_obsolete are defined if the
                    123: #   library supports certain features present in SysV and BSD Curses but not
                    124: #   defined in the X/Open definition.  In particular, the functions
                    125: #   getattrs(), getcurx() and getmaxx() are checked.
                    126: #
                    127: #   To use the HAVE_xxx_H preprocessor symbols, insert the following into
                    128: #   your system.h (or equivalent) header file:
                    129: #
                    130: #     #if defined HAVE_NCURSESW_CURSES_H
                    131: #     #  include <ncursesw/curses.h>
                    132: #     #elif defined HAVE_NCURSESW_H
                    133: #     #  include <ncursesw.h>
                    134: #     #elif defined HAVE_NCURSES_CURSES_H
                    135: #     #  include <ncurses/curses.h>
                    136: #     #elif defined HAVE_NCURSES_H
                    137: #     #  include <ncurses.h>
                    138: #     #elif defined HAVE_CURSES_H
                    139: #     #  include <curses.h>
                    140: #     #else
                    141: #     #  error "SysV or X/Open-compatible Curses header file required"
                    142: #     #endif
                    143: #
                    144: #   For previous users of this macro: you should not need to change anything
                    145: #   in your configure.ac or Makefile.am, as the previous (serial 10)
                    146: #   semantics are still valid.  However, you should update your system.h (or
                    147: #   equivalent) header file to the fragment shown above. You are encouraged
                    148: #   also to make use of the extended functionality provided by this version
                    149: #   of AX_WITH_CURSES, as well as in the additional macros
                    150: #   AX_WITH_CURSES_PANEL, AX_WITH_CURSES_MENU and AX_WITH_CURSES_FORM.
                    151: #
                    152: # LICENSE
                    153: #
                    154: #   Copyright (c) 2009 Mark Pulford <mark@kyne.com.au>
                    155: #   Copyright (c) 2009 Damian Pietras <daper@daper.net>
                    156: #   Copyright (c) 2012 Reuben Thomas <rrt@sc3d.org>
                    157: #   Copyright (c) 2011 John Zaitseff <J.Zaitseff@zap.org.au>
                    158: #
                    159: #   This program is free software: you can redistribute it and/or modify it
                    160: #   under the terms of the GNU General Public License as published by the
                    161: #   Free Software Foundation, either version 3 of the License, or (at your
                    162: #   option) any later version.
                    163: #
                    164: #   This program is distributed in the hope that it will be useful, but
                    165: #   WITHOUT ANY WARRANTY; without even the implied warranty of
                    166: #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
                    167: #   Public License for more details.
                    168: #
                    169: #   You should have received a copy of the GNU General Public License along
                    170: #   with this program. If not, see <http://www.gnu.org/licenses/>.
                    171: #
                    172: #   As a special exception, the respective Autoconf Macro's copyright owner
                    173: #   gives unlimited permission to copy, distribute and modify the configure
                    174: #   scripts that are the output of Autoconf when processing the Macro. You
                    175: #   need not follow the terms of the GNU General Public License when using
                    176: #   or distributing such scripts, even though portions of the text of the
                    177: #   Macro appear in them. The GNU General Public License (GPL) does govern
                    178: #   all other use of the material that constitutes the Autoconf Macro.
                    179: #
                    180: #   This special exception to the GPL applies to versions of the Autoconf
                    181: #   Macro released by the Autoconf Archive. When you make and distribute a
                    182: #   modified version of the Autoconf Macro, you may extend this special
                    183: #   exception to the GPL to apply to your modified version as well.
                    184: 
                    185: #serial 13
                    186: 
                    187: AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
                    188: AC_DEFUN([AX_WITH_CURSES], [
                    189:     AC_ARG_VAR([CURSES_LIB], [linker library for Curses, e.g. -lcurses])
                    190:     AC_ARG_WITH([ncurses], [AS_HELP_STRING([--with-ncurses],
                    191:         [force the use of Ncurses or NcursesW])],
                    192:         [], [with_ncurses=check])
                    193:     AC_ARG_WITH([ncursesw], [AS_HELP_STRING([--without-ncursesw],
                    194:         [do not use NcursesW (wide character support)])],
                    195:         [], [with_ncursesw=check])
                    196: 
                    197:     ax_saved_LIBS=$LIBS
                    198:     AS_IF([test "x$with_ncurses" = xyes || test "x$with_ncursesw" = xyes],
                    199:         [ax_with_plaincurses=no], [ax_with_plaincurses=check])
                    200: 
                    201:     ax_cv_curses_which=no
                    202: 
                    203:     # Test for NcursesW
                    204: 
                    205:     AS_IF([test "x$CURSES_LIB" = x && test "x$with_ncursesw" != xno], [
                    206:         LIBS="$ax_saved_LIBS -lncursesw"
                    207: 
                    208:         AC_CACHE_CHECK([for NcursesW wide-character library], [ax_cv_ncursesw], [
                    209:             AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
                    210:                 [ax_cv_ncursesw=yes], [ax_cv_ncursesw=no])
                    211:         ])
                    212:         AS_IF([test "x$ax_cv_ncursesw" = xno && test "x$with_ncursesw" = xyes], [
                    213:             AC_MSG_ERROR([--with-ncursesw specified but could not find NcursesW library])
                    214:         ])
                    215: 
                    216:         AS_IF([test "x$ax_cv_ncursesw" = xyes], [
                    217:             ax_cv_curses=yes
                    218:             ax_cv_curses_which=ncursesw
                    219:             CURSES_LIB="-lncursesw"
                    220:             AC_DEFINE([HAVE_NCURSESW], [1], [Define to 1 if the NcursesW library is present])
                    221:             AC_DEFINE([HAVE_CURSES],   [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
                    222: 
                    223:             AC_CACHE_CHECK([for working ncursesw/curses.h], [ax_cv_header_ncursesw_curses_h], [
                    224:                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    225:                         @%:@define _XOPEN_SOURCE_EXTENDED 1
                    226:                         @%:@include <ncursesw/curses.h>
                    227:                     ]], [[
                    228:                         chtype a = A_BOLD;
                    229:                         int b = KEY_LEFT;
                    230:                         chtype c = COLOR_PAIR(1) & A_COLOR;
                    231:                         attr_t d = WA_NORMAL;
                    232:                         cchar_t e;
                    233:                         wint_t f;
                    234:                         int g = getattrs(stdscr);
                    235:                         int h = getcurx(stdscr) + getmaxx(stdscr);
                    236:                         initscr();
                    237:                         init_pair(1, COLOR_WHITE, COLOR_RED);
                    238:                         wattr_set(stdscr, d, 0, NULL);
                    239:                         wget_wch(stdscr, &f);
                    240:                     ]])],
                    241:                     [ax_cv_header_ncursesw_curses_h=yes],
                    242:                     [ax_cv_header_ncursesw_curses_h=no])
                    243:             ])
                    244:             AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xyes], [
                    245:                 ax_cv_curses_enhanced=yes
                    246:                 ax_cv_curses_color=yes
                    247:                 ax_cv_curses_obsolete=yes
                    248:                 AC_DEFINE([HAVE_CURSES_ENHANCED],   [1], [Define to 1 if library supports X/Open Enhanced functions])
                    249:                 AC_DEFINE([HAVE_CURSES_COLOR],      [1], [Define to 1 if library supports color (enhanced functions)])
                    250:                 AC_DEFINE([HAVE_CURSES_OBSOLETE],   [1], [Define to 1 if library supports certain obsolete features])
                    251:                 AC_DEFINE([HAVE_NCURSESW_CURSES_H], [1], [Define to 1 if <ncursesw/curses.h> is present])
                    252:             ])
                    253: 
                    254:             AC_CACHE_CHECK([for working ncursesw.h], [ax_cv_header_ncursesw_h], [
                    255:                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    256:                         @%:@define _XOPEN_SOURCE_EXTENDED 1
                    257:                         @%:@include <ncursesw.h>
                    258:                     ]], [[
                    259:                         chtype a = A_BOLD;
                    260:                         int b = KEY_LEFT;
                    261:                         chtype c = COLOR_PAIR(1) & A_COLOR;
                    262:                         attr_t d = WA_NORMAL;
                    263:                         cchar_t e;
                    264:                         wint_t f;
                    265:                         int g = getattrs(stdscr);
                    266:                         int h = getcurx(stdscr) + getmaxx(stdscr);
                    267:                         initscr();
                    268:                         init_pair(1, COLOR_WHITE, COLOR_RED);
                    269:                         wattr_set(stdscr, d, 0, NULL);
                    270:                         wget_wch(stdscr, &f);
                    271:                     ]])],
                    272:                     [ax_cv_header_ncursesw_h=yes],
                    273:                     [ax_cv_header_ncursesw_h=no])
                    274:             ])
                    275:             AS_IF([test "x$ax_cv_header_ncursesw_h" = xyes], [
                    276:                 ax_cv_curses_enhanced=yes
                    277:                 ax_cv_curses_color=yes
                    278:                 ax_cv_curses_obsolete=yes
                    279:                 AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
                    280:                 AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
                    281:                 AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
                    282:                 AC_DEFINE([HAVE_NCURSESW_H],      [1], [Define to 1 if <ncursesw.h> is present])
                    283:             ])
                    284: 
                    285:             AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h_with_ncursesw], [
                    286:                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    287:                         @%:@define _XOPEN_SOURCE_EXTENDED 1
                    288:                         @%:@include <ncurses.h>
                    289:                     ]], [[
                    290:                         chtype a = A_BOLD;
                    291:                         int b = KEY_LEFT;
                    292:                         chtype c = COLOR_PAIR(1) & A_COLOR;
                    293:                         attr_t d = WA_NORMAL;
                    294:                         cchar_t e;
                    295:                         wint_t f;
                    296:                         int g = getattrs(stdscr);
                    297:                         int h = getcurx(stdscr) + getmaxx(stdscr);
                    298:                         initscr();
                    299:                         init_pair(1, COLOR_WHITE, COLOR_RED);
                    300:                         wattr_set(stdscr, d, 0, NULL);
                    301:                         wget_wch(stdscr, &f);
                    302:                     ]])],
                    303:                     [ax_cv_header_ncurses_h_with_ncursesw=yes],
                    304:                     [ax_cv_header_ncurses_h_with_ncursesw=no])
                    305:             ])
                    306:             AS_IF([test "x$ax_cv_header_ncurses_h_with_ncursesw" = xyes], [
                    307:                 ax_cv_curses_enhanced=yes
                    308:                 ax_cv_curses_color=yes
                    309:                 ax_cv_curses_obsolete=yes
                    310:                 AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
                    311:                 AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
                    312:                 AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
                    313:                 AC_DEFINE([HAVE_NCURSES_H],       [1], [Define to 1 if <ncurses.h> is present])
                    314:             ])
                    315: 
                    316:             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], [
                    317:                 AC_MSG_WARN([could not find a working ncursesw/curses.h, ncursesw.h or ncurses.h])
                    318:             ])
                    319:         ])
                    320:     ])
                    321: 
                    322:     # Test for Ncurses
                    323: 
                    324:     AS_IF([test "x$CURSES_LIB" = x && test "x$with_ncurses" != xno && test "x$ax_cv_curses_which" = xno], [
                    325:         LIBS="$ax_saved_LIBS -lncurses"
                    326: 
                    327:         AC_CACHE_CHECK([for Ncurses library], [ax_cv_ncurses], [
                    328:             AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
                    329:                 [ax_cv_ncurses=yes], [ax_cv_ncurses=no])
                    330:         ])
                    331:         AS_IF([test "x$ax_cv_ncurses" = xno && test "x$with_ncurses" = xyes], [
                    332:             AC_MSG_ERROR([--with-ncurses specified but could not find Ncurses library])
                    333:         ])
                    334: 
                    335:         AS_IF([test "x$ax_cv_ncurses" = xyes], [
                    336:             ax_cv_curses=yes
                    337:             ax_cv_curses_which=ncurses
                    338:             CURSES_LIB="-lncurses"
                    339:             AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if the Ncurses library is present])
                    340:             AC_DEFINE([HAVE_CURSES],  [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
                    341: 
                    342:             AC_CACHE_CHECK([for working ncurses/curses.h], [ax_cv_header_ncurses_curses_h], [
                    343:                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    344:                         @%:@include <ncurses/curses.h>
                    345:                     ]], [[
                    346:                         chtype a = A_BOLD;
                    347:                         int b = KEY_LEFT;
                    348:                         chtype c = COLOR_PAIR(1) & A_COLOR;
                    349:                         int g = getattrs(stdscr);
                    350:                         int h = getcurx(stdscr) + getmaxx(stdscr);
                    351:                         initscr();
                    352:                         init_pair(1, COLOR_WHITE, COLOR_RED);
                    353:                     ]])],
                    354:                     [ax_cv_header_ncurses_curses_h=yes],
                    355:                     [ax_cv_header_ncurses_curses_h=no])
                    356:             ])
                    357:             AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xyes], [
                    358:                 ax_cv_curses_color=yes
                    359:                 ax_cv_curses_obsolete=yes
                    360:                 AC_DEFINE([HAVE_CURSES_COLOR],     [1], [Define to 1 if library supports color (enhanced functions)])
                    361:                 AC_DEFINE([HAVE_CURSES_OBSOLETE],  [1], [Define to 1 if library supports certain obsolete features])
                    362:                 AC_DEFINE([HAVE_NCURSES_CURSES_H], [1], [Define to 1 if <ncurses/curses.h> is present])
                    363:             ])
                    364: 
                    365:             AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h], [
                    366:                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    367:                         @%:@include <ncurses.h>
                    368:                     ]], [[
                    369:                         chtype a = A_BOLD;
                    370:                         int b = KEY_LEFT;
                    371:                         chtype c = COLOR_PAIR(1) & A_COLOR;
                    372:                         int g = getattrs(stdscr);
                    373:                         int h = getcurx(stdscr) + getmaxx(stdscr);
                    374:                         initscr();
                    375:                         init_pair(1, COLOR_WHITE, COLOR_RED);
                    376:                     ]])],
                    377:                     [ax_cv_header_ncurses_h=yes],
                    378:                     [ax_cv_header_ncurses_h=no])
                    379:             ])
                    380:             AS_IF([test "x$ax_cv_header_ncurses_h" = xyes], [
                    381:                 ax_cv_curses_color=yes
                    382:                 ax_cv_curses_obsolete=yes
                    383:                 AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
                    384:                 AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
                    385:                 AC_DEFINE([HAVE_NCURSES_H],       [1], [Define to 1 if <ncurses.h> is present])
                    386:             ])
                    387: 
                    388:             AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xno && test "x$ax_cv_header_ncurses_h" = xno], [
                    389:                 AC_MSG_WARN([could not find a working ncurses/curses.h or ncurses.h])
                    390:             ])
                    391:         ])
                    392:     ])
                    393: 
                    394:     # Test for plain Curses (or if CURSES_LIB was set by user)
                    395: 
                    396:     AS_IF([test "x$with_plaincurses" != xno && test "x$ax_cv_curses_which" = xno], [
                    397:         AS_IF([test "x$CURSES_LIB" != x], [
                    398:             LIBS="$ax_saved_LIBS $CURSES_LIB"
                    399:         ], [
                    400:             LIBS="$ax_saved_LIBS -lcurses"
                    401:         ])
                    402: 
                    403:         AC_CACHE_CHECK([for Curses library], [ax_cv_plaincurses], [
                    404:             AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
                    405:                 [ax_cv_plaincurses=yes], [ax_cv_plaincurses=no])
                    406:         ])
                    407: 
                    408:         AS_IF([test "x$ax_cv_plaincurses" = xyes], [
                    409:             ax_cv_curses=yes
                    410:             ax_cv_curses_which=plaincurses
                    411:             AS_IF([test "x$CURSES_LIB" = x], [
                    412:                 CURSES_LIB="-lcurses"
                    413:             ])
                    414:             AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
                    415: 
                    416:             # Check for base conformance (and header file)
                    417: 
                    418:             AC_CACHE_CHECK([for working curses.h], [ax_cv_header_curses_h], [
                    419:                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    420:                         @%:@include <curses.h>
                    421:                     ]], [[
                    422:                         chtype a = A_BOLD;
                    423:                         int b = KEY_LEFT;
                    424:                         initscr();
                    425:                     ]])],
                    426:                     [ax_cv_header_curses_h=yes],
                    427:                     [ax_cv_header_curses_h=no])
                    428:             ])
                    429:             AS_IF([test "x$ax_cv_header_curses_h" = xyes], [
                    430:                 AC_DEFINE([HAVE_CURSES_H], [1], [Define to 1 if <curses.h> is present])
                    431: 
                    432:                 # Check for X/Open Enhanced conformance
                    433: 
                    434:                 AC_CACHE_CHECK([for X/Open Enhanced Curses conformance], [ax_cv_plaincurses_enhanced], [
                    435:                     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    436:                             @%:@define _XOPEN_SOURCE_EXTENDED 1
                    437:                             @%:@include <curses.h>
                    438:                             @%:@ifndef _XOPEN_CURSES
                    439:                             @%:@error "this Curses library is not enhanced"
                    440:                             "this Curses library is not enhanced"
                    441:                             @%:@endif
                    442:                         ]], [[
                    443:                             chtype a = A_BOLD;
                    444:                             int b = KEY_LEFT;
                    445:                             chtype c = COLOR_PAIR(1) & A_COLOR;
                    446:                             attr_t d = WA_NORMAL;
                    447:                             cchar_t e;
                    448:                             wint_t f;
                    449:                             initscr();
                    450:                             init_pair(1, COLOR_WHITE, COLOR_RED);
                    451:                             wattr_set(stdscr, d, 0, NULL);
                    452:                             wget_wch(stdscr, &f);
                    453:                         ]])],
                    454:                         [ax_cv_plaincurses_enhanced=yes],
                    455:                         [ax_cv_plaincurses_enhanced=no])
                    456:                 ])
                    457:                 AS_IF([test "x$ax_cv_plaincurses_enhanced" = xyes], [
                    458:                     ax_cv_curses_enhanced=yes
                    459:                     ax_cv_curses_color=yes
                    460:                     AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
                    461:                     AC_DEFINE([HAVE_CURSES_COLOR],    [1], [Define to 1 if library supports color (enhanced functions)])
                    462:                 ])
                    463: 
                    464:                 # Check for color functions
                    465: 
                    466:                 AC_CACHE_CHECK([for Curses color functions], [ax_cv_plaincurses_color], [
                    467:                     AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    468:                         @%:@define _XOPEN_SOURCE_EXTENDED 1
                    469:                         @%:@include <curses.h>
                    470:                         ]], [[
                    471:                             chtype a = A_BOLD;
                    472:                             int b = KEY_LEFT;
                    473:                             chtype c = COLOR_PAIR(1) & A_COLOR;
                    474:                             initscr();
                    475:                             init_pair(1, COLOR_WHITE, COLOR_RED);
                    476:                         ]])],
                    477:                         [ax_cv_plaincurses_color=yes],
                    478:                         [ax_cv_plaincurses_color=no])
                    479:                 ])
                    480:                 AS_IF([test "x$ax_cv_plaincurses_color" = xyes], [
                    481:                     ax_cv_curses_color=yes
                    482:                     AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
                    483:                 ])
                    484: 
                    485:                 # Check for obsolete functions
                    486: 
                    487:                 AC_CACHE_CHECK([for obsolete Curses functions], [ax_cv_plaincurses_obsolete], [
                    488:                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                    489:                         @%:@include <curses.h>
                    490:                     ]], [[
                    491:                         chtype a = A_BOLD;
                    492:                         int b = KEY_LEFT;
                    493:                         int g = getattrs(stdscr);
                    494:                         int h = getcurx(stdscr) + getmaxx(stdscr);
                    495:                         initscr();
                    496:                     ]])],
                    497:                     [ax_cv_plaincurses_obsolete=yes],
                    498:                     [ax_cv_plaincurses_obsolete=no])
                    499:                 ])
                    500:                 AS_IF([test "x$ax_cv_plaincurses_obsolete" = xyes], [
                    501:                     ax_cv_curses_obsolete=yes
                    502:                     AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
                    503:                 ])
                    504:             ])
                    505: 
                    506:             AS_IF([test "x$ax_cv_header_curses_h" = xno], [
                    507:                 AC_MSG_WARN([could not find a working curses.h])
                    508:             ])
                    509:         ])
                    510:     ])
                    511: 
                    512:     AS_IF([test "x$ax_cv_curses"          != xyes], [ax_cv_curses=no])
                    513:     AS_IF([test "x$ax_cv_curses_enhanced" != xyes], [ax_cv_curses_enhanced=no])
                    514:     AS_IF([test "x$ax_cv_curses_color"    != xyes], [ax_cv_curses_color=no])
                    515:     AS_IF([test "x$ax_cv_curses_obsolete" != xyes], [ax_cv_curses_obsolete=no])
                    516: 
                    517:     LIBS=$ax_saved_LIBS
                    518: ])dnl

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>