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 # Detect SysV compatible curses, such as ncurses.
12 #
13 # Defines HAVE_CURSES_H or HAVE_NCURSES_H if curses is found. CURSES_LIB
14 # is also set with the required library, but is not appended to LIBS
15 # automatically. If no working curses library is found CURSES_LIB will be
16 # left blank. If CURSES_LIB is set in the environment, the supplied value
17 # will be used.
18 #
19 # There are two options: --with-ncurses forces the use of ncurses, and
20 # --with-ncursesw forces the use of ncursesw (wide character ncurses). The
21 # corresponding options --without-ncurses and --without-ncursesw force
22 # those libraries not to be used. By default, ncursesw is preferred to
23 # ncurses, which is preferred to plain curses.
24 #
25 # ax_cv_curses is set to "yes" if any curses is found (including
26 # ncurses!); ax_cv_ncurses is set to "yes" if any ncurses is found, and
27 # ax_cv_ncursesw is set to "yes" if ncursesw is found.
28 #
29 # LICENSE
30 #
31 # Copyright (c) 2009 Mark Pulford <mark@kyne.com.au>
32 # Copyright (c) 2009 Damian Pietras <daper@daper.net>
33 # Copyright (c) 2009 Reuben Thomas <rrt@sc3d.org>
34 #
35 # This program is free software: you can redistribute it and/or modify it
36 # under the terms of the GNU General Public License as published by the
37 # Free Software Foundation, either version 3 of the License, or (at your
38 # option) any later version.
39 #
40 # This program is distributed in the hope that it will be useful, but
41 # WITHOUT ANY WARRANTY; without even the implied warranty of
42 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
43 # Public License for more details.
44 #
45 # You should have received a copy of the GNU General Public License along
46 # with this program. If not, see <http://www.gnu.org/licenses/>.
47 #
48 # As a special exception, the respective Autoconf Macro's copyright owner
49 # gives unlimited permission to copy, distribute and modify the configure
50 # scripts that are the output of Autoconf when processing the Macro. You
51 # need not follow the terms of the GNU General Public License when using
52 # or distributing such scripts, even though portions of the text of the
53 # Macro appear in them. The GNU General Public License (GPL) does govern
54 # all other use of the material that constitutes the Autoconf Macro.
55 #
56 # This special exception to the GPL applies to versions of the Autoconf
57 # Macro released by the Autoconf Archive. When you make and distribute a
58 # modified version of the Autoconf Macro, you may extend this special
59 # exception to the GPL to apply to your modified version as well.
61 #serial 6
63 AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
64 AC_DEFUN([AX_WITH_CURSES],
65 [AC_ARG_WITH(ncurses, [AS_HELP_STRING([--with-ncurses],
66 [Force the use of ncurses over curses])],,)
67 ax_save_LIBS="$LIBS"
68 AC_ARG_WITH(ncursesw, [AS_HELP_STRING([--without-ncursesw],
69 [Don't use ncursesw (wide character support)])],,)
70 if test ! "$CURSES_LIB" -a "$with_ncurses" != no -a "$with_ncursesw" != "no"
71 then
72 AC_CACHE_CHECK([for working ncursesw], ax_cv_ncursesw,
73 [LIBS="$ax_save_LIBS -lncursesw"
74 AC_TRY_LINK(
75 [#include <ncurses.h>],
76 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
77 ax_cv_ncursesw=yes, ax_cv_ncursesw=no)])
78 if test "$ax_cv_ncursesw" = yes
79 then
80 AC_CHECK_HEADER([ncursesw/curses.h], AC_DEFINE(HAVE_NCURSESW_H, 1,
81 [Define if you have ncursesw.h]))
82 AC_DEFINE(HAVE_NCURSES_H, 1, [Define if you have ncursesw/curses.h])
83 AC_DEFINE(HAVE_NCURSESW, 1, [Define if you have libncursesw])
84 CURSES_LIB="-lncursesw"
85 ax_cv_ncurses=yes
86 ax_cv_curses=yes
87 fi
88 fi
89 if test ! "$CURSES_LIB" -a "$with_ncurses" != no -a "$with_ncursesw" != yes
90 then
91 AC_CACHE_CHECK([for working ncurses], ax_cv_ncurses,
92 [LIBS="$ax_save_LIBS -lncurses"
93 AC_TRY_LINK(
94 [#include <ncurses.h>],
95 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
96 ax_cv_ncurses=yes, ax_cv_ncurses=no)])
97 if test "$ax_cv_ncurses" = yes
98 then
99 AC_DEFINE([HAVE_NCURSES_H],[1],[Define if you have ncurses.h])
100 CURSES_LIB="-lncurses"
101 ax_cv_curses=yes
102 fi
103 fi
104 if test "$ax_cv_curses" != yes -a "$with_ncurses" != yes -a "$with_ncursesw" != yes
105 then
106 if test ! "$CURSES_LIB"
107 then
108 CURSES_LIB="-lcurses"
109 fi
110 AC_CACHE_CHECK([for working curses], ax_cv_curses,
111 [LIBS="$ax_save_LIBS $CURSES_LIB"
112 AC_TRY_LINK(
113 [#include <curses.h>],
114 [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
115 ax_cv_curses=yes, ax_cv_curses=no)])
116 if test "$ax_cv_curses" = yes
117 then
118 AC_DEFINE([HAVE_CURSES_H],[1],[Define if you have curses.h])
119 fi
120 fi
121 LIBS="$ax_save_LIBS"
122 ])dnl