1dnl acinclude.m4 - aclocal include file for "aclocal.m4"
2dnl Copyright 2000  Jochen Voss
3dnl $Id: acinclude.m4 5726 2004-06-01 21:22:28Z voss $
4
5dnl The idea of this tests, is to be as simple, as possible.
6dnl The only special case we check for, is old versions of
7dnl ncurses.  Any other problems must be handled by the user
8dnl via configure's --with-curses-includedir,
9dnl --with-curses-header, and --with-curses-libs options.
10
11AC_DEFUN([JV_CHECK_CURSES],[
12  dnl step 1: find the correct preprocessor flags
13  dnl         This is completely left to the user.
14  AC_MSG_CHECKING([for curses preprocessor flags])
15  AC_ARG_WITH(curses-includedir,
16    [  --with-curses-includedir[=DIR]
17                          special header file location for the curses library
18			  [none]],[
19    case "$withval" in
20      yes|no) ;;
21      *) CURSES_INCLUDEDIR="-I$withval" ;;
22    esac
23  ])
24  AC_SUBST(CURSES_INCLUDEDIR)
25  if test -z "$CURSES_INCLUDEDIR"; then
26    mb_result="none"
27  else
28    mb_result="$CURSES_INCLUDEDIR"
29  fi
30  AC_MSG_RESULT($mb_result)
31
32
33  dnl step 2: find the correct header file name
34  dnl         When nothing is specified on the command line, we try to guess.
35  AC_ARG_WITH(curses-header,
36    [  --with-curses-header[=ARG]
37                          the curses header file name (including brackets)
38			  [<curses.h>]],[
39    case "$withval" in
40      yes|no) ;;
41      *) CURSES_HEADER="$withval" ;;
42    esac
43  ])
44  if test -z "$CURSES_HEADER"; then
45    mb_save_CPPFLAGS="$CPPFLAGS"
46    CPPFLAGS="$CPPFLAGS $CURSES_INCLUDEDIR"
47    AC_CHECK_HEADERS(curses.h ncurses.h ncurses/ncurses.h ncurses/curses.h, break)
48    CPPFLAGS="$mb_save_CPPFLAGS"
49
50    if test "$ac_cv_header_curses_h" = yes; then
51      CURSES_HEADER="<curses.h>"
52    elif test "$ac_cv_header_ncurses_h" = yes; then
53      CURSES_HEADER="<ncurses.h>"
54    elif test "$ac_cv_header_ncurses_ncurses_h" = yes; then
55      CURSES_HEADER="<ncurses/ncurses.h>"
56    elif test "$ac_cv_header_ncurses_curses_h" = yes; then
57      CURSES_HEADER="<ncurses/curses.h>"
58    fi
59  fi
60  AC_MSG_CHECKING([how to include the curses header file])
61  if test -n "$CURSES_HEADER"; then
62    AC_DEFINE_UNQUOTED(CURSES_HEADER, $CURSES_HEADER, [Define to the curses header file name (including brackets). ])
63    AC_MSG_RESULT($CURSES_HEADER)
64  else
65    AC_MSG_RESULT([unknown])
66    AC_MSG_WARN([no curses header found, try --with-curses-header])
67  fi
68
69
70  dnl step 3: try to find the correct linker flags
71  dnl         When nothing is specified on the command line, we try to guess.
72  AC_ARG_WITH(curses-libs,
73    [  --with-curses-libs[=ARG]
74                          the -l and -L linker flags for the curses library
75			  [-lcurses]],[
76    case "$withval" in
77      yes|no) ;;
78      *) CURSES_LIBS="$withval" ;;
79    esac
80  ])
81  if test -z "$CURSES_LIBS"; then
82    AC_CHECK_LIB(curses,initscr,CURSES_LIBS=-lcurses)
83    if test -z "$CURSES_LIBS"; then
84      AC_CHECK_LIB(ncurses,initscr,CURSES_LIBS=-lncurses)
85    fi
86  fi
87  AC_MSG_CHECKING([for curses linker flags])
88  if test -n "$CURSES_LIBS"; then
89    AC_SUBST(CURSES_LIBS)
90    AC_MSG_RESULT($CURSES_LIBS)
91  else
92    AC_MSG_RESULT([unknown])
93    AC_MSG_WARN([curses library not found, try --with-curses-libs])
94  fi
95])
96