Skip to content

Commit

Permalink
Update the sample project autoconf setup to include support for
Browse files Browse the repository at this point in the history
detecting terminfo. Requested by Craig Topper, and probably should be
done much more systematically.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188616 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
chandlerc committed Aug 18, 2013
1 parent d485e7b commit b5d5797
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 1 deletion.
19 changes: 19 additions & 0 deletions projects/sample/autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,17 @@ AC_ARG_WITH(bug-report-url,
AC_DEFINE_UNQUOTED(BUG_REPORT_URL,"$withval",
[Bug report URL.])

dnl --enable-terminfo: check whether the user wants to control use of terminfo:
AC_ARG_ENABLE(terminfo,AS_HELP_STRING(
[--enable-terminfo],
[Query the terminfo database if available (default is YES)]),
[case "$enableval" in
yes) llvm_cv_enable_terminfo="yes" ;;
no) llvm_cv_enable_terminfo="no" ;;
*) AC_MSG_ERROR([Invalid setting for --enable-terminfo. Use "yes" or "no"]) ;;
esac],
llvm_cv_enable_terminfo="yes")

dnl --enable-libffi : check whether the user wants to turn off libffi:
AC_ARG_ENABLE(libffi,AS_HELP_STRING(
--enable-libffi,[Check for the presence of libffi (default is NO)]),
Expand Down Expand Up @@ -1068,6 +1079,14 @@ AC_SEARCH_LIBS(dlopen,dl,AC_DEFINE([HAVE_DLOPEN],[1],
[Define if dlopen() is available on this platform.]),
AC_MSG_WARN([dlopen() not found - disabling plugin support]))

dnl The curses library is optional; used for querying terminal info
if test "$llvm_cv_enable_terminfo" = "yes" ; then
dnl We need the has_color functionality in curses for it to be useful.
AC_SEARCH_LIBS(setupterm,tinfo curses ncurses ncursesw,
AC_DEFINE([HAVE_TERMINFO],[1],
[Define if the setupterm() function is supported this platform.]))
fi

dnl libffi is optional; used to call external functions from the interpreter
if test "$llvm_cv_enable_libffi" = "yes" ; then
AC_SEARCH_LIBS(ffi_call,ffi,AC_DEFINE([HAVE_FFI_CALL],[1],
Expand Down
124 changes: 123 additions & 1 deletion projects/sample/configure
Original file line number Diff line number Diff line change
Expand Up @@ -1409,6 +1409,8 @@ Optional Features:
(default=all)
--enable-bindings Build specific language bindings:
all,auto,none,{binding-name} (default=auto)
--enable-terminfo Query the terminfo database if available (default is
YES)
--enable-libffi Check for the presence of libffi (default is NO)
--enable-ltdl-install install libltdl

Expand Down Expand Up @@ -5604,6 +5606,20 @@ cat >>confdefs.h <<_ACEOF
_ACEOF


# Check whether --enable-terminfo was given.
if test "${enable_terminfo+set}" = set; then
enableval=$enable_terminfo; case "$enableval" in
yes) llvm_cv_enable_terminfo="yes" ;;
no) llvm_cv_enable_terminfo="no" ;;
*) { { echo "$as_me:$LINENO: error: Invalid setting for --enable-terminfo. Use \"yes\" or \"no\"" >&5
echo "$as_me: error: Invalid setting for --enable-terminfo. Use \"yes\" or \"no\"" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
else
llvm_cv_enable_terminfo="yes"
fi


# Check whether --enable-libffi was given.
if test "${enable_libffi+set}" = set; then
enableval=$enable_libffi; case "$enableval" in
Expand Down Expand Up @@ -10339,7 +10355,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 10342 "configure"
#line 10358 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -12462,6 +12478,112 @@ echo "$as_me: WARNING: dlopen() not found - disabling plugin support" >&2;}
fi


if test "$llvm_cv_enable_terminfo" = "yes" ; then
{ echo "$as_me:$LINENO: checking for library containing setupterm" >&5
echo $ECHO_N "checking for library containing setupterm... $ECHO_C" >&6; }
if test "${ac_cv_search_setupterm+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_func_search_save_LIBS=$LIBS
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */

/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char setupterm ();
int
main ()
{
return setupterm ();
;
return 0;
}
_ACEOF
for ac_lib in '' tinfo curses ncurses ncursesw; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
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_link") 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_exeext'
{ (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_cv_search_setupterm=$ac_res
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5


fi

rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if test "${ac_cv_search_setupterm+set}" = set; then
break
fi
done
if test "${ac_cv_search_setupterm+set}" = set; then
:
else
ac_cv_search_setupterm=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ echo "$as_me:$LINENO: result: $ac_cv_search_setupterm" >&5
echo "${ECHO_T}$ac_cv_search_setupterm" >&6; }
ac_res=$ac_cv_search_setupterm
if test "$ac_res" != no; then
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"

cat >>confdefs.h <<\_ACEOF
#define HAVE_TERMINFO 1
_ACEOF

fi

fi

if test "$llvm_cv_enable_libffi" = "yes" ; then
{ echo "$as_me:$LINENO: checking for library containing ffi_call" >&5
echo $ECHO_N "checking for library containing ffi_call... $ECHO_C" >&6; }
Expand Down

0 comments on commit b5d5797

Please sign in to comment.