summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3cbb9e7)
raw | patch | inline | side by side (parent: 3cbb9e7)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 3 Oct 2010 03:12:38 +0000 (23:12 -0400) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 3 Oct 2010 03:15:26 +0000 (23:15 -0400) |
Makefile | patch | blob | history | |
config.make.in | patch | blob | history | |
configure.ac | patch | blob | history | |
contrib/ax_with_curses.m4 | [new file with mode: 0644] | patch | blob |
tig.c | patch | blob | history |
diff --git a/Makefile b/Makefile
index ced5be310ee5a9f66f87e3b653b3cf4077930c43..86c455a72b1925256bdd34fd5ab7d3d85725a100 100644 (file)
--- a/Makefile
+++ b/Makefile
rpmbuild -ta $(TARNAME).tar.gz
configure: configure.ac acinclude.m4
- $(AUTORECONF) -v
+ $(AUTORECONF) -v -I contrib
.PHONY: all all-debug doc doc-man doc-html install install-doc \
install-doc-man install-doc-html clean spell-check dist rpm
diff --git a/config.make.in b/config.make.in
index 3962050d2bc906b09dd732975a91a4a38b8e4a70..97135e0578dc49ae81adb9c731260c990b5c29eb 100644 (file)
--- a/config.make.in
+++ b/config.make.in
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@ -DHAVE_CONFIG_H
LDFLAGS = @LDFLAGS@
-LDLIBS = @LIBS@
+LDLIBS = @LIBS@ @CURSES_LIB@
ASCIIDOC = @ASCIIDOC@
XMLTO = @XMLTO@
diff --git a/configure.ac b/configure.ac
index e209afe6a7814bbe9e6e4e17b20153ac2a2f7104..236d5f93dd876f34ad338fe35ecb1d669c69ad1b 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_CONFIG_HEADER(config.h)
AC_CONFIG_SRCDIR(tig.c)
-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
-
+AX_WITH_CURSES
+case "$ax_cv_ncurses" in "no")
+ AC_ERROR([ncurses not found])
+esac
+case "$ax_cv_ncursesw" in "no")
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
+AC_SUBST(CURSES_LIB)
AM_ICONV
diff --git a/contrib/ax_with_curses.m4 b/contrib/ax_with_curses.m4
--- /dev/null
@@ -0,0 +1,122 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_with_curses.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_WITH_CURSES
+#
+# DESCRIPTION
+#
+# Detect SysV compatible curses, such as ncurses.
+#
+# Defines HAVE_CURSES_H or HAVE_NCURSES_H if curses is found. CURSES_LIB
+# is also set with the required library, but is not appended to LIBS
+# automatically. If no working curses library is found CURSES_LIB will be
+# left blank. If CURSES_LIB is set in the environment, the supplied value
+# will be used.
+#
+# There are two options: --with-ncurses forces the use of ncurses, and
+# --with-ncursesw forces the use of ncursesw (wide character ncurses). The
+# corresponding options --without-ncurses and --without-ncursesw force
+# those libraries not to be used. By default, ncursesw is preferred to
+# ncurses, which is preferred to plain curses.
+#
+# ax_cv_curses is set to "yes" if any curses is found (including
+# ncurses!); ax_cv_ncurses is set to "yes" if any ncurses is found, and
+# ax_cv_ncursesw is set to "yes" if ncursesw is found.
+#
+# LICENSE
+#
+# Copyright (c) 2009 Mark Pulford <mark@kyne.com.au>
+# Copyright (c) 2009 Damian Pietras <daper@daper.net>
+# Copyright (c) 2009 Reuben Thomas <rrt@sc3d.org>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 6
+
+AU_ALIAS([MP_WITH_CURSES], [AX_WITH_CURSES])
+AC_DEFUN([AX_WITH_CURSES],
+ [AC_ARG_WITH(ncurses, [AS_HELP_STRING([--with-ncurses],
+ [Force the use of ncurses over curses])],,)
+ ax_save_LIBS="$LIBS"
+ AC_ARG_WITH(ncursesw, [AS_HELP_STRING([--without-ncursesw],
+ [Don't use ncursesw (wide character support)])],,)
+ if test ! "$CURSES_LIB" -a "$with_ncurses" != no -a "$with_ncursesw" != "no"
+ then
+ AC_CACHE_CHECK([for working ncursesw], ax_cv_ncursesw,
+ [LIBS="$ax_save_LIBS -lncursesw"
+ AC_TRY_LINK(
+ [#include <ncurses.h>],
+ [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
+ ax_cv_ncursesw=yes, ax_cv_ncursesw=no)])
+ if test "$ax_cv_ncursesw" = yes
+ then
+ AC_CHECK_HEADER([ncursesw/curses.h], AC_DEFINE(HAVE_NCURSESW_H, 1,
+ [Define if you have ncursesw.h]))
+ AC_DEFINE(HAVE_NCURSES_H, 1, [Define if you have ncursesw/curses.h])
+ AC_DEFINE(HAVE_NCURSESW, 1, [Define if you have libncursesw])
+ CURSES_LIB="-lncursesw"
+ ax_cv_ncurses=yes
+ ax_cv_curses=yes
+ fi
+ fi
+ if test ! "$CURSES_LIB" -a "$with_ncurses" != no -a "$with_ncursesw" != yes
+ then
+ AC_CACHE_CHECK([for working ncurses], ax_cv_ncurses,
+ [LIBS="$ax_save_LIBS -lncurses"
+ AC_TRY_LINK(
+ [#include <ncurses.h>],
+ [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
+ ax_cv_ncurses=yes, ax_cv_ncurses=no)])
+ if test "$ax_cv_ncurses" = yes
+ then
+ AC_DEFINE([HAVE_NCURSES_H],[1],[Define if you have ncurses.h])
+ CURSES_LIB="-lncurses"
+ ax_cv_curses=yes
+ fi
+ fi
+ if test "$ax_cv_curses" != yes -a "$with_ncurses" != yes -a "$with_ncursesw" != yes
+ then
+ if test ! "$CURSES_LIB"
+ then
+ CURSES_LIB="-lcurses"
+ fi
+ AC_CACHE_CHECK([for working curses], ax_cv_curses,
+ [LIBS="$ax_save_LIBS $CURSES_LIB"
+ AC_TRY_LINK(
+ [#include <curses.h>],
+ [chtype a; int b=A_STANDOUT, c=KEY_LEFT; initscr(); ],
+ ax_cv_curses=yes, ax_cv_curses=no)])
+ if test "$ax_cv_curses" = yes
+ then
+ AC_DEFINE([HAVE_CURSES_H],[1],[Define if you have curses.h])
+ fi
+ fi
+ LIBS="$ax_save_LIBS"
+])dnl
index fd19f5403e8351618b37e2e1a97bcc1af9a6906b..801fccd4914e0338a8e23e576d3dded09f8ee8a2 100644 (file)
--- a/tig.c
+++ b/tig.c
/* ncurses(3): Must be defined to have extended wide-character functions. */
#define _XOPEN_SOURCE_EXTENDED
-#ifdef HAVE_NCURSESW_NCURSES_H
+#ifdef HAVE_NCURSESW_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__))