[Asterisk-code-review] BuildSystem: Enable ncurses for menuselect in Solaris 11. (asterisk[16])
Kevin Harwell
asteriskteam at digium.com
Fri Aug 3 13:29:01 CDT 2018
Kevin Harwell has submitted this change and it was merged. ( https://gerrit.asterisk.org/9773 )
Change subject: BuildSystem: Enable ncurses for menuselect in Solaris 11.
......................................................................
BuildSystem: Enable ncurses for menuselect in Solaris 11.
The check for the library ncurses should use not use the header <curses.h> but
<ncurses.h>, because on some platforms <curses.h> is not a drop-in replacement
for <ncurses.h>: For example in Solaris, the symbol initscr is a typedef in
<curses.h> to a symbol which does not exist in the library ncurses (initscr32).
Simply use <ncurses.h> when you link to ncurses.
Furthermore in Solaris, the header <ncurses.h> is in a subdirectory
/usr/include/ncurses and not available via pkg-config.
ASTERISK-15331
ASTERISK-14935
ASTERISK-12382
ASTERISK-9107
Change-Id: Ife367776b0ccf17d3fefed868245376bfb93745d
---
M menuselect/Makefile
M menuselect/configure
M menuselect/configure.ac
M menuselect/makeopts.in
M menuselect/menuselect_curses.c
5 files changed, 223 insertions(+), 96 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Matthew Fredrickson: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved; Approved for Submit
diff --git a/menuselect/Makefile b/menuselect/Makefile
index d949efd..da4a6c0 100644
--- a/menuselect/Makefile
+++ b/menuselect/Makefile
@@ -41,6 +41,10 @@
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 7cbe477..8efb637 100755
--- a/menuselect/configure
+++ b/menuselect/configure
@@ -634,6 +634,7 @@
PKG_CONFIG
CONFIG_LIBXML2
SED
+HAVE_NCURSES_SUBDIR
PBX_LIBXML2
LIBXML2_DIR
LIBXML2_INCLUDE
@@ -4012,6 +4013,201 @@
+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 @@
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 4a2d0ac..e2ae2cb 100644
--- a/menuselect/configure.ac
+++ b/menuselect/configure.ac
@@ -67,8 +67,17 @@
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 <libxml/tree.h>
#include <libxml/parser.h>],
diff --git a/menuselect/makeopts.in b/menuselect/makeopts.in
index 495555d..efafbab 100644
--- a/menuselect/makeopts.in
+++ b/menuselect/makeopts.in
@@ -17,6 +17,7 @@
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 0917eba..fe42119 100644
--- a/menuselect/menuselect_curses.c
+++ b/menuselect/menuselect_curses.c
@@ -31,7 +31,15 @@
#include <string.h>
#include <signal.h>
#include <time.h>
+#ifdef HAVE_NCURSES
+#ifdef HAVE_NCURSES_SUBDIR
+#include <ncurses/ncurses.h>
+#else
+#include <ncurses.h>
+#endif
+#else
#include <curses.h>
+#endif
#include "menuselect.h"
--
To view, visit https://gerrit.asterisk.org/9773
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: merged
Gerrit-Change-Id: Ife367776b0ccf17d3fefed868245376bfb93745d
Gerrit-Change-Number: 9773
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180803/031e0007/attachment-0001.html>
More information about the asterisk-code-review
mailing list