Updating ChangeLog for 4.22.10
[centerim.git] / m4 / ax_with_curses.m4
blob344e6d54633418471aeb7711772023918bef028c
1 # ===========================================================================
2 #         http://www.nongnu.org/autoconf-archive/ax_with_curses.html
3 # ===========================================================================
5 # SYNOPSIS
7 #   AX_WITH_CURSES
9 # DESCRIPTION
11 #   Detect SysV compatible curses, such as ncurses.
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.
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.
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.
29 # LICENSE
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>
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.
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.
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/>.
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.
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 AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
62 AC_DEFUN([AX_WITH_CURSES],
63   [AC_ARG_WITH(ncurses, [AC_HELP_STRING([--with-ncurses],
64         [Force the use of ncurses over curses])],,)
65    ax_save_LIBS="$LIBS"
66    AC_ARG_WITH(ncursesw, [AC_HELP_STRING([--without-ncursesw],
67         [Don't use ncursesw (wide character support)])],,)
68    if test ! "$CURSES_LIB" -a "$with_ncurses" != no -a "$with_ncursesw" != "no"
69    then
70        AC_CACHE_CHECK([for working ncursesw], ax_cv_ncursesw,
71          [LIBS="$ax_save_LIBS -lncursesw"
72           AC_TRY_LINK(
73             [#include <ncurses.h>],
74             [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
75             ax_cv_ncursesw=yes, ax_cv_ncursesw=no)])
76        if test "$ax_cv_ncursesw" = yes
77        then
78          AC_CHECK_HEADER([ncursesw/cursesw.h], AC_DEFINE(HAVE_NCURSESW_H, 1,
79             [Define if you have ncursesw/cursesw.h]))
80          AC_CHECK_HEADER([ncursesw/curses.h], AC_DEFINE(HAVE_NCURSES_H, 1,
81             [Define if you have ncursesw/curses.h]))
82          AC_DEFINE(HAVE_NCURSESW, 1, [Define if you have libncursesw])
83          CURSES_LIB="-lncursesw"
84          ax_cv_ncurses=yes
85          ax_cv_curses=yes
86        fi
87    fi
88    if test ! "$CURSES_LIB" -a "$with_ncurses" != no -a "$with_ncursesw" != yes
89    then
90      AC_CACHE_CHECK([for working ncurses], ax_cv_ncurses,
91        [LIBS="$ax_save_LIBS -lncurses"
92         AC_TRY_LINK(
93           [#include <ncurses.h>],
94           [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
95           ax_cv_ncurses=yes, ax_cv_ncurses=no)])
96      if test "$ax_cv_ncurses" = yes
97      then
98        AC_DEFINE([HAVE_NCURSES_H],[1],[Define if you have ncurses.h])
99        CURSES_LIB="-lncurses"
100        ax_cv_curses=yes
101      fi
102    fi
103    if test "$ax_cv_curses" != yes -a "$with_ncurses" != yes -a "$with_ncursesw" != yes
104    then
105      if test ! "$CURSES_LIB"
106      then
107        CURSES_LIB="-lcurses"
108      fi
109      AC_CACHE_CHECK([for working curses], ax_cv_curses,
110        [LIBS="$ax_save_LIBS $CURSES_LIB"
111         AC_TRY_LINK(
112           [#include <curses.h>],
113           [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
114           ax_cv_curses=yes, ax_cv_curses=no)])
115      if test "$ax_cv_curses" = yes
116      then
117        AC_DEFINE([HAVE_CURSES_H],[1],[Define if you have curses.h])
118      fi
119    fi
120    LIBS="$ax_save_LIBS"
121 ])dnl