1 # ===========================================================================
2 # http://www.gnu.org/software/autoconf-archive/ax_with_curses_extra.html
3 # ===========================================================================
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.
18 # The following preprocessor symbols may be defined by these macros:
20 # By AX_WITH_CURSES_PANEL:
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
27 # By AX_WITH_CURSES_MENU:
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
34 # By AX_WITH_CURSES_FORM:
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
41 # The following output variables may be defined by these macros; these are
42 # precious and may be overridden on the ./configure command line:
44 # PANEL_LIB - library to add to xxx_LDADD before CURSES_LIB
45 # MENU_LIB - library to add to xxx_LDADD before CURSES_LIB
46 # FORM_LIB - library to add to xxx_LDADD before CURSES_LIB
48 # These libraries are NOT added to LIBS by default. You need to add them
49 # to the appropriate xxx_LDADD line in your Makefile.am in front of the
50 # equivalent CURSES_LIB incantation. For example:
52 # prog_LDADD = @PANEL_LIB@ @CURSES_LIB@
54 # If one of the xxx_LIB variables is set on the configure command line
55 # (such as by running "./configure PANEL_LIB=-lmypanel"), then the header
56 # file searched must NOT contain a subpath. In this case, in other words,
57 # only <panel.h> would be searched for. The user may use the CPPFLAGS
58 # precious variable to override the standard #include search path.
60 # The following shell variables may be defined by these macros:
62 # ax_cv_panel - set to "yes" if Panels library is present
63 # ax_cv_menu - set to "yes" if Menu library is present
64 # ax_cv_form - set to "yes" if Form library is present
66 # These variables can be used in your configure.ac to determine whether a
67 # library you require is actually present. For example:
70 # if test "x$ax_cv_curses" != xyes; then
71 # AC_MSG_ERROR([requires a SysV or X/Open-compatible Curses library])
73 # AX_WITH_CURSES_PANEL
74 # if test "x$ax_cv_panel" != xyes; then
75 # AC_MSG_ERROR([requires the Curses Panel library])
78 # To use the HAVE_xxx_H preprocessor symbols, insert the following into
79 # your system.h (or equivalent) header file:
81 # For AX_WITH_CURSES_PANEL:
83 # #if defined(HAVE_NCURSESW_PANEL_H)
84 # # include <ncursesw/panel.h>
85 # #elif defined(HAVE_NCURSES_PANEL_H)
86 # # include <ncurses/panel.h>
87 # #elif defined(HAVE_PANEL_H)
90 # # error "SysV-compatible Curses Panel header file required"
93 # For AX_WITH_CURSES_MENU:
95 # #if defined(HAVE_NCURSESW_MENU_H)
96 # # include <ncursesw/menu.h>
97 # #elif defined(HAVE_NCURSES_MENU_H)
98 # # include <ncurses/menu.h>
99 # #elif defined(HAVE_MENU_H)
102 # # error "SysV-compatible Curses Menu header file required"
105 # For AX_WITH_CURSES_FORM:
107 # #if defined(HAVE_NCURSESW_FORM_H)
108 # # include <ncursesw/form.h>
109 # #elif defined(HAVE_NCURSES_FORM_H)
110 # # include <ncurses/form.h>
111 # #elif defined(HAVE_FORM_H)
114 # # error "SysV-compatible Curses Form header file required"
119 # Copyright (c) 2011 John Zaitseff <J.Zaitseff@zap.org.au>
121 # This program is free software: you can redistribute it and/or modify it
122 # under the terms of the GNU General Public License as published by the
123 # Free Software Foundation, either version 3 of the License, or (at your
124 # option) any later version.
126 # This program is distributed in the hope that it will be useful, but
127 # WITHOUT ANY WARRANTY; without even the implied warranty of
128 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
129 # Public License for more details.
131 # You should have received a copy of the GNU General Public License along
132 # with this program. If not, see <http://www.gnu.org/licenses/>.
134 # As a special exception, the respective Autoconf Macro's copyright owner
135 # gives unlimited permission to copy, distribute and modify the configure
136 # scripts that are the output of Autoconf when processing the Macro. You
137 # need not follow the terms of the GNU General Public License when using
138 # or distributing such scripts, even though portions of the text of the
139 # Macro appear in them. The GNU General Public License (GPL) does govern
140 # all other use of the material that constitutes the Autoconf Macro.
142 # This special exception to the GPL applies to versions of the Autoconf
143 # Macro released by the Autoconf Archive. When you make and distribute a
144 # modified version of the Autoconf Macro, you may extend this special
145 # exception to the GPL to apply to your modified version as well.
149 AC_DEFUN([_AX_WITH_CURSES_CHECKEXTRA], [
150 dnl Parameter 1 is the variable name component, using uppercase letters only
151 dnl Parameter 2 is the printable library name
152 dnl Parameter 3 is the C code to try compiling and linking
153 dnl Parameter 4 is the header filename
154 dnl Parameter 5 is the library command line
156 AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_have_var], [HAVE_$1])dnl
157 AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_cv_var], [ax_cv_[]m4_tolower($1)])dnl
158 AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_header_var], [ax_cv_header_$4])dnl
159 AS_VAR_PUSHDEF([_AX_WITH_CURSES_CHECKEXTRA_have_header_var], [HAVE_[]m4_toupper($4)])dnl
162 AC_CACHE_CHECK([for Curses $2 library with $4], [_AX_WITH_CURSES_CHECKEXTRA_header_var], [
163 LIBS="$ax_saved_LIBS $5 $CURSES_LIB"
164 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
167 [_AX_WITH_CURSES_CHECKEXTRA_header_var=yes],
168 [_AX_WITH_CURSES_CHECKEXTRA_header_var=no])
170 AS_IF([test "x$[]_AX_WITH_CURSES_CHECKEXTRA_header_var" = xyes], [
171 _AX_WITH_CURSES_CHECKEXTRA_cv_var=yes
172 AS_LITERAL_IF([$5], [$1_LIB="$5"])
173 AC_DEFINE([_AX_WITH_CURSES_CHECKEXTRA_have_var], [1], [Define to 1 if the Curses $2 library is present])
174 AC_DEFINE([_AX_WITH_CURSES_CHECKEXTRA_have_header_var], [1], [Define to 1 if <$4> is present])
176 _AX_WITH_CURSES_CHECKEXTRA_cv_var=no
180 AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_have_header_var])dnl
181 AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_header_var])dnl
182 AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_cv_var])dnl
183 AS_VAR_POPDEF([_AX_WITH_CURSES_CHECKEXTRA_have_var])dnl
186 AC_DEFUN([_AX_WITH_CURSES_EXTRA], [
187 dnl Parameter 1 is the variable name component, using uppercase letters only
188 dnl Parameter 2 is the printable library name
189 dnl Parameter 3 is the C code to try compiling and linking
190 dnl Parameter 4 is the header filename component
191 dnl Parameter 5 is the NCursesW library command line
192 dnl Parameter 6 is the NCurses library command line
193 dnl Parameter 7 is the plain Curses library command line
195 AC_REQUIRE([AX_WITH_CURSES])
196 AC_ARG_VAR([$1_LIB], [linker library for Curses $2, e.g. $7])
198 AS_IF([test "x$[]$1_LIB" != x], [
199 _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$[]$1_LIB])
201 AS_IF([test "x$ax_cv_curses_which" = xncursesw], [
202 _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [ncursesw/$4], [$5])
203 dnl This fixes a problem building on distros with 'odd'
204 dnl ncurses header file setups
205 AS_IF([test x$[]ax_cv_[]m4_tolower($1) != "xyes"], [
206 _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$5])
208 ], [test "x$ax_cv_curses_which" = xncurses], [
209 _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [ncurses/$4], [$6])
210 _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$6])
211 ], [test "x$ax_cv_curses_which" = xplaincurses], [
212 _AX_WITH_CURSES_CHECKEXTRA([$1], [$2], [$3], [$4], [$7])
217 AC_DEFUN([AX_WITH_CURSES_PANEL], [
218 _AX_WITH_CURSES_EXTRA([PANEL], [Panel], [[
219 WINDOW *win = newwin(0, 0, 0, 0);
220 PANEL *pan = new_panel(win);
221 ]], [panel.h], [-lpanelw], [-lpanel], [-lpanel])
224 AC_DEFUN([AX_WITH_CURSES_MENU], [
225 _AX_WITH_CURSES_EXTRA([MENU], [Menu], [[
227 MENU *m = new_menu(mi);
228 ]], [menu.h], [-lmenuw], [-lmenu], [-lmenu])
231 AC_DEFUN([AX_WITH_CURSES_FORM], [
232 _AX_WITH_CURSES_EXTRA([FORM], [Form], [[
234 FORM *f = new_form(ff);
235 ]], [form.h], [-lformw], [-lform], [-lform])