Remove all checking for the various terminfo headers (term.h and

curses.h). Finding these headers is next to impossible. For example, on
Debian systems libtinfo-dev provides the terminfo reading library we
want, but *not* term.h. For the header, you have to use libncurses-dev.
And libncursesw-dev provides a *different* term.h in a different
location!

These headers aren't worth it. We want two functions the signatures of
which are clearly spec'ed in sys-v and other documentation. Just declare
them ourselves and call them. This should fix some debian builders and
provide better support for "minimal" debian systems that do want color
autodetection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188165 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2013-08-12 10:40:11 +00:00
parent dfb5ceae90
commit 3729d7d62b
6 changed files with 11 additions and 252 deletions

View File

@ -1573,11 +1573,6 @@ else
AC_SUBST(HAVE_LIBZ, 0) AC_SUBST(HAVE_LIBZ, 0)
fi fi
dnl Try to find a suitable curses header.
if test "$llvm_cv_enable_terminfo" = "yes" ; then
AC_CHECK_HEADERS([term.h curses.h ncurses.h ncursesw.h ncurses/curses.h ncursesw/curses.h])
fi
dnl Try to find ffi.h. dnl Try to find ffi.h.
if test "$llvm_cv_enable_libffi" = "yes" ; then if test "$llvm_cv_enable_libffi" = "yes" ; then
AC_CHECK_HEADERS([ffi.h ffi/ffi.h]) AC_CHECK_HEADERS([ffi.h ffi/ffi.h])

View File

@ -74,13 +74,6 @@ check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)
check_include_file(mach/mach.h HAVE_MACH_MACH_H) check_include_file(mach/mach.h HAVE_MACH_MACH_H)
check_include_file(mach-o/dyld.h HAVE_MACH_O_DYLD_H) check_include_file(mach-o/dyld.h HAVE_MACH_O_DYLD_H)
check_include_file(term.h HAVE_TERM_H)
check_include_file(curses.h HAVE_CURSES_H)
check_include_file(ncurses.h HAVE_NCURSES_H)
check_include_file(ncursesw.h HAVE_NCURSESW_H)
check_include_file(ncurses/curses.h HAVE_NCURSES_CURSES_H)
check_include_file(ncursesw/curses.h HAVE_NCURSESW_CURSES_H)
# library checks # library checks
if( NOT PURE_WINDOWS ) if( NOT PURE_WINDOWS )
check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD) check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
@ -104,9 +97,7 @@ if( NOT PURE_WINDOWS )
else() else()
set(HAVE_LIBZ 0) set(HAVE_LIBZ 0)
endif() endif()
if(LLVM_ENABLE_TERMINFO AND if(LLVM_ENABLE_TERMINFO)
(HAVE_TERM_H OR HAVE_CURSES_H OR HAVE_NCURSES_H OR HAVE_NCURSESW_H OR
HAVE_NCURSES_CURSES_H OR HAVE_NCURSESW_CURSES_H))
set(HAVE_TERMINFO 0) set(HAVE_TERMINFO 0)
foreach(library tinfo curses ncurses ncursesw) foreach(library tinfo curses ncurses ncursesw)
string(TOUPPER ${library} library_suffix) string(TOUPPER ${library} library_suffix)

177
configure vendored
View File

