Browse Source

Detect curses support for wide characters during configure

Luke Dashjr 12 years ago
parent
commit
801337c8b0
2 changed files with 39 additions and 22 deletions
  1. 37 18
      configure.ac
  2. 2 4
      miner.c

+ 37 - 18
configure.ac

@@ -505,27 +505,46 @@ else
 		fi
 	fi
 	if test "x$curses" != "xyes"; then
-
-	AC_SEARCH_LIBS(addstr, ${preferl}, [
-		curses=yes
-		cursesmsg="FOUND: ${ac_cv_search_addstr}"
-		cursesmsg="${cursesmsg/-l/}"
-		if test "x${ac_cv_search_addstr}" != "xnone required"; then
-			NCURSES_LIBS="${ac_cv_search_addstr}"
-		fi
-	], [
-		if test "x$curses" = "xyes"; then
-			AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
-		else
-			AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
-			curses=no
-			cursesmsg='NOT FOUND. TUI support DISABLED'
-		fi
-	])
-
+		for sym in addwstr addstr; do
+			AC_SEARCH_LIBS(${sym}, ${preferl}, [
+				curses=yes
+				eval "curseslib=\"\${ac_cv_search_${sym}}\""
+				cursesmsg="FOUND: ${curseslib}"
+				cursesmsg="${cursesmsg/-l/}"
+				if test "x${curseslib}" != "xnone required"; then
+					NCURSES_LIBS="${curseslib}"
+				fi
+				break
+			], [
+				test "x$sym" != "addstr" && continue
+				
+				if test "x$curses" = "xyes"; then
+					AC_MSG_ERROR([Could not find curses library - please install libncurses-dev or pdcurses-dev (or configure --without-curses)])
+				else
+					AC_MSG_WARN([Could not find curses library - if you want a TUI, install libncurses-dev or pdcurses-dev])
+					curses=no
+					cursesmsg='NOT FOUND. TUI support DISABLED'
+				fi
+			])
+		done
 	fi
 	if test "x$curses" = "xyes"; then
 		AC_DEFINE([HAVE_CURSES], [1], [Defined to 1 if curses TUI support is wanted])
+		AC_MSG_CHECKING([whether curses library supports wide characters])
+		LIBS="$orig_libs $NCURSES_CPPFLAGS $NCURSES_LIBS"
+		AC_LINK_IFELSE([
+			AC_LANG_PROGRAM([
+				#define PDC_WIDE
+				#include <curses.h>
+			],[
+				addwstr(L"test");
+			])
+		],[
+			AC_MSG_RESULT([yes])
+			AC_DEFINE([USE_UNICODE],[1],[Defined to 1 if curses supports wide characters])
+		],[
+			AC_MSG_RESULT([no])
+		])
 	fi
 	LIBS="$orig_libs"
 fi

+ 2 - 4
miner.c

@@ -13,12 +13,10 @@
 #include "config.h"
 
 #ifdef HAVE_CURSES
+#ifdef USE_UNICODE
 #define PDC_WIDE
-#include <curses.h>
-
-#ifdef WACS_HLINE
-#define USE_UNICODE
 #endif
+#include <curses.h>
 #endif
 
 #include <ctype.h>