Re: [PATCH] fix compilation if readline lib is not available

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Dec 06, 2007 at 05:05:33AM -0500, Daniel Veillard wrote:
>   The current CVS code doesn't compile on RHEL5/F6 because readline lib
> there require ncurses, and we removed that check earlier. Sor we find
> the readline headers but the lib is not found. Unfortunately virsh.c
> tests the availablility of the header to use readline, and link time failures
> follow. The patch below:
>    - exports a READLINE_CFLAGS from configure if used
>    - use the READLINE_CFLAGS when compiling virsh.c
>    - change virsh.c to rely on this instead of the header test
>    - adds a message about readline usage at the end of configure
> 
>     configure: Miscellaneous
>     configure: 
>     configure:   Debug: no
>     configure:   Readline: yes
>     configure: 

  Oops actual good patch enclosed,

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard@xxxxxxxxxx  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/
Index: configure.in
===================================================================
RCS file: /data/cvs/libxen/configure.in,v
retrieving revision 1.108
diff -u -r1.108 configure.in
--- configure.in	5 Dec 2007 23:02:13 -0000	1.108
+++ configure.in	6 Dec 2007 10:13:15 -0000
@@ -448,11 +448,21 @@
 AC_SUBST(AVAHI_LIBS)
 
 dnl virsh libraries
+USE_READLINE=
+READLINE_CFLAGS=
 AC_CHECK_HEADERS([readline/readline.h])
 AC_CHECK_LIB(readline, main,
-	[VIRSH_LIBS="$VIRSH_LIBS -lreadline"],
-	[AC_MSG_WARN([readline library not found])],
+	[USE_READLINE=yes],
+	[USE_READLINE=no],
 	[$VIRSH_LIBS])
+if test "$USE_READLINE" = "yes" ; then
+    VIRSH_LIBS="$VIRSH_LIBS -lreadline"
+    AC_DEFINE_UNQUOTED(USE_READLINE, 1, [whether virsh use readline])
+    READLINE_CFLAGS="-DUSE_READLINE"
+else
+    AC_MSG_WARN([readline library not found])
+fi
+AC_SUBST(READLINE_CFLAGS)
 AC_SUBST(VIRSH_LIBS)
 
 # end of if with_depends
@@ -687,4 +697,5 @@
 AC_MSG_NOTICE([Miscellaneous])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([  Debug: $enable_debug])
+AC_MSG_NOTICE([  Readline: $USE_READLINE])
 AC_MSG_NOTICE([])
Index: src/Makefile.am
===================================================================
RCS file: /data/cvs/libxen/src/Makefile.am,v
retrieving revision 1.59
diff -u -r1.59 Makefile.am
--- src/Makefile.am	5 Dec 2007 21:31:07 -0000	1.59
+++ src/Makefile.am	6 Dec 2007 10:13:15 -0000
@@ -76,7 +76,7 @@
 virsh_LDFLAGS = $(WARN_CFLAGS) $(COVERAGE_LDFLAGS)
 virsh_DEPENDENCIES = $(DEPS)
 virsh_LDADD = $(LDADDS) $(VIRSH_LIBS)
-virsh_CFLAGS = $(COVERAGE_CFLAGS)
+virsh_CFLAGS = $(COVERAGE_CFLAGS) $(READLINE_CFLAGS)
 
 #
 # target to ease building test programs
Index: src/virsh.c
===================================================================
RCS file: /data/cvs/libxen/src/virsh.c,v
retrieving revision 1.116
diff -u -r1.116 virsh.c
--- src/virsh.c	5 Dec 2007 18:55:04 -0000	1.116
+++ src/virsh.c	6 Dec 2007 10:13:15 -0000
@@ -4661,7 +4661,7 @@
     }
 }
 
-#ifdef HAVE_READLINE_READLINE_H
+#ifdef USE_READLINE
 
 /* -----------------
  * Readline stuff
@@ -4786,7 +4786,7 @@
     return readline (prompt);
 }
 
-#else /* !HAVE_READLINE_READLINE_H */
+#else /* !USE_READLINE */
 
 static void
 vshReadlineInit (void)
@@ -4813,7 +4813,7 @@
     return vshStrdup (ctl, r);
 }
 
-#endif /* !HAVE_READLINE_READLINE_H */
+#endif /* !USE_READLINE */
 
 /*
  * Deinitliaze virsh
@@ -5059,7 +5059,7 @@
             if (ctl->cmdstr == NULL)
                 break;          /* EOF */
             if (*ctl->cmdstr) {
-#if HAVE_READLINE_READLINE_H
+#if USE_READLINE
                 add_history(ctl->cmdstr);
 #endif
                 if (vshCommandParse(ctl, ctl->cmdstr))
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]