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

Re: [libvirt] [PATCH] freebsd: Fix build problem due to picking up the wrong libvirt.h



2011/7/26 Eric Blake <eblake redhat com>:
> On 07/26/2011 02:45 PM, Matthias Bolte wrote:
>>>>
>>>> +++ b/configure.ac
>>>> @@ -2011,8 +2011,16 @@ dnl Enable building libvirtd?
>>>>  AM_CONDITIONAL([WITH_LIBVIRTD],[test "x$with_libvirtd" = "xyes"])
>>>>
>>>>  dnl Check for gettext - don't go any newer than what RHEL 5 supports
>>>> +dnl
>>>> +dnl save and restore CPPFLAGS around gettext check as the internal
>>>> iconv
>>>> +dnl check might leave -I/usr/local/include in CPPFLAGS on FreeBSD
>>>> resulting
>>>> +dnl in the build picking up previously installed libvirt/libvirt.h
>>>> instead
>>>> +dnl of the correct one from the soucre tree
>>>> +
>>>> +save_CPPFLAGS="$CPPFLAGS"
>>>>  AM_GNU_GETTEXT_VERSION([0.17])
>>>>  AM_GNU_GETTEXT([external])
>>>> +CPPFLAGS="$save_CPPFLAGS"
>>>
>
>>> But I'm still worried that we have to use -I/usr/local/include somewhere
>>> in the command line, which means we would have to modify src/Makefile.am
>>> (and friends) to have:
>>>
>>> INCLUDES= ... $(GETTEXT_CPPFLAGS)
>>>
>>> where GETTEXT_CPPFLAGS is substituted with the difference in
>>> $save_CPPFLAGS and $CPPFLAGS prior to the point where we restore
>>> $CPPFLAGS.
>>
>> That's probably what we should do here.
>>
>> Now how to compute this difference? When we assume that save_CPPFLAGS
>> and CPPFLAGS have a common prefix that we need to strip to get
>> GETTEXT_CPPFLAGS then we could do it like this
>>
>>   echo $(CPPFLAGS) | cut -c 1-`expr length $(save_CPPFLAGS)` --complement
>> -
>>
>> This is probably neither the best nor a robustest way to do this. Do
>> you have a better idea?
>
> Yep (although I haven't tested it thoroughly):
>
> save_CPPFLAGS="$CPPFLAGS"
> AM_GNU_GETTEXT_VERSION([0.17])
> AM_GNU_GETTEXT([external])
> GETTEXT_CPPFLAGS=
> if test "x$save_CPPFLAGS" != "x$CPPFLAGS"; then
>  set dummy $CPPFLAGS
>  for var
>  do
>    case " $var " in
>      " $save_CPPFLAGS ") ;;
>      *) GETTEXT_CPPFLAGS="$GETTEXT_CPPFLAGS $var" ;;
>    esac
>  done
> fi
> CPPFLAGS="$save_CPPFLAGS"
>

Okay, this works for libvirt itself, but it fails for make check as
the global CPPFLAGS also affect gnulib, but with this patch it doesn't
contain the gettext related parts anymore and the gnulib tests fail to
find libintl.h because of this.

Making check in gnulib/tests
Making check in .
In file included from wait-process.c:37:
../../gnulib/lib/gettext.h:28:22: error: libintl.h: No such file or directory

Is there any option in gnulib that would allow to inject
GETTEXT_CPPFLAGS into the gnulib makefiles, or any other possibility
to fix this?

I attached a preliminary patch.

-- 
Matthias Bolte
http://photron.blogspot.com
diff --git a/configure.ac b/configure.ac
index ac34efc..b61c8e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2055,8 +2055,30 @@ dnl Enable building libvirtd?
 AM_CONDITIONAL([WITH_LIBVIRTD],[test "x$with_libvirtd" = "xyes"])
 
 dnl Check for gettext - don't go any newer than what RHEL 5 supports
+dnl
+dnl save and restore CPPFLAGS around gettext check as the internal iconv
+dnl check might leave -I/usr/local/include in CPPFLAGS on FreeBSD resulting
+dnl in the build picking up previously installed libvirt/libvirt.h instead
+dnl of the correct one from the soucre tree.
+dnl compute the difference between save_CPPFLAGS and CPPFLAGS and append it
+dnl to INCLUDES in order to preserve changes made by gettext but in a place
+dnl that does not break the build
+save_CPPFLAGS="$CPPFLAGS"
 AM_GNU_GETTEXT_VERSION([0.17])
 AM_GNU_GETTEXT([external])
