[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2] autoconf: add check for curses library
2012/2/23 Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>: > # HG changeset patch > # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> > # Date 1329958212 -3600 > # Node ID 1220a9aa16fc2b44021a244086de244196ebe468 > # 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 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 1220a9aa16fc config/NetBSD.mk > --- a/config/NetBSD.mk ÂWed Feb 22 17:37:28 2012 +0100 > +++ b/config/NetBSD.mk ÂThu Feb 23 01:50:12 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 1220a9aa16fc config/StdGNU.mk > --- a/config/StdGNU.mk ÂWed Feb 22 17:37:28 2012 +0100 > +++ b/config/StdGNU.mk ÂThu Feb 23 01:50:12 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 1220a9aa16fc config/SunOS.mk > --- a/config/SunOS.mk  Wed Feb 22 17:37:28 2012 +0100 > +++ b/config/SunOS.mk  Thu Feb 23 01:50:12 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 1220a9aa16fc 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:50:12 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 1220a9aa16fc 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:50:12 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 1220a9aa16fc tools/configure > --- a/tools/configure  Wed Feb 22 17:37:28 2012 +0100 > +++ b/tools/configure  Thu Feb 23 01:50:12 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 1220a9aa16fc tools/configure.ac > --- a/tools/configure.ac    ÂWed Feb 22 17:37:28 2012 +0100 > +++ b/tools/configure.ac    ÂThu Feb 23 01:50:12 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 1220a9aa16fc tools/m4/curses.m4 > --- /dev/null  Thu Jan 01 00:00:00 1970 +0000 > +++ b/tools/m4/curses.m4    ÂThu Feb 23 01:50:12 2012 +0100 > @@ -0,0 +1,23 @@ > +AC_DEFUN([AX_CHECK_CURSES], [ > +AC_CHECK_HEADER([curses.h], [ > +  ÂAC_CHECK_LIB([curses], [clear], [curses="y"], [curses="n"]) > +], [cursesh="n"]) This is wrong, it should be curses="n" > +AC_CHECK_HEADER([ncurses.h], [ > +  ÂAC_CHECK_LIB([ncurses], [clear], [ncurses="y"], [ncurses="n"]) > +], [ncursesh="n"]) This is also wrong, it should be ncurses="n", I will have to resend it, sorry. > +AS_IF([test "$cursesh" = "n" && test "$ncursesh" = "n"], [ Same here.... > +  ÂAC_MSG_ERROR([Unable to find a suitable curses header]) > +]) > +AS_IF([test "$curses" = "n" && test "$ncurses" = "n"], [ > +  ÂAC_MSG_ERROR([Unable to find a suitable curses library]) > +]) > +# Prefer ncurses over curses is 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="-lncurses" > +  ÂAC_DEFINE([HAVE_CURSES_H], [1], [Define if curses.h should be used]) > +]) > +AC_SUBST(CURSES_LIBS) > +]) > diff -r caf033544726 -r 1220a9aa16fc tools/misc/Makefile > --- a/tools/misc/Makefile    Wed Feb 22 17:37:28 2012 +0100 > +++ b/tools/misc/Makefile    Thu Feb 23 01:50:12 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 1220a9aa16fc 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:50:12 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 1220a9aa16fc 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:50:12 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 1220a9aa16fc 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:50:12 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 |