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.

246 lines
9.9KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_with_curses_extra.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_WITH_CURSES_PANEL
  8. # AX_WITH_CURSES_MENU
  9. # AX_WITH_CURSES_FORM
  10. #
  11. # DESCRIPTION
  12. #
  13. # These macros try to find additional libraries that often come with
  14. # SysV-compatible Curses. In particular, the Panel, Menu and Form
  15. # libraries are searched, along with their header files. These macros
  16. # depend on AX_WITH_CURSES.
  17. #
  18. # The following preprocessor symbols may be defined by these macros:
  19. #
  20. # By AX_WITH_CURSES_PANEL:
  21. #
  22. # HAVE_PANEL - if the Panel library is present
  23. # HAVE_PANEL_H - if <panel.h> is present and should be used
  24. # HAVE_NCURSES_PANEL_H - if <ncurses/panel.h> should be used
  25. # HAVE_NCURSESW_PANEL_H - if <ncursesw/panel.h> should be used
  26. #
  27. # By AX_WITH_CURSES_MENU:
  28. #
  29. # HAVE_MENU - if the Menu library is present
  30. # HAVE_MENU_H - if <menu.h> is present and should be used
  31. # HAVE_NCURSES_MENU_H - if <ncurses/menu.h> should be used
  32. # HAVE_NCURSESW_MENU_H - if <ncursesw/menu.h> should be used
  33. #
  34. # By AX_WITH_CURSES_FORM:
  35. #
  36. # HAVE_FORM - if the Form library is present
  37. # HAVE_FORM_H - if <form.h> is present and should be used
  38. # HAVE_NCURSES_FORM_H - if <ncurses/form.h> should be used
  39. # HAVE_NCURSESW_FORM_H - if <ncursesw/form.h> should be used
  40. #
  41. # The following output variables may be defined by these macros; these are
  42. # precious and may be overridden on the ./configure command line:
  43. #
  44. # PANEL_LIBS - library to add to xxx_LDADD before CURSES_LIBS
  45. # MENU_LIBS - library to add to xxx_LDADD before CURSES_LIBS
  46. # FORM_LIBS - library to add to xxx_LDADD before CURSES_LIBS
  47. #
  48. # In previous versions of this macro, the flags PANEL_LIB, MENU_LIB and
  49. # FORM_LIB were defined. These have been renamed, in keeping with the
  50. # variable scheme of PKG_CHECK_MODULES, which should eventually supersede
  51. # the use of AX_WITH_CURSES and AX_WITH_CURSES_* macros. These libraries
  52. # are NOT added to LIBS by default. You need to add them to the
  53. # appropriate xxx_LDADD line in your Makefile.am in front of the
  54. # equivalent CURSES_LIBS incantation. For example:
  55. #
  56. # prog_LDADD = @PANEL_LIBS@ @CURSES_LIBS@
  57. #
  58. # If one of the xxx_LIBS variables is set on the configure command line
  59. # (such as by running "./configure PANEL_LIBS=-lmypanel"), then the header
  60. # file searched must NOT contain a subpath. In this case, in other words,
  61. # only <panel.h> would be searched for. The user may use the CPPFLAGS
  62. # precious variable to override the standard #include search path.
  63. #
  64. # The following shell variables may be defined by these macros:
  65. #
  66. # ax_cv_panel - set to "yes" if Panels library is present
  67. # ax_cv_menu - set to "yes" if Menu library is present
  68. # ax_cv_form - set to "yes" if Form library is present
  69. #
  70. # These variables can be used in your configure.ac to determine whether a
  71. # library you require is actually present. For example:
  72. #
  73. # AX_WITH_CURSES
  74. # if test "x$ax_cv_curses" != xyes; then
  75. # AC_MSG_ERROR([requires a SysV or X/Open-compatible Curses library])
  76. # fi
  77. # AX_WITH_CURSES_PANEL
  78. # if test "x$ax_cv_panel" != xyes; then
  79. # AC_MSG_ERROR([requires the Curses Panel library])
  80. # fi
  81. #
  82. # To use the HAVE_xxx_H preprocessor symbols, insert the following into
  83. # your system.h (or equivalent) header file:
  84. #
  85. # For AX_WITH_CURSES_PANEL:
  86. #
  87. # #if defined HAVE_NCURSESW_PANEL_H
  88. # # include <ncursesw/panel.h>
  89. # #elif defined HAVE_NCURSES_PANEL_H
  90. # # include <ncurses/panel.h>
  91. # #elif defined HAVE_PANEL_H
  92. # # include <panel.h>
  93. # #else
  94. # # error "SysV-compatible Curses Panel header file required"
  95. # #endif
  96. #
  97. # For AX_WITH_CURSES_MENU:
  98. #
  99. # #if defined HAVE_NCURSESW_MENU_H
  100. # # include <ncursesw/menu.h>
  101. # #elif defined HAVE_NCURSES_MENU_H
  102. # # include <ncurses/menu.h>
  103. # #elif defined HAVE_MENU_H
  104. # # include <menu.h>
  105. # #else
  106. # # error "SysV-compatible Curses Menu header file required"
  107. # #endif
  108. #
  109. # For AX_WITH_CURSES_FORM:
  110. #
  111. # #if defined HAVE_NCURSESW_FORM_H
  112. # # include <ncursesw/form.h>
  113. # #elif defined HAVE_NCURSES_FORM_H
  114. # # include <ncurses/form.h>
  115. # #elif defined HAVE_FORM_H
  116. # # include <form.h>
  117. # #else
  118. # # error "SysV-compatible Curses Form header file required"
  119. # #endif
  120. #
  121. # LICENSE
  122. #
  123. # Copyright (c) 2011 John Zaitseff <J.Zaitseff@zap.org.au>
  124. #
  125. # This program is free software: you can redistribute it and/or modify it
  126. # under the terms of the GNU General Public License as published by the
  127. # Free Software Foundation, either version 3 of the License, or (at your
  128. # option) any later version.
  129. #
  130. # This program is distributed in the hope that it will be useful, but
  131. # WITHOUT ANY WARRANTY; without even the implied warranty of
  132. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  133. # Public License for more details.
  134. #
  135. # You should have received a copy of the GNU General Public License along
  136. # with this program. If not, see <https://www.gnu.org/licenses/>.
  137. #
  138. # As a special exception, the respective Autoconf Macro's copyright owner
  139. # gives unlimited permission to copy, distribute and modify the configure
  140. # scripts that are the output of Autoconf when processing the Macro. You
  141. # need not follow the terms of the GNU General Public License when using
  142. # or distributing such scripts, even though portions of the text of the
  143. # Macro appear in them. The GNU General Public License (GPL) does govern
  144. # all other use of the material that constitutes the Autoconf Macro.
  145. #
  146. # This special exception to the GPL applies to versions of the Autoconf
  147. # Macro released by the Autoconf Archive. When you make and distribute a
  148. # modified version of the Autoconf Macro, you may extend this special
  149. # exception to the GPL to apply to your modified version as well.
  150. #serial 5
  151. AC_DEFUN([_AX_WITH_CURSES_CHECKEXTRA], [
  152. dnl Parameter 1 is the variable name component, using uppercase letters only
  153. dnl Parameter 2 is the printable library name
  154. dnl Parameter 3 is the C code to try compiling and linking
  155. dnl Parameter 4 is the header filename
  156. dnl Parameter 5 is the library command line
  157. AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_have_var], [HAVE_$1])dnl
  158. AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_cv_var], [ax_cv_[]m4_tolower($1)])dnl
  159. AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_header_var], [ax_cv_header_$4])dnl
  160. AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_have_header_var], [HAVE_[]m4_toupper($4)])dnl
  161. ax_saved_LIBS=$LIBS
  162. ax_saved_CPPFLAGS=$CPPFLAGS
  163. AC_CACHE_CHECK([for Curses $2 library with $4], [_AX_WITH_CURSES_CHECKEXTRA_header_var], [
  164. LIBS="$ax_saved_LIBS $5 $CURSES_LIBS"
  165. CPPFLAGS="$ax_saved_CPPFLAGS $CURSES_CFLAGS"
  166. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  167. @%:@include <$4>
  168. ]], [$3])],
  169. [_AX_WITH_CURSES_CHECKEXTRA_header_var=yes],
  170. [_AX_WITH_CURSES_CHECKEXTRA_header_var=no])
  171. ])
  172. AS_IF([test "x$[]_AX_WITH_CURSES_CHECKEXTRA_header_var" = xyes], [
  173. _AX_WITH_CURSES_CHECKEXTRA_cv_var=yes
  174. AS_LITERAL_IF([$5], [$1_LIBS="$5"])
  175. AC_DEFINE([_AX_WITH_CURSES_CHECKEXTRA_have_var], [1], [Define to 1 if the Curses $2 library is present])
  176. AC_DEFINE([_AX_WITH_CURSES_CHECKEXTRA_have_header_var], [1], [Define to 1 if <$4> is present])
  177. ], [
  178. AS_IF([test "x$[]_AX_WITH_CURSES_CHECKEXTRA_cv_var" = xyes], [],
  179. [_AX_WITH_CURSES_CHECKEXTRA_cv_var=no])
  180. ])
  181. LIBS=$ax_saved_LIBS
  182. CPPFLAGS=$ax_saved_CPPFLAGS
  183. unset ax_saved_LIBS
  184. unset ax_saved_CPPFLAGS
  185. AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_have_header_var])dnl
  186. AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_header_var])dnl
  187. AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_cv_var])dnl
  188. AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_have_var])dnl
  189. ])dnl
  190. AC_DEFUN([_AX_WITH_CURSES_EXTRA], [
  191. dnl Parameter 1 is the variable name component, using uppercase letters only
  192. dnl Parameter 2 is the printable library name
  193. dnl Parameter 3 is the C code to try compiling and linking
  194. dnl Parameter 4 is the header filename component
  195. dnl Parameter 5 is the NCursesW library command line
  196. dnl Parameter 6 is the NCurses library command line
  197. dnl Parameter 7 is the plain Curses library command line
  198. AC_REQUIRE([AX_WITH_CURSES])
  199. AC_ARG_VAR([$1_LIBS], [linker library for Curses $2, e.g. $7])
  200. AS_IF([test "x$[]$1_LIBS" != x], [
  201. _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$[]$1_LIBS])
  202. ], [
  203. AS_IF([test "x$ax_cv_curses_which" = xncursesw], [
  204. _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [ncursesw/$4], [$5])
  205. ], [test "x$ax_cv_curses_which" = xncurses], [
  206. _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$6])
  207. AS_IF([test x$[]ax_cv_[]m4_tolower($1) != "xyes"], [
  208. _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [ncurses/$4], [$6])
  209. ])
  210. ], [test "x$ax_cv_curses_which" = xplaincurses], [
  211. _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$7])
  212. ])
  213. ])
  214. ])dnl
  215. AC_DEFUN([AX_WITH_CURSES_PANEL], [
  216. _AX_WITH_CURSES_EXTRA([PANEL], [Panel], [[
  217. WINDOW *win = newwin(0, 0, 0, 0);
  218. PANEL *pan = new_panel(win);
  219. ]], [panel.h], [-lpanelw], [-lpanel], [-lpanel])
  220. ])dnl
  221. AC_DEFUN([AX_WITH_CURSES_MENU], [
  222. _AX_WITH_CURSES_EXTRA([MENU], [Menu], [[
  223. ITEM **mi;
  224. MENU *m = new_menu(mi);
  225. ]], [menu.h], [-lmenuw], [-lmenu], [-lmenu])
  226. ])dnl
  227. AC_DEFUN([AX_WITH_CURSES_FORM], [
  228. _AX_WITH_CURSES_EXTRA([FORM], [Form], [[
  229. FIELD **ff;
  230. FORM *f = new_form(ff);
  231. ]], [form.h], [-lformw], [-lform], [-lform])
  232. ])dnl