@ -16543,183 +16543,6 @@ else
fi fi
if test "$llvm_cv_enable_terminfo" = "yes" ; then
for ac_header in term.h curses.h ncurses.h ncursesw.h ncurses/curses.h ncursesw/curses.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
else
# Is the header compilable?
{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_try") 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6; }
# Is the header present?
{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <$ac_header>
_ACEOF
if { (ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6; }
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
yes:no: )
{ echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
ac_header_preproc=yes
;;
no:yes:* )
{ echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
{ echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
( cat <<\_ASBOX
## ------------------------------------ ##
## Report this to http://llvm.org/bugs/ ##
## ------------------------------------ ##
_ASBOX
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
{ echo "$as_me:$LINENO: checking for $ac_header" >&5
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
eval "$as_ac_Header=\$ac_header_preproc"
fi
ac_res=`eval echo '${'$as_ac_Header'}'`
{ echo "$as_me:$LINENO: result: $ac_res" >&5
echo "${ECHO_T}$ac_res" >&6; }
fi
if test `eval echo '${'$as_ac_Header'}'` = yes; then
cat >>confdefs.h <<_ACEOF
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF
fi
done
fi
if test "$llvm_cv_enable_libffi" = "yes" ; then if test "$llvm_cv_enable_libffi" = "yes" ; then

View File

@ -48,9 +48,6 @@
/* Define to 1 if you have the `closedir' function. */ /* Define to 1 if you have the `closedir' function. */
#cmakedefine HAVE_CLOSEDIR ${HAVE_CLOSEDIR} #cmakedefine HAVE_CLOSEDIR ${HAVE_CLOSEDIR}
/* Define to 1 if you have the <curses.h> header file. */
#cmakedefine HAVE_CURSES_H
/* Define to 1 if you have the <cxxabi.h> header file. */ /* Define to 1 if you have the <cxxabi.h> header file. */
#cmakedefine HAVE_CXXABI_H ${HAVE_CXXABI_H} #cmakedefine HAVE_CXXABI_H ${HAVE_CXXABI_H}
@ -259,18 +256,6 @@
/* Define if mmap() can map files into memory */ /* Define if mmap() can map files into memory */
#undef HAVE_MMAP_FILE #undef HAVE_MMAP_FILE
/* Define to 1 if you have the <ncursesw/curses.h> header file. */
#cmakedefine HAVE_NCURSESW_CURSES_H
/* Define to 1 if you have the <ncursesw.h> header file. */
#cmakedefine HAVE_NCURSESW_H
/* Define to 1 if you have the <ncurses/curses.h> header file. */
#cmakedefine HAVE_NCURSES_CURSES_H
/* Define to 1 if you have the <ncurses.h> header file. */
#cmakedefine HAVE_NCURSES_H
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#cmakedefine HAVE_NDIR_H ${HAVE_NDIR_H} #cmakedefine HAVE_NDIR_H ${HAVE_NDIR_H}
@ -423,9 +408,6 @@
/* Define to 1 if you have the <termios.h> header file. */ /* Define to 1 if you have the <termios.h> header file. */
#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H} #cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H}
/* Define to 1 if you have the <term.h> header file. */
#cmakedefine HAVE_TERM_H
/* Define if the neat program is available */ /* Define if the neat program is available */
#cmakedefine HAVE_TWOPI ${HAVE_TWOPI} #cmakedefine HAVE_TWOPI ${HAVE_TWOPI}

View File

@ -69,9 +69,6 @@
/* can use __crashreporter_info__ */ /* can use __crashreporter_info__ */
#undef HAVE_CRASHREPORTER_INFO #undef HAVE_CRASHREPORTER_INFO
/* Define to 1 if you have the <curses.h> header file. */
#undef HAVE_CURSES_H
/* Define to 1 if you have the <cxxabi.h> header file. */ /* Define to 1 if you have the <cxxabi.h> header file. */
#undef HAVE_CXXABI_H #undef HAVE_CXXABI_H
@ -285,18 +282,6 @@
/* Define if mmap() can map files into memory */ /* Define if mmap() can map files into memory */
#undef HAVE_MMAP_FILE #undef HAVE_MMAP_FILE
/* Define to 1 if you have the <ncursesw/curses.h> header file. */
#undef HAVE_NCURSESW_CURSES_H
/* Define to 1 if you have the <ncursesw.h> header file. */
#undef HAVE_NCURSESW_H
/* Define to 1 if you have the <ncurses/curses.h> header file. */
#undef HAVE_NCURSES_CURSES_H
/* Define to 1 if you have the <ncurses.h> header file. */
#undef HAVE_NCURSES_H
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */ /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H #undef HAVE_NDIR_H
@ -458,9 +443,6 @@
/* Define to 1 if you have the <termios.h> header file. */ /* Define to 1 if you have the <termios.h> header file. */
#undef HAVE_TERMIOS_H #undef HAVE_TERMIOS_H
/* Define to 1 if you have the <term.h> header file. */
#undef HAVE_TERM_H
/* Define if the neat program is available */ /* Define if the neat program is available */
#undef HAVE_TWOPI #undef HAVE_TWOPI

View File

@ -38,28 +38,6 @@
# include <termios.h> # include <termios.h>
#endif #endif
// Pull in the headers we found to go with the terminfo reading library (tinfo,
// curses, whatever it may be). We have to pull in the 'curses.h' header as the
// SysV spec only provides certain values and defines from that header even
// though we work hard to not link against all of the curses implementation
// when avoidable.
#ifdef HAVE_TERMINFO
# if defined(HAVE_CURSES_H)
# include <curses.h>
# elif defined(HAVE_NCURSES_H)
# include <ncurses.h>
# elif defined(HAVE_NCURSESW_H)
# include <ncursesw.h>
# elif defined(HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
# elif defined(HAVE_NCURSESW_CURSES_H)
# include <ncursesw/curses.h>
# endif
# if defined(HAVE_TERM_H)
# include <term.h>
# endif
#endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only generic UNIX code that //=== WARNING: Implementation here must contain only generic UNIX code that
//=== is guaranteed to work on *all* UNIX variants. //=== is guaranteed to work on *all* UNIX variants.
@ -269,6 +247,14 @@ unsigned Process::StandardErrColumns() {
return getColumns(2); return getColumns(2);
} }
#ifdef HAVE_TERMINFO
// We manually declare these two extern functions because finding the correct
// headers from various terminfo, curses, or other sources is harder than
// writing their specs down.
extern "C" int setupterm(char *term, int filedes, int *errret);
extern "C" int tigetnum(char *capname);
#endif
static bool terminalHasColors(int fd) { static bool terminalHasColors(int fd) {
#ifdef HAVE_TERMINFO #ifdef HAVE_TERMINFO
// First, acquire a global lock because these C routines are thread hostile. // First, acquire a global lock because these C routines are thread hostile.
@ -276,7 +262,7 @@ static bool terminalHasColors(int fd) {
MutexGuard G(M); MutexGuard G(M);
int errret = 0; int errret = 0;
if (setupterm((char *)0, fd, &errret) != OK) if (setupterm((char *)0, fd, &errret) != 0)
// Regardless of why, if we can't get terminfo, we shouldn't try to print // Regardless of why, if we can't get terminfo, we shouldn't try to print
// colors. // colors.
return false; return false;
@ -294,7 +280,7 @@ static bool terminalHasColors(int fd) {
// //
// The 'tigetnum' routine returns -2 or -1 on errors, and might return 0 if // The 'tigetnum' routine returns -2 or -1 on errors, and might return 0 if
// the terminfo says that no colors are supported. // the terminfo says that no colors are supported.
if (tigetnum("colors") > 0) if (tigetnum((char *)"colors") > 0)
return true; return true;
#endif #endif