Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

583 lines
27KB

  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. #serial 18
  193. # internal function to factorize common code that is used by both ncurses
  194. # and ncursesw
  195. AC_DEFUN([_FIND_CURSES_FLAGS], [
  196. AC_MSG_CHECKING([for $1 via pkg-config])
  197. AX_REQUIRE_DEFINED([PKG_CHECK_EXISTS])
  198. _PKG_CONFIG([_ax_cv_$1_libs], [libs], [$1])
  199. _PKG_CONFIG([_ax_cv_$1_cppflags], [cflags], [$1])
  200. AS_IF([test "x$pkg_failed" = "xyes" || test "x$pkg_failed" = "xuntried"],[
  201. AC_MSG_RESULT([no])
  202. # No suitable .pc file found, have to find flags via fallback
  203. AC_CACHE_CHECK([for $1 via fallback], [ax_cv_$1], [
  204. AS_ECHO()
  205. pkg_cv__ax_cv_$1_libs="-l$1"
  206. pkg_cv__ax_cv_$1_cppflags="-D_GNU_SOURCE $CURSES_CFLAGS"
  207. LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs"
  208. CPPFLAGS="$ax_saved_CPPFLAGS $pkg_cv__ax_cv_$1_cppflags"
  209. AC_MSG_CHECKING([for initscr() with $pkg_cv__ax_cv_$1_libs])
  210. AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
  211. [
  212. AC_MSG_RESULT([yes])
  213. AC_MSG_CHECKING([for nodelay() with $pkg_cv__ax_cv_$1_libs])
  214. AC_LINK_IFELSE([AC_LANG_CALL([], [nodelay])],[
  215. ax_cv_$1=yes
  216. ],[
  217. AC_MSG_RESULT([no])
  218. m4_if(
  219. [$1],[ncursesw],[pkg_cv__ax_cv_$1_libs="$pkg_cv__ax_cv_$1_libs -ltinfow"],
  220. [$1],[ncurses],[pkg_cv__ax_cv_$1_libs="$pkg_cv__ax_cv_$1_libs -ltinfo"]
  221. )
  222. LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs"
  223. AC_MSG_CHECKING([for nodelay() with $pkg_cv__ax_cv_$1_libs])
  224. AC_LINK_IFELSE([AC_LANG_CALL([], [nodelay])],[
  225. ax_cv_$1=yes
  226. ],[
  227. ax_cv_$1=no
  228. ])
  229. ])
  230. ],[
  231. ax_cv_$1=no
  232. ])
  233. ])
  234. ],[
  235. AC_MSG_RESULT([yes])
  236. # Found .pc file, using its information
  237. LIBS="$ax_saved_LIBS $pkg_cv__ax_cv_$1_libs"
  238. CPPFLAGS="$ax_saved_CPPFLAGS $pkg_cv__ax_cv_$1_cppflags"
  239. ax_cv_$1=yes
  240. ])
  241. ])
  242. AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
  243. AC_DEFUN([AX_WITH_CURSES], [
  244. AC_ARG_VAR([CURSES_LIBS], [linker library for Curses, e.g. -lcurses])
  245. AC_ARG_VAR([CURSES_CFLAGS], [preprocessor flags for Curses, e.g. -I/usr/include/ncursesw])
  246. AC_ARG_WITH([ncurses], [AS_HELP_STRING([--with-ncurses],
  247. [force the use of Ncurses or NcursesW])],
  248. [], [with_ncurses=check])
  249. AC_ARG_WITH([ncursesw], [AS_HELP_STRING([--without-ncursesw],
  250. [do not use NcursesW (wide character support)])],
  251. [], [with_ncursesw=check])
  252. ax_saved_LIBS=$LIBS
  253. ax_saved_CPPFLAGS=$CPPFLAGS
  254. AS_IF([test "x$with_ncurses" = xyes || test "x$with_ncursesw" = xyes],
  255. [ax_with_plaincurses=no], [ax_with_plaincurses=check])
  256. ax_cv_curses_which=no
  257. # Test for NcursesW
  258. AS_IF([test "x$CURSES_LIBS" = x && test "x$with_ncursesw" != xno], [
  259. _FIND_CURSES_FLAGS([ncursesw])
  260. AS_IF([test "x$ax_cv_ncursesw" = xno && test "x$with_ncursesw" = xyes], [
  261. AC_MSG_ERROR([--with-ncursesw specified but could not find NcursesW library])
  262. ])
  263. AS_IF([test "x$ax_cv_ncursesw" = xyes], [
  264. ax_cv_curses=yes
  265. ax_cv_curses_which=ncursesw
  266. CURSES_LIBS="$pkg_cv__ax_cv_ncursesw_libs"
  267. CURSES_CFLAGS="$pkg_cv__ax_cv_ncursesw_cppflags"
  268. AC_DEFINE([HAVE_NCURSESW], [1], [Define to 1 if the NcursesW library is present])
  269. AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
  270. AC_CACHE_CHECK([for working ncursesw/curses.h], [ax_cv_header_ncursesw_curses_h], [
  271. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  272. @%:@define _XOPEN_SOURCE_EXTENDED 1
  273. @%:@include <ncursesw/curses.h>
  274. ]], [[
  275. chtype a = A_BOLD;
  276. int b = KEY_LEFT;
  277. chtype c = COLOR_PAIR(1) & A_COLOR;
  278. attr_t d = WA_NORMAL;
  279. cchar_t e;
  280. wint_t f;
  281. int g = getattrs(stdscr);
  282. int h = getcurx(stdscr) + getmaxx(stdscr);
  283. initscr();
  284. init_pair(1, COLOR_WHITE, COLOR_RED);
  285. wattr_set(stdscr, d, 0, NULL);
  286. wget_wch(stdscr, &f);
  287. ]])],
  288. [ax_cv_header_ncursesw_curses_h=yes],
  289. [ax_cv_header_ncursesw_curses_h=no])
  290. ])
  291. AS_IF([test "x$ax_cv_header_ncursesw_curses_h" = xyes], [
  292. ax_cv_curses_enhanced=yes
  293. ax_cv_curses_color=yes
  294. ax_cv_curses_obsolete=yes
  295. AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
  296. AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
  297. AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
  298. AC_DEFINE([HAVE_NCURSESW_CURSES_H], [1], [Define to 1 if <ncursesw/curses.h> is present])
  299. ])
  300. AC_CACHE_CHECK([for working ncursesw.h], [ax_cv_header_ncursesw_h], [
  301. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  302. @%:@define _XOPEN_SOURCE_EXTENDED 1
  303. @%:@include <ncursesw.h>
  304. ]], [[
  305. chtype a = A_BOLD;
  306. int b = KEY_LEFT;
  307. chtype c = COLOR_PAIR(1) & A_COLOR;
  308. attr_t d = WA_NORMAL;
  309. cchar_t e;
  310. wint_t f;
  311. int g = getattrs(stdscr);
  312. int h = getcurx(stdscr) + getmaxx(stdscr);
  313. initscr();
  314. init_pair(1, COLOR_WHITE, COLOR_RED);
  315. wattr_set(stdscr, d, 0, NULL);
  316. wget_wch(stdscr, &f);
  317. ]])],
  318. [ax_cv_header_ncursesw_h=yes],
  319. [ax_cv_header_ncursesw_h=no])
  320. ])
  321. AS_IF([test "x$ax_cv_header_ncursesw_h" = xyes], [
  322. ax_cv_curses_enhanced=yes
  323. ax_cv_curses_color=yes
  324. ax_cv_curses_obsolete=yes
  325. AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
  326. AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
  327. AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
  328. AC_DEFINE([HAVE_NCURSESW_H], [1], [Define to 1 if <ncursesw.h> is present])
  329. ])
  330. AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h_with_ncursesw], [
  331. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  332. @%:@define _XOPEN_SOURCE_EXTENDED 1
  333. @%:@include <ncurses.h>
  334. ]], [[
  335. chtype a = A_BOLD;
  336. int b = KEY_LEFT;
  337. chtype c = COLOR_PAIR(1) & A_COLOR;
  338. attr_t d = WA_NORMAL;
  339. cchar_t e;
  340. wint_t f;
  341. int g = getattrs(stdscr);
  342. int h = getcurx(stdscr) + getmaxx(stdscr);
  343. initscr();
  344. init_pair(1, COLOR_WHITE, COLOR_RED);
  345. wattr_set(stdscr, d, 0, NULL);
  346. wget_wch(stdscr, &f);
  347. ]])],
  348. [ax_cv_header_ncurses_h_with_ncursesw=yes],
  349. [ax_cv_header_ncurses_h_with_ncursesw=no])
  350. ])
  351. AS_IF([test "x$ax_cv_header_ncurses_h_with_ncursesw" = xyes], [
  352. ax_cv_curses_enhanced=yes
  353. ax_cv_curses_color=yes
  354. ax_cv_curses_obsolete=yes
  355. AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
  356. AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
  357. AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
  358. AC_DEFINE([HAVE_NCURSES_H], [1], [Define to 1 if <ncurses.h> is present])
  359. ])
  360. 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], [
  361. AC_MSG_WARN([could not find a working ncursesw/curses.h, ncursesw.h or ncurses.h])
  362. ])
  363. ])
  364. ])
  365. unset pkg_cv__ax_cv_ncursesw_libs
  366. unset pkg_cv__ax_cv_ncursesw_cppflags
  367. # Test for Ncurses
  368. AS_IF([test "x$CURSES_LIBS" = x && test "x$with_ncurses" != xno && test "x$ax_cv_curses_which" = xno], [
  369. _FIND_CURSES_FLAGS([ncurses])
  370. AS_IF([test "x$ax_cv_ncurses" = xno && test "x$with_ncurses" = xyes], [
  371. AC_MSG_ERROR([--with-ncurses specified but could not find Ncurses library])
  372. ])
  373. AS_IF([test "x$ax_cv_ncurses" = xyes], [
  374. ax_cv_curses=yes
  375. ax_cv_curses_which=ncurses
  376. CURSES_LIBS="$pkg_cv__ax_cv_ncurses_libs"
  377. CURSES_CFLAGS="$pkg_cv__ax_cv_ncurses_cppflags"
  378. AC_DEFINE([HAVE_NCURSES], [1], [Define to 1 if the Ncurses library is present])
  379. AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
  380. AC_CACHE_CHECK([for working ncurses/curses.h], [ax_cv_header_ncurses_curses_h], [
  381. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  382. @%:@include <ncurses/curses.h>
  383. ]], [[
  384. chtype a = A_BOLD;
  385. int b = KEY_LEFT;
  386. chtype c = COLOR_PAIR(1) & A_COLOR;
  387. int g = getattrs(stdscr);
  388. int h = getcurx(stdscr) + getmaxx(stdscr);
  389. initscr();
  390. init_pair(1, COLOR_WHITE, COLOR_RED);
  391. ]])],
  392. [ax_cv_header_ncurses_curses_h=yes],
  393. [ax_cv_header_ncurses_curses_h=no])
  394. ])
  395. AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xyes], [
  396. ax_cv_curses_color=yes
  397. ax_cv_curses_obsolete=yes
  398. AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
  399. AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
  400. AC_DEFINE([HAVE_NCURSES_CURSES_H], [1], [Define to 1 if <ncurses/curses.h> is present])
  401. ])
  402. AC_CACHE_CHECK([for working ncurses.h], [ax_cv_header_ncurses_h], [
  403. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  404. @%:@include <ncurses.h>
  405. ]], [[
  406. chtype a = A_BOLD;
  407. int b = KEY_LEFT;
  408. chtype c = COLOR_PAIR(1) & A_COLOR;
  409. int g = getattrs(stdscr);
  410. int h = getcurx(stdscr) + getmaxx(stdscr);
  411. initscr();
  412. init_pair(1, COLOR_WHITE, COLOR_RED);
  413. ]])],
  414. [ax_cv_header_ncurses_h=yes],
  415. [ax_cv_header_ncurses_h=no])
  416. ])
  417. AS_IF([test "x$ax_cv_header_ncurses_h" = xyes], [
  418. ax_cv_curses_color=yes
  419. ax_cv_curses_obsolete=yes
  420. AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
  421. AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
  422. AC_DEFINE([HAVE_NCURSES_H], [1], [Define to 1 if <ncurses.h> is present])
  423. ])
  424. AS_IF([test "x$ax_cv_header_ncurses_curses_h" = xno && test "x$ax_cv_header_ncurses_h" = xno], [
  425. AC_MSG_WARN([could not find a working ncurses/curses.h or ncurses.h])
  426. ])
  427. ])
  428. ])
  429. unset pkg_cv__ax_cv_ncurses_libs
  430. unset pkg_cv__ax_cv_ncurses_cppflags
  431. # Test for plain Curses (or if CURSES_LIBS was set by user)
  432. AS_IF([test "x$with_plaincurses" != xno && test "x$ax_cv_curses_which" = xno], [
  433. AS_IF([test "x$CURSES_LIBS" != x], [
  434. LIBS="$ax_saved_LIBS $CURSES_LIBS"
  435. ], [
  436. LIBS="$ax_saved_LIBS -lcurses"
  437. ])
  438. AC_CACHE_CHECK([for Curses library], [ax_cv_plaincurses], [
  439. AC_LINK_IFELSE([AC_LANG_CALL([], [initscr])],
  440. [ax_cv_plaincurses=yes], [ax_cv_plaincurses=no])
  441. ])
  442. AS_IF([test "x$ax_cv_plaincurses" = xyes], [
  443. ax_cv_curses=yes
  444. ax_cv_curses_which=plaincurses
  445. AS_IF([test "x$CURSES_LIBS" = x], [
  446. CURSES_LIBS="-lcurses"
  447. ])
  448. AC_DEFINE([HAVE_CURSES], [1], [Define to 1 if a SysV or X/Open compatible Curses library is present])
  449. # Check for base conformance (and header file)
  450. AC_CACHE_CHECK([for working curses.h], [ax_cv_header_curses_h], [
  451. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  452. @%:@include <curses.h>
  453. ]], [[
  454. chtype a = A_BOLD;
  455. int b = KEY_LEFT;
  456. initscr();
  457. ]])],
  458. [ax_cv_header_curses_h=yes],
  459. [ax_cv_header_curses_h=no])
  460. ])
  461. AS_IF([test "x$ax_cv_header_curses_h" = xyes], [
  462. AC_DEFINE([HAVE_CURSES_H], [1], [Define to 1 if <curses.h> is present])
  463. # Check for X/Open Enhanced conformance
  464. AC_CACHE_CHECK([for X/Open Enhanced Curses conformance], [ax_cv_plaincurses_enhanced], [
  465. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  466. @%:@define _XOPEN_SOURCE_EXTENDED 1
  467. @%:@include <curses.h>
  468. @%:@ifndef _XOPEN_CURSES
  469. @%:@error "this Curses library is not enhanced"
  470. "this Curses library is not enhanced"
  471. @%:@endif
  472. ]], [[
  473. chtype a = A_BOLD;
  474. int b = KEY_LEFT;
  475. chtype c = COLOR_PAIR(1) & A_COLOR;
  476. attr_t d = WA_NORMAL;
  477. cchar_t e;
  478. wint_t f;
  479. initscr();
  480. init_pair(1, COLOR_WHITE, COLOR_RED);
  481. wattr_set(stdscr, d, 0, NULL);
  482. wget_wch(stdscr, &f);
  483. ]])],
  484. [ax_cv_plaincurses_enhanced=yes],
  485. [ax_cv_plaincurses_enhanced=no])
  486. ])
  487. AS_IF([test "x$ax_cv_plaincurses_enhanced" = xyes], [
  488. ax_cv_curses_enhanced=yes
  489. ax_cv_curses_color=yes
  490. AC_DEFINE([HAVE_CURSES_ENHANCED], [1], [Define to 1 if library supports X/Open Enhanced functions])
  491. AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
  492. ])
  493. # Check for color functions
  494. AC_CACHE_CHECK([for Curses color functions], [ax_cv_plaincurses_color], [
  495. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  496. @%:@define _XOPEN_SOURCE_EXTENDED 1
  497. @%:@include <curses.h>
  498. ]], [[
  499. chtype a = A_BOLD;
  500. int b = KEY_LEFT;
  501. chtype c = COLOR_PAIR(1) & A_COLOR;
  502. initscr();
  503. init_pair(1, COLOR_WHITE, COLOR_RED);
  504. ]])],
  505. [ax_cv_plaincurses_color=yes],
  506. [ax_cv_plaincurses_color=no])
  507. ])
  508. AS_IF([test "x$ax_cv_plaincurses_color" = xyes], [
  509. ax_cv_curses_color=yes
  510. AC_DEFINE([HAVE_CURSES_COLOR], [1], [Define to 1 if library supports color (enhanced functions)])
  511. ])
  512. # Check for obsolete functions
  513. AC_CACHE_CHECK([for obsolete Curses functions], [ax_cv_plaincurses_obsolete], [
  514. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  515. @%:@include <curses.h>
  516. ]], [[
  517. chtype a = A_BOLD;
  518. int b = KEY_LEFT;
  519. int g = getattrs(stdscr);
  520. int h = getcurx(stdscr) + getmaxx(stdscr);
  521. initscr();
  522. ]])],
  523. [ax_cv_plaincurses_obsolete=yes],
  524. [ax_cv_plaincurses_obsolete=no])
  525. ])
  526. AS_IF([test "x$ax_cv_plaincurses_obsolete" = xyes], [
  527. ax_cv_curses_obsolete=yes
  528. AC_DEFINE([HAVE_CURSES_OBSOLETE], [1], [Define to 1 if library supports certain obsolete features])
  529. ])
  530. ])
  531. AS_IF([test "x$ax_cv_header_curses_h" = xno], [
  532. AC_MSG_WARN([could not find a working curses.h])
  533. ])
  534. ])
  535. ])
  536. AS_IF([test "x$ax_cv_curses" != xyes], [ax_cv_curses=no])
  537. AS_IF([test "x$ax_cv_curses_enhanced" != xyes], [ax_cv_curses_enhanced=no])
  538. AS_IF([test "x$ax_cv_curses_color" != xyes], [ax_cv_curses_color=no])
  539. AS_IF([test "x$ax_cv_curses_obsolete" != xyes], [ax_cv_curses_obsolete=no])
  540. LIBS=$ax_saved_LIBS
  541. CPPFLAGS=$ax_saved_CPPFLAGS
  542. unset ax_saved_LIBS
  543. unset ax_saved_CPPFLAGS
  544. ])dnl