Skip to content

Commit

Permalink
Make configure check for ncurses header files
Browse files Browse the repository at this point in the history
First ncursesw/ncurses.h, then ncurses/ncurses.h, and finally ncurses.h.
Also include ncurses.h by default instead of curses.h. On most system
ncurses.h should be a symlink to curses.h and this will avoid the
problem of including a non-ncurses header file.

This should fix systems like Solaris who ships their own version of
/usr/include/curses.h that is incompatible with ncurses.

Reported by SungHyun Nam.
  • Loading branch information
jonas committed Apr 24, 2008
1 parent 50efd29 commit 7a5eba3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -9,6 +9,7 @@ Improvements:
- F5 also refreshes the current view.
- Allow line graphics to be disabled with new line-graphics option.
- Also include the reference names when searching.
- Configure: check for the ncurses header files.

Bug fixes:

Expand Down
26 changes: 15 additions & 11 deletions configure.ac
@@ -1,13 +1,23 @@
AC_INIT([tig], [0],
[Jonas Fonseca <fonseca@diku.dk>],
[tig])
AC_INIT([tig], [0], [Jonas Fonseca <fonseca@diku.dk>], [tig])

AC_LANG([C])
AC_CONFIG_HEADER(config.h)
AC_CONFIG_SRCDIR(tig.c)

AC_SEARCH_LIBS([wclear], [ncursesw ncurses curses], [],
[AC_ERROR([curses not found])])
cursed=no
AC_CHECK_HEADERS([ncursesw/ncurses.h],
[AC_SEARCH_LIBS([initscr], [ncursesw], [cursed=yes])])
case "$cursed" in "no")
AC_CHECK_HEADERS([ncurses/ncurses.h ncurses.h],
[AC_SEARCH_LIBS([wclear], [ncurses], [cursed=yes])])

case "$cursed" in "no")
AC_ERROR([ncurses not found])
esac

AC_MSG_WARN([The found ncurses library does not support wide-char.])
AC_MSG_WARN([This means that tig will not correctly render UTF-8.])
esac

AM_ICONV

Expand All @@ -26,9 +36,3 @@ AC_CHECK_PROGS(DOCBOOK2PDF, [docbook2pdf false])

AC_CONFIG_FILES([config.make])
AC_OUTPUT

case "$LIBS" in
*-lncursesw*) ;;
*) AC_MSG_RESULT([NOTE: The found ncurses library does not support wide-char.])
AC_MSG_RESULT([NOTE: This means that tig will not correctly render UTF-8])
esac
10 changes: 9 additions & 1 deletion tig.c
Expand Up @@ -45,7 +45,15 @@
/* ncurses(3): Must be defined to have extended wide-character functions. */
#define _XOPEN_SOURCE_EXTENDED

#include <curses.h>
#ifdef HAVE_NCURSESW_NCURSES_H
#include <ncursesw/ncurses.h>
#else
#ifdef HAVE_NCURSES_NCURSES_H
#include <ncurses/ncurses.h>
#else
#include <ncurses.h>
#endif
#endif

#if __GNUC__ >= 3
#define __NORETURN __attribute__((__noreturn__))
Expand Down

0 comments on commit 7a5eba3

Please sign in to comment.