+GETTEXT_CPPFLAGS=
+if test "x$save_CPPFLAGS" != "x$CPPFLAGS"; then
+ set dummy $CPPFLAGS; shift
+ for var
+ do
+   case " $var " in
+     " $save_CPPFLAGS ") ;;
+     *) GETTEXT_CPPFLAGS="$GETTEXT_CPPFLAGS $var" ;;
+   esac
+ done
+fi
+CPPFLAGS="$save_CPPFLAGS"
+AC_SUBST([GETTEXT_CPPFLAGS])
 
 ALL_LINGUAS=`cd "$srcdir/po" > /dev/null && ls *.po | sed 's+\.po$++'`
 
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 63c731e..d81c29c 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -1,5 +1,15 @@
 ## Process this file with automake to produce Makefile.in
 
+INCLUDES = \
+	-I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
+	-I$(top_srcdir)/include -I$(top_builddir)/include \
+	-I$(top_srcdir)/src \
+	-I$(top_srcdir)/src/util \
+	-I$(top_srcdir)/src/conf \
+	-I$(top_srcdir)/src/rpc \
+	-I$(top_srcdir)/src/remote \
+	$(GETTEXT_CPPFLAGS)
+
 CLEANFILES =
 
 DAEMON_GENERATED =					\
@@ -79,13 +89,6 @@ libvirtd_SOURCES = $(DAEMON_SOURCES)
 
 #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
 libvirtd_CFLAGS = \
-	-I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
-	-I$(top_srcdir)/include -I$(top_builddir)/include \
-	-I$(top_srcdir)/src \
-	-I$(top_srcdir)/src/util \
-	-I$(top_srcdir)/src/conf \
-	-I$(top_srcdir)/src/rpc \
-	-I$(top_srcdir)/src/remote \
 	$(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \
 	$(XDR_CFLAGS) $(POLKIT_CFLAGS) \
 	$(WARN_CFLAGS) \
diff --git a/python/Makefile.am b/python/Makefile.am
index 51f005d..063b1bf 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -6,7 +6,8 @@ INCLUDES = \
 	$(PYTHON_INCLUDES) \
 	-I$(top_srcdir)/include \
 	-I$(top_builddir)/include \
-	-I$(top_builddir)/$(subdir)
+	-I$(top_builddir)/$(subdir) \
+	$(GETTEXT_CPPFLAGS)
 
 AM_CFLAGS = $(WARN_CFLAGS)
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 46b92a8..5d2d93e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,13 +2,14 @@
 
 # No libraries with the exception of LIBXML should be listed
 # here. List them against the individual XXX_la_CFLAGS targets
-# that actually use them
+# that actually use them. Also keep GETTEXT_CPPFLAGS at the end.
 INCLUDES =	-I$(top_srcdir)/gnulib/lib			\
 		-I../gnulib/lib					\
 		-I../include					\
 		-I top_srcdir@/src/util				\
 		-I top_srcdir@/include				\
-		-DIN_LIBVIRT
+		-DIN_LIBVIRT					\
+		$(GETTEXT_CPPFLAGS)
 
 AM_CFLAGS =	$(DRIVER_MODULE_CFLAGS)				\
 		$(LIBXML_CFLAGS)				\
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 872aa22..82ab04c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -8,7 +8,8 @@ INCLUDES = \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/src \
 	-I$(top_srcdir)/src/util \
-	-I$(top_srcdir)/src/conf
+	-I$(top_srcdir)/src/conf \
+	$(GETTEXT_CPPFLAGS)
 
 AM_CFLAGS = \
 	$(LIBXML_CFLAGS) \
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 62c275e..ac91b9c 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,4 +1,12 @@
 
+INCLUDES = \
+	-I../include -I$(top_srcdir)/include \
+	-I$(top_srcdir)/gnulib/lib -I../gnulib/lib	\
+	-I$(top_srcdir)/src				\
+	-I$(top_srcdir)/src/util			\
+	-I$(top_srcdir)					\
+	$(GETTEXT_CPPFLAGS)
+
 POD2MAN = pod2man -c "Virtualization Support" -r "$(PACKAGE)-$(VERSION)"
 
 ICON_FILES = \
@@ -66,11 +74,6 @@ virsh_LDADD =							\
 		$(LIBXML_LIBS)					\
 		$(VIRSH_LIBS)
 virsh_CFLAGS =							\
-		-I$(top_srcdir)/gnulib/lib -I../gnulib/lib	\
-		-I../include -I$(top_srcdir)/include		\
-		-I$(top_srcdir)/src				\
-		-I$(top_srcdir)/src/util			\
-		-I$(top_srcdir)					\
 		$(WARN_CFLAGS)					\
 		$(COVERAGE_CFLAGS)				\
 		$(LIBXML_CFLAGS)				\

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