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