Skip to contentSkip to conversation

autoconf: add check for curses library

PATCH Superseded Roger Pau Monne 2 participants 2 messages Feb 22, 2012 – Mar 12, 2012 1 message not in the archive

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 autoconf: add check for curses library

# HG changeset patch
# User Roger Pau Monne <[email protected]> # Date 1329929367 -3600
# Node ID 9e72215b0ee2d73b6b60b1e155067595294dc2df # Parent caf03354472676522f7407a80ad5bec3963a90a9
autoconf: add check for curses library

Check for a curses compatible library (curses or ncurses basically). One of those is needed to compile Xen tools.

tools/configure +114 -0
diff -r caf033544726 -r 9e72215b0ee2 tools/configure
@@ -3907,6 +3907,8 @@ case $host_os in *\ *) host_os=`echo "$h
 # PKG_CHECK_MODULES
 
 
+
+
 # Enable/disable options
 # Check whether --enable-xsm was given.
 if test "${enable_xsm+set}" = set; then :
@@ -6380,6 +6382,118 @@ if test "$libuuid" != "y"; then :
 fi
 
 
+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" = x""yes; then :
+  cursesh="y"
+else
+  cursesh="n"
+fi
+
+
+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" = x""yes; then :
+  ncursesh="y"
+else
+  ncursesh="n"
+fi
+
+
+if test "$cursesh" = "n" && test "$ncursesh" = "n"; then :
+
+    as_fn_error $? "Unable to find a suitable curses header" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clear in -lcurses" >&5
+$as_echo_n "checking for clear in -lcurses... " >&6; }
+if test "${ac_cv_lib_curses_clear+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcurses  $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 clear ();
+int
+main ()
+{
+return clear ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_curses_clear=yes
+else
+  ac_cv_lib_curses_clear=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_curses_clear" >&5
+$as_echo "$ac_cv_lib_curses_clear" >&6; }
+if test "x$ac_cv_lib_curses_clear" = x""yes; then :
+  curses="y"
+else
+  curses="n"
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clear in -lncurses" >&5
+$as_echo_n "checking for clear in -lncurses... " >&6; }
+if test "${ac_cv_lib_ncurses_clear+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lncurses  $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 clear ();
+int
+main ()
+{
+return clear ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_ncurses_clear=yes
+else
+  ac_cv_lib_ncurses_clear=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_clear" >&5
+$as_echo "$ac_cv_lib_ncurses_clear" >&6; }
+if test "x$ac_cv_lib_ncurses_clear" = x""yes; then :
+  ncurses="y"
+else
+  ncurses="n"
+fi
+
+if test "$curses" = "n" && test "$ncurses" = "n"; then :
+
+    as_fn_error $? "Unable to find a suitable curses library" "$LINENO" 5
+
+fi
+
+
 
 
 
tools/configure.ac +2 -0
diff -r caf033544726 -r 9e72215b0ee2 tools/configure.ac
@@ -33,6 +33,7 @@ m4_include([m4/default_lib.m4])
 m4_include([m4/set_cflags_ldflags.m4])
 m4_include([m4/uuid.m4])
 m4_include([m4/pkg.m4])
+m4_include([m4/curses.m4])
 
 # Enable/disable options
 AX_ARG_ENABLE_AND_EXPORT([xsm],
@@ -102,6 +103,7 @@ AS_IF([test "x$pythontools" = "xy"], [
 ])
 AX_PATH_PROG_OR_FAIL([XGETTEXT], [xgettext])
 AX_CHECK_UUID
+AX_CHECK_CURSES
 PKG_CHECK_MODULES(glib, glib-2.0)
 
 # Check library path
tools/m4/curses.m4 new file +12 -0
diff -r caf033544726 -r 9e72215b0ee2 tools/m4/curses.m4
@@ -0,0 +1,12 @@
+AC_DEFUN([AX_CHECK_CURSES], [
+AC_CHECK_HEADER([curses.h], [cursesh="y"], [cursesh="n"])
+AC_CHECK_HEADER([ncurses.h], [ncursesh="y"], [ncursesh="n"])
+AS_IF([test "$cursesh" = "n" && test "$ncursesh" = "n"], [
+    AC_MSG_ERROR([Unable to find a suitable curses header])
+])
+AC_CHECK_LIB([curses], [clear], [curses="y"], [curses="n"])
+AC_CHECK_LIB([ncurses], [clear], [ncurses="y"], [ncurses="n"])
+AS_IF([test "$curses" = "n" && test "$ncurses" = "n"], [
+    AC_MSG_ERROR([Unable to find a suitable curses library])
+])
+])
#2 lore raw

Roger Pau Monne writes ("[PATCH v2] autoconf: add check for curses library"):

Quoted 4 lines

autoconf: add check for curses library

Check for a curses compatible library (curses or ncurses basically). One of those is needed to compile Xen tools.

This seems to permit including ncurses.h but linking with -lcurses, or vice versa, which would be very odd.

Also I can't see any plumbing that actually uses the result of this test. How does that work ?

Ian.