|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3] autoconf: add check for curses library
# HG changeset patch
# User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
# Date 1329958678 -3600
# Node ID 8c83cbb30fe84a2ff7c9f9bb1ab73b30eeee244c
# 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 (gtraceview and xentop).
Modify Makefiles/sources to use configure output (fetch CURSES_LIBS
from tools/Tools.mk and header to include from tools/config.h)
Changes since v2:
* Fixed ncursesh/cursesh variable mess in curses.m4.
Changes since v1:
* Added better ncurses/curses detection.
* Modify Makefiles/sources to use configure output.
Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
diff -r caf033544726 -r 8c83cbb30fe8 config/NetBSD.mk
--- a/config/NetBSD.mk Wed Feb 22 17:37:28 2012 +0100
+++ b/config/NetBSD.mk Thu Feb 23 01:57:58 2012 +0100
@@ -1,8 +1,6 @@
include $(XEN_ROOT)/config/StdGNU.mk
# Override settings for this OS
-CURSES_LIBS = -lcurses
-
LIBLEAFDIR_x86_64 = lib
LIBEXEC = $(PREFIX)/libexec
PRIVATE_BINDIR = $(BINDIR)
diff -r caf033544726 -r 8c83cbb30fe8 config/StdGNU.mk
--- a/config/StdGNU.mk Wed Feb 22 17:37:28 2012 +0100
+++ b/config/StdGNU.mk Thu Feb 23 01:57:58 2012 +0100
@@ -67,7 +67,6 @@ XEN_CONFIG_DIR = $(CONFIG_DIR)/xen
XEN_SCRIPT_DIR = $(XEN_CONFIG_DIR)/scripts
SOCKET_LIBS =
-CURSES_LIBS = -lncurses
PTHREAD_LIBS = -lpthread
UTIL_LIBS = -lutil
DLOPEN_LIBS = -ldl
diff -r caf033544726 -r 8c83cbb30fe8 config/SunOS.mk
--- a/config/SunOS.mk Wed Feb 22 17:37:28 2012 +0100
+++ b/config/SunOS.mk Thu Feb 23 01:57:58 2012 +0100
@@ -47,7 +47,6 @@ SunOS_LIBDIR = /usr/sfw/lib
SunOS_LIBDIR_x86_64 = /usr/sfw/lib/amd64
SOCKET_LIBS = -lsocket
-CURSES_LIBS = -lcurses
PTHREAD_LIBS = -lpthread
UTIL_LIBS =
DLOPEN_LIBS = -ldl
diff -r caf033544726 -r 8c83cbb30fe8 config/Tools.mk.in
--- a/config/Tools.mk.in Wed Feb 22 17:37:28 2012 +0100
+++ b/config/Tools.mk.in Thu Feb 23 01:57:58 2012 +0100
@@ -46,3 +46,4 @@ CONFIG_SYSTEM_LIBAIO:= @system_aio@
CONFIG_LIBICONV := @libiconv@
CONFIG_GCRYPT := @libgcrypt@
CONFIG_EXT2FS := @libext2fs@
+CURSES_LIBS := @CURSES_LIBS@
diff -r caf033544726 -r 8c83cbb30fe8 tools/config.h.in
--- a/tools/config.h.in Wed Feb 22 17:37:28 2012 +0100
+++ b/tools/config.h.in Thu Feb 23 01:57:58 2012 +0100
@@ -14,3 +14,9 @@
/* Define to 1 if you have the <yajl/yajl_version.h> header file. */
#undef HAVE_YAJL_YAJL_VERSION_H
+
+/* Define to 1 if you have the <curses.h> header file. */
+#undef HAVE_CURSES_H
+
+/* Define to 1 if you have the <ncurses.h> header file. */
+#undef HAVE_NCURSES_H
diff -r caf033544726 -r 8c83cbb30fe8 tools/configure
--- a/tools/configure Wed Feb 22 17:37:28 2012 +0100
+++ b/tools/configure Thu Feb 23 01:57:58 2012 +0100
@@ -611,6 +611,7 @@ glib_CFLAGS
PKG_CONFIG_LIBDIR
PKG_CONFIG_PATH
PKG_CONFIG
+CURSES_LIBS
PYTHONPATH
OCAMLBUILD
OCAMLDOC
@@ -3907,6 +3908,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 +6383,137 @@ 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 :
+
+ { $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
+
+
+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 :
+
+ { $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
+
+
+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
+if test "$curses" = "n" && test "$ncurses" = "n"; then :
+
+ as_fn_error $? "Unable to find a suitable curses library" "$LINENO" 5
+
+fi
+# Prefer ncurses over curses is both are present
+if test "$ncurses" = "y"; then :
+
+ CURSES_LIBS="-lncurses"
+
+$as_echo "#define HAVE_NCURSES_H 1" >>confdefs.h
+
+
+else
+
+ CURSES_LIBS="-lncurses"
+
+$as_echo "#define HAVE_CURSES_H 1" >>confdefs.h
+
+
+fi
+
+
+
diff -r caf033544726 -r 8c83cbb30fe8 tools/configure.ac
--- a/tools/configure.ac Wed Feb 22 17:37:28 2012 +0100
+++ b/tools/configure.ac Thu Feb 23 01:57:58 2012 +0100
@@ -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
diff -r caf033544726 -r 8c83cbb30fe8 tools/m4/curses.m4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/m4/curses.m4 Thu Feb 23 01:57:58 2012 +0100
@@ -0,0 +1,20 @@
+AC_DEFUN([AX_CHECK_CURSES], [
+AC_CHECK_HEADER([curses.h], [
+ AC_CHECK_LIB([curses], [clear], [curses="y"], [curses="n"])
+], [curses="n"])
+AC_CHECK_HEADER([ncurses.h], [
+ AC_CHECK_LIB([ncurses], [clear], [ncurses="y"], [ncurses="n"])
+], [ncurses="n"])
+AS_IF([test "$curses" = "n" && test "$ncurses" = "n"], [
+ AC_MSG_ERROR([Unable to find a suitable curses library])
+])
+# Prefer ncurses over curses if both are present
+AS_IF([test "$ncurses" = "y"], [
+ CURSES_LIBS="-lncurses"
+ AC_DEFINE([HAVE_NCURSES_H], [1], [Define if ncurses.h should be used])
+], [
+ CURSES_LIBS="-lcurses"
+ AC_DEFINE([HAVE_CURSES_H], [1], [Define if curses.h should be used])
+])
+AC_SUBST(CURSES_LIBS)
+])
diff -r caf033544726 -r 8c83cbb30fe8 tools/misc/Makefile
--- a/tools/misc/Makefile Wed Feb 22 17:37:28 2012 +0100
+++ b/tools/misc/Makefile Thu Feb 23 01:57:58 2012 +0100
@@ -26,6 +26,9 @@ INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx
INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool
INSTALL_SBIN := $(INSTALL_SBIN-y)
+# Include configure output (config.h) to headers search path
+CFLAGS += -I$(XEN_ROOT)/tools
+
.PHONY: all
all: build
diff -r caf033544726 -r 8c83cbb30fe8 tools/misc/gtraceview.c
--- a/tools/misc/gtraceview.c Wed Feb 22 17:37:28 2012 +0100
+++ b/tools/misc/gtraceview.c Thu Feb 23 01:57:58 2012 +0100
@@ -16,6 +16,9 @@
* Place - Suite 330, Boston, MA 02111-1307 USA.
*/
+/* Include output from configure */
+#include <config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -30,10 +33,9 @@
#include <xenctrl.h>
#include <xen/trace.h>
-#ifdef __linux__
+#if defined(HAVE_NCURSES_H)
#include <ncurses.h>
-#endif
-#ifdef __NetBSD__
+#elif defined(HAVE_CURSES_H)
#include <curses.h>
#endif
diff -r caf033544726 -r 8c83cbb30fe8 tools/xenstat/xentop/Makefile
--- a/tools/xenstat/xentop/Makefile Wed Feb 22 17:37:28 2012 +0100
+++ b/tools/xenstat/xentop/Makefile Thu Feb 23 01:57:58 2012 +0100
@@ -22,6 +22,9 @@ CFLAGS += -DGCC_PRINTF -Wall -Werror $(C
LDLIBS += $(LDLIBS_libxenstat) $(CURSES_LIBS) $(SOCKET_LIBS)
CFLAGS += -DHOST_$(XEN_OS)
+# Include configure output (config.h) to headers search path
+CFLAGS += -I$(XEN_ROOT)/tools
+
.PHONY: all
all: xentop
diff -r caf033544726 -r 8c83cbb30fe8 tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c Wed Feb 22 17:37:28 2012 +0100
+++ b/tools/xenstat/xentop/xentop.c Thu Feb 23 01:57:58 2012 +0100
@@ -18,7 +18,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
+/* Include output from configure */
+#include <config.h>
+
+#if defined(HAVE_NCURSES_H)
+#include <ncurses.h>
+#elif defined(HAVE_CURSES_H)
#include <curses.h>
+#endif
+
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |