Commit | Line | Data |
---|---|---|
805e021f CE |
1 | dnl _OPENAFS_CURSES_HEADERS |
2 | dnl abstracting out the preprocessor gunk to #include curses | |
3 | AC_DEFUN([_OPENAFS_CURSES_HEADERS],[ | |
4 | #if defined(HAVE_NCURSES_H) | |
5 | # include <ncurses.h> | |
6 | #elif defined(HAVE_NCURSES_NCURSES_H) | |
7 | # include <ncurses/ncurses.h> | |
8 | #elif defined(HAVE_CURSES_H) | |
9 | # include <curses.h> | |
10 | #endif | |
11 | ]) | |
12 | ||
13 | dnl OPENAFS_CURSES_LIB([ACTION-IF-SUCCESS], [ACTION_IF_FAILURE]) | |
14 | dnl check for a working curses library and set $LIB_curses if so | |
15 | AC_DEFUN([OPENAFS_CURSES_LIB], | |
16 | [AC_CACHE_VAL([openafs_cv_curses_lib], | |
17 | [save_LIBS="$LIBS" | |
18 | openafs_cv_curses_lib= | |
19 | AC_CHECK_LIB([ncurses], [initscr], | |
20 | [AC_CHECK_LIB([ncurses], [LINES], [openafs_cv_curses_lib=-lncurses], | |
21 | [AC_CHECK_LIB([tinfo], [LINES], | |
22 | [openafs_cv_curses_lib="-lncurses -ltinfo"])])]) | |
23 | AS_IF([test "x$openafs_cv_curses_lib" = x], | |
24 | [AC_CHECK_LIB([Hcurses], [initscr], [openafs_cv_curses_lib=-lHcurses])]) | |
25 | AS_IF([test "x$openafs_cv_curses_lib" = x], | |
26 | [AC_CHECK_LIB([curses], [initscr], [openafs_cv_curses_lib=-lcurses])]) | |
27 | LIBS="$save_LIBS"]) | |
28 | LIB_curses="$openafs_cv_curses_lib" | |
29 | AC_SUBST(LIB_curses) | |
30 | AC_MSG_NOTICE([checking for curses library... ${openafs_cv_curses_lib:-none}]) | |
31 | AS_IF([test "x$openafs_cv_curses_lib" != x], [$1], [$2])]) | |
32 | ||
33 | dnl _OPENAFS_CURSES_GETMAXYX_XTI([ACTION-IF-SUCCESS], [ACTION_IF_FAILURE]) | |
34 | dnl test for XTI-standard getmaxyx() | |
35 | AC_DEFUN([_OPENAFS_CURSES_GETMAXYX_XTI], | |
36 | [dnl paranoid check because of complex macros in various curses impls | |
37 | AC_CACHE_CHECK([getmaxyx macro], [openafs_cv_curses_getmaxyx], | |
38 | [save_LIBS="$LIBS" | |
39 | LIBS="$LIBS $LIB_curses" | |
40 | AC_LINK_IFELSE( | |
41 | [AC_LANG_PROGRAM( | |
42 | _OPENAFS_CURSES_HEADERS, | |
43 | [int mx, my; initscr(); getmaxyx(stdscr, my, mx); endwin();])], | |
44 | [openafs_cv_curses_getmaxyx=yes], | |
45 | [openafs_cv_curses_getmaxyx=no]) | |
46 | LIBS="$save_LIBS"]) | |
47 | AS_IF([test x"$openafs_cv_curses_getmaxyx" = xyes], | |
48 | [AC_DEFINE(HAVE_GETMAXYX, 1, | |
49 | [define if your curses has the getmaxyx() macro]) | |
50 | $1], | |
51 | [$2])]) | |
52 | ||
53 | dnl _OPENAFS_CURSES_GETMAXYX_BSD43([ACTION-IF-SUCCESS], [ACTION_IF_FAILURE]) | |
54 | dnl test for getmaxx() and getmaxy() as from later BSD curses | |
55 | AC_DEFUN([_OPENAFS_CURSES_GETMAXYX_BSD43], | |
56 | [OPENAFS_CURSES_LIB | |
57 | save_LIBS="$LIBS" | |
58 | LIBS="$LIBS $LIB_curses" | |
59 | _openafs_curses_bsd43=yes | |
60 | dnl possibly this may need to be done as above in some cases? | |
61 | AC_CHECK_FUNCS([getmaxx getmaxy], [], [_openafs_curses_bsd43=no]) | |
62 | LIBS="$save_LIBS" | |
63 | AS_IF([test "$_openafs_curses_bsd43" = yes], [$1], [$2])]) | |
64 | ||
65 | dnl _OPENAFS_CURSES_GETMAXYX_BSDVI([ACTION-IF-SUCCESS], [ACTION_IF_FAILURE]) | |
66 | dnl test for getmaxx() and getmaxy() as from BSD curses as bodily ripped | |
67 | dnl out of the original vi sources | |
68 | AC_DEFUN([_OPENAFS_CURSES_GETMAXYX_BSDVI], | |
69 | [OPENAFS_CURSES_LIB | |
70 | save_LIBS="$LIBS" | |
71 | LIBS="$LIBS $LIB_curses" | |
72 | _openafs_curses_bsdvi=yes | |
73 | AC_CHECK_MEMBERS([WINDOW._maxx WINDOW._maxy], [], [_openafs_curses_bsdvi=no], | |
74 | _OPENAFS_CURSES_HEADERS) | |
75 | LIBS="$save_LIBS" | |
76 | AS_IF([test "$_openafs_curses_bsdvi" = yes], [$1], [$2])]) | |
77 | ||
78 | dnl OPENAFS_CURSES_WINDOW_EXTENTS([ACTION-IF-SUCCESS], [ACTION_IF_FAILURE]) | |
79 | dnl check for standard getmaxyx macro. failing that, try the | |
80 | dnl older getmaxx and getmaxy functions/macros; failing those, | |
81 | dnl try the 4.2BSD _maxx and _maxy fields | |
82 | AC_DEFUN([OPENAFS_CURSES_WINDOW_EXTENTS], | |
83 | [OPENAFS_CURSES_LIB | |
84 | openafs_curses_extent=none | |
85 | _OPENAFS_CURSES_GETMAXYX_XTI([openafs_curses_extent=xti]) | |
86 | AS_IF([test "$openafs_curses_extent" = none], | |
87 | [_OPENAFS_CURSES_GETMAXYX_BSD43([openafs_curses_extent=bsd])]) | |
88 | AS_IF([test "$openafs_curses_extent" = none], | |
89 | [_OPENAFS_CURSES_GETMAXYX_BSDVI([openafs_curses_extent=vi])],) | |
90 | AS_IF([test "$openafs_curses_extent" != none], [$1], [$2])]) | |
91 | ||
92 | dnl The top level curses group | |
93 | AC_DEFUN([OPENAFS_CURSES], | |
94 | [AC_ARG_ENABLE([gtx], | |
95 | [AS_HELP_STRING([--disable-gtx], [disable gtx curses-based terminal tools])]) | |
96 | AS_IF([test "x$enable_gtx" != "xno"], | |
97 | [OPENAFS_CURSES_LIB([], [enable_gtx=no])]) | |
98 | AS_IF([test "x$enable_gtx" != "xno"], | |
99 | [OPENAFS_CURSES_WINDOW_EXTENTS([], [enable_gtx=no])])]) |