diff --git a/menuselect/Makefile b/menuselect/Makefile index d949efd559..da4a6c080e 100644 --- a/menuselect/Makefile +++ b/menuselect/Makefile @@ -41,6 +41,10 @@ ifdef NCURSES_LIB C_LIBS +=$(NCURSES_LIB) C_INCLUDE += $(NCURSES_INCLUDE) ALL_TGTS += cmenuselect + CFLAGS += -DHAVE_NCURSES + ifeq ($(HAVE_NCURSES_SUBDIR),yes) + CFLAGS += -DHAVE_NCURSES_SUBDIR + endif else ifdef CURSES_LIB C_OBJS += menuselect_curses.o diff --git a/menuselect/configure b/menuselect/configure index 7cbe477569..8efb6372e8 100755 --- a/menuselect/configure +++ b/menuselect/configure @@ -634,6 +634,7 @@ PKG_CONFIG_PATH PKG_CONFIG CONFIG_LIBXML2 SED +HAVE_NCURSES_SUBDIR PBX_LIBXML2 LIBXML2_DIR LIBXML2_INCLUDE @@ -4012,6 +4013,201 @@ fi +if test "x${PBX_NCURSES}" != "x1" -a "${USE_NCURSES}" != "no"; then + pbxlibdir="" + # if --with-NCURSES=DIR has been specified, use it. + if test "x${NCURSES_DIR}" != "x"; then + if test -d ${NCURSES_DIR}/lib; then + pbxlibdir="-L${NCURSES_DIR}/lib" + else + pbxlibdir="-L${NCURSES_DIR}" + fi + fi + + ast_ext_lib_check_save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} " + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncurses" >&5 +$as_echo_n "checking for initscr in -lncurses... " >&6; } +if ${ac_cv_lib_ncurses_initscr+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lncurses ${pbxlibdir} $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* 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 initscr (); +int +main () +{ +return initscr (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ncurses_initscr=yes +else + ac_cv_lib_ncurses_initscr=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_initscr" >&5 +$as_echo "$ac_cv_lib_ncurses_initscr" >&6; } +if test "x$ac_cv_lib_ncurses_initscr" = xyes; then : + AST_NCURSES_FOUND=yes +else + AST_NCURSES_FOUND=no +fi + + CFLAGS="${ast_ext_lib_check_save_CFLAGS}" + + + # now check for the header. + if test "${AST_NCURSES_FOUND}" = "yes"; then + NCURSES_LIB="${pbxlibdir} -lncurses " + # if --with-NCURSES=DIR has been specified, use it. + if test "x${NCURSES_DIR}" != "x"; then + NCURSES_INCLUDE="-I${NCURSES_DIR}/include" + fi + NCURSES_INCLUDE="${NCURSES_INCLUDE} " + + # check for the header + ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${CPPFLAGS} ${NCURSES_INCLUDE}" + ac_fn_c_check_header_mongrel "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_h" = xyes; then : + NCURSES_HEADER_FOUND=1 +else + NCURSES_HEADER_FOUND=0 +fi + + + CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}" + + if test "x${NCURSES_HEADER_FOUND}" = "x0" ; then + NCURSES_LIB="" + NCURSES_INCLUDE="" + else + + PBX_NCURSES=1 + cat >>confdefs.h <<_ACEOF +#define HAVE_NCURSES 1 +_ACEOF + + fi + fi +fi + + +if test "${PBX_NCURSES}" != 1; then + # some platforms have the header in a sub-directory, for example Solaris + +if test "x${PBX_NCURSES}" != "x1" -a "${USE_NCURSES}" != "no"; then + pbxlibdir="" + # if --with-NCURSES=DIR has been specified, use it. + if test "x${NCURSES_DIR}" != "x"; then + if test -d ${NCURSES_DIR}/lib; then + pbxlibdir="-L${NCURSES_DIR}/lib" + else + pbxlibdir="-L${NCURSES_DIR}" + fi + fi + + ast_ext_lib_check_save_CFLAGS="${CFLAGS}" + CFLAGS="${CFLAGS} " + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncurses" >&5 +$as_echo_n "checking for initscr in -lncurses... " >&6; } +if ${ac_cv_lib_ncurses_initscr+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lncurses ${pbxlibdir} $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* 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 initscr (); +int +main () +{ +return initscr (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_ncurses_initscr=yes +else + ac_cv_lib_ncurses_initscr=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_initscr" >&5 +$as_echo "$ac_cv_lib_ncurses_initscr" >&6; } +if test "x$ac_cv_lib_ncurses_initscr" = xyes; then : + AST_NCURSES_FOUND=yes +else + AST_NCURSES_FOUND=no +fi + + CFLAGS="${ast_ext_lib_check_save_CFLAGS}" + + + # now check for the header. + if test "${AST_NCURSES_FOUND}" = "yes"; then + NCURSES_LIB="${pbxlibdir} -lncurses " + # if --with-NCURSES=DIR has been specified, use it. + if test "x${NCURSES_DIR}" != "x"; then + NCURSES_INCLUDE="-I${NCURSES_DIR}/include" + fi + NCURSES_INCLUDE="${NCURSES_INCLUDE} " + + # check for the header + ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}" + CPPFLAGS="${CPPFLAGS} ${NCURSES_INCLUDE}" + ac_fn_c_check_header_mongrel "$LINENO" "ncurses/ncurses.h" "ac_cv_header_ncurses_ncurses_h" "$ac_includes_default" +if test "x$ac_cv_header_ncurses_ncurses_h" = xyes; then : + NCURSES_HEADER_FOUND=1 +else + NCURSES_HEADER_FOUND=0 +fi + + + CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}" + + if test "x${NCURSES_HEADER_FOUND}" = "x0" ; then + NCURSES_LIB="" + NCURSES_INCLUDE="" + else + + PBX_NCURSES=1 + cat >>confdefs.h <<_ACEOF +#define HAVE_NCURSES 1 +_ACEOF + + fi + fi +fi + + + if test "${PBX_NCURSES}" != 1; then + if test "x${PBX_CURSES}" != "x1" -a "${USE_CURSES}" != "no"; then pbxlibdir="" # if --with-CURSES=DIR has been specified, use it. @@ -4107,101 +4303,10 @@ _ACEOF fi - -if test "x${PBX_NCURSES}" != "x1" -a "${USE_NCURSES}" != "no"; then - pbxlibdir="" - # if --with-NCURSES=DIR has been specified, use it. - if test "x${NCURSES_DIR}" != "x"; then - if test -d ${NCURSES_DIR}/lib; then - pbxlibdir="-L${NCURSES_DIR}/lib" - else - pbxlibdir="-L${NCURSES_DIR}" - fi - fi - - ast_ext_lib_check_save_CFLAGS="${CFLAGS}" - CFLAGS="${CFLAGS} " - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for initscr in -lncurses" >&5 -$as_echo_n "checking for initscr in -lncurses... " >&6; } -if ${ac_cv_lib_ncurses_initscr+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lncurses ${pbxlibdir} $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* 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 initscr (); -int -main () -{ -return initscr (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ncurses_initscr=yes -else - ac_cv_lib_ncurses_initscr=no + else + HAVE_NCURSES_SUBDIR=yes + fi fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncurses_initscr" >&5 -$as_echo "$ac_cv_lib_ncurses_initscr" >&6; } -if test "x$ac_cv_lib_ncurses_initscr" = xyes; then : - AST_NCURSES_FOUND=yes -else - AST_NCURSES_FOUND=no -fi - - CFLAGS="${ast_ext_lib_check_save_CFLAGS}" - - - # now check for the header. - if test "${AST_NCURSES_FOUND}" = "yes"; then - NCURSES_LIB="${pbxlibdir} -lncurses " - # if --with-NCURSES=DIR has been specified, use it. - if test "x${NCURSES_DIR}" != "x"; then - NCURSES_INCLUDE="-I${NCURSES_DIR}/include" - fi - NCURSES_INCLUDE="${NCURSES_INCLUDE} " - - # check for the header - ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}" - CPPFLAGS="${CPPFLAGS} ${NCURSES_INCLUDE}" - ac_fn_c_check_header_mongrel "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default" -if test "x$ac_cv_header_curses_h" = xyes; then : - NCURSES_HEADER_FOUND=1 -else - NCURSES_HEADER_FOUND=0 -fi - - - CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}" - - if test "x${NCURSES_HEADER_FOUND}" = "x0" ; then - NCURSES_LIB="" - NCURSES_INCLUDE="" - else - - PBX_NCURSES=1 - cat >>confdefs.h <<_ACEOF -#define HAVE_NCURSES 1 -_ACEOF - - fi - fi -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } diff --git a/menuselect/configure.ac b/menuselect/configure.ac index 4a2d0acc29..e2ae2cb47e 100644 --- a/menuselect/configure.ac +++ b/menuselect/configure.ac @@ -67,8 +67,17 @@ AST_EXT_LIB_SETUP([NCURSES], [ncurses], [ncurses]) AST_EXT_LIB_SETUP([LIBXML2], [LibXML2], [libxml2]) AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h]) -AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h]) -AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [curses.h]) +AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [ncurses.h]) +if test "${PBX_NCURSES}" != 1; then + # some platforms have the header in a sub-directory, for example Solaris + AST_EXT_LIB_CHECK([NCURSES], [ncurses], [initscr], [ncurses/ncurses.h]) + if test "${PBX_NCURSES}" != 1; then + AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h]) + else + HAVE_NCURSES_SUBDIR=yes + fi +fi +AC_SUBST(HAVE_NCURSES_SUBDIR) AST_EXT_TOOL_CHECK([LIBXML2], [xml2-config], , , [#include #include ], diff --git a/menuselect/makeopts.in b/menuselect/makeopts.in index 495555d6b6..efafbabfd3 100644 --- a/menuselect/makeopts.in +++ b/menuselect/makeopts.in @@ -17,6 +17,7 @@ GTK2_LIB=@GTK2_LIB@ NCURSES_INCLUDE=@NCURSES_INCLUDE@ NCURSES_LIB=@NCURSES_LIB@ +HAVE_NCURSES_SUBDIR=@HAVE_NCURSES_SUBDIR@ NEWT_INCLUDE=@NEWT_INCLUDE@ NEWT_LIB=@NEWT_LIB@ diff --git a/menuselect/menuselect_curses.c b/menuselect/menuselect_curses.c index 0917eba62b..fe42119db6 100644 --- a/menuselect/menuselect_curses.c +++ b/menuselect/menuselect_curses.c @@ -31,7 +31,15 @@ #include #include #include +#ifdef HAVE_NCURSES +#ifdef HAVE_NCURSES_SUBDIR +#include +#else +#include +#endif +#else #include +#endif #include "menuselect.h"