[PATCH v2 2/2] examples: Avoid gnulib, have standalone examples

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

 



Commit 0c6ad476 updated gnulib, which rearranged some of the
conditions in gnulib wrapper headers such that compilation
started failing on BSD systems when the normal system <unistd.h>
tried to include another system header but instead got a
gnulib wrapper header in an incomplete state; this is because
gnulib headers only work if <config.h> is included first.

Commit b6f78259 papered over the symptoms of that by including
<config.h> in all the examples.  But this logic is backwards -
if our examples are truly meant to be stand-alone, they should
NOT depend on how libvirt was configured, and should NOT
depend on the gnulib fixes for system quirks.  In particular,
if an example does not need to link against libgnulib.la,
then it also does not need to use -Ignulib in its compile
flags, and likewise does not need to include <config.h> since
none of the gnulib wrapper headers should be interfering.

So, revert (most of) b6f78259 (except for the bogus pre-patch
use of "config.h" in admin/logging.c: if config.h is included,
it should be via <> rather than "", and must be before any
system headers); then additionally nuke all mention of
<config.h>, -Ignulib, and -lgnulib, making all of the examples
truly standalone.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>

---
v2: rewrite to nuke rather than partition use of gnulib, revert
Jan's patch that landed in meantime
---
 examples/Makefile.am                 | 5 ++---
 examples/admin/client_close.c        | 2 --
 examples/admin/client_info.c         | 3 +--
 examples/admin/client_limits.c       | 2 --
 examples/admin/list_clients.c        | 2 --
 examples/admin/list_servers.c        | 2 --
 examples/admin/logging.c             | 2 --
 examples/admin/threadpool_params.c   | 2 --
 examples/dommigrate/dommigrate.c     | 2 --
 examples/domsuspend/suspend.c        | 2 --
 examples/domtop/domtop.c             | 2 --
 examples/hellolibvirt/hellolibvirt.c | 2 --
 examples/object-events/event-test.c  | 2 --
 examples/openauth/openauth.c         | 2 --
 examples/rename/rename.c             | 2 --
 15 files changed, 3 insertions(+), 31 deletions(-)

diff --git a/examples/Makefile.am b/examples/Makefile.am
index 61cf2af4a5..76907a1c8f 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -34,10 +34,9 @@ EXTRA_DIST = \


 AM_CPPFLAGS = \
-	-I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir) \
-	-I$(top_builddir)/gnulib/lib -I$(top_srcdir)/gnulib/lib
+	-I$(top_builddir)/include -I$(top_srcdir)/include -I$(top_srcdir)
 LDADD = $(STATIC_BINARIES) $(WARN_CFLAGS) $(COVERAGE_LDFLAGS) \
-	$(top_builddir)/src/libvirt.la $(top_builddir)/gnulib/lib/libgnu.la \
+	$(top_builddir)/src/libvirt.la \
 	$(top_builddir)/src/libvirt-admin.la

 noinst_PROGRAMS=dominfo/info1 dommigrate/dommigrate domsuspend/suspend \
diff --git a/examples/admin/client_close.c b/examples/admin/client_close.c
index 9b7e1febb1..5c28ce7949 100644
--- a/examples/admin/client_close.c
+++ b/examples/admin/client_close.c
@@ -1,5 +1,3 @@
-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <libvirt/libvirt.h>
diff --git a/examples/admin/client_info.c b/examples/admin/client_info.c
index 550a24824a..2c46ccf514 100644
--- a/examples/admin/client_info.c
+++ b/examples/admin/client_info.c
@@ -1,5 +1,4 @@
-#include <config.h>
-
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
diff --git a/examples/admin/client_limits.c b/examples/admin/client_limits.c
index a87cb52c82..69b931682c 100644
--- a/examples/admin/client_limits.c
+++ b/examples/admin/client_limits.c
@@ -1,5 +1,3 @@
-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <libvirt/libvirt-admin.h>
diff --git a/examples/admin/list_clients.c b/examples/admin/list_clients.c
index 1d961a1ec9..15205a7bd1 100644
--- a/examples/admin/list_clients.c
+++ b/examples/admin/list_clients.c
@@ -1,5 +1,3 @@
-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
diff --git a/examples/admin/list_servers.c b/examples/admin/list_servers.c
index d48d87af6e..e53cd3b48f 100644
--- a/examples/admin/list_servers.c
+++ b/examples/admin/list_servers.c
@@ -1,5 +1,3 @@
-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <libvirt/libvirt-admin.h>
diff --git a/examples/admin/logging.c b/examples/admin/logging.c
index 10952afa03..730ae40d9d 100644
--- a/examples/admin/logging.c
+++ b/examples/admin/logging.c
@@ -1,5 +1,3 @@
-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdbool.h>
diff --git a/examples/admin/threadpool_params.c b/examples/admin/threadpool_params.c
index 9517dcb0f2..be833c2ea3 100644
--- a/examples/admin/threadpool_params.c
+++ b/examples/admin/threadpool_params.c
@@ -1,5 +1,3 @@
-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <libvirt/libvirt-admin.h>
diff --git a/examples/dommigrate/dommigrate.c b/examples/dommigrate/dommigrate.c
index 71a0af4058..1b6072d138 100644
--- a/examples/dommigrate/dommigrate.c
+++ b/examples/dommigrate/dommigrate.c
@@ -20,8 +20,6 @@
  * <http://www.gnu.org/licenses/>.
  */

-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <libvirt/libvirt.h>
diff --git a/examples/domsuspend/suspend.c b/examples/domsuspend/suspend.c
index ac816044ef..af61129ecc 100644
--- a/examples/domsuspend/suspend.c
+++ b/examples/domsuspend/suspend.c
@@ -19,8 +19,6 @@
  * <http://www.gnu.org/licenses/>.
  */

-#include <config.h>
-
 #include <errno.h>
 #include <getopt.h>
 #include <libvirt/libvirt.h>
diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
index fb631781fd..4224e4c9ec 100644
--- a/examples/domtop/domtop.c
+++ b/examples/domtop/domtop.c
@@ -18,8 +18,6 @@
  * <http://www.gnu.org/licenses/>.
  */

-#include <config.h>
-
 #include <errno.h>
 #include <getopt.h>
 #include <libvirt/libvirt.h>
diff --git a/examples/hellolibvirt/hellolibvirt.c b/examples/hellolibvirt/hellolibvirt.c
index 02c4401987..bfb12846e6 100644
--- a/examples/hellolibvirt/hellolibvirt.c
+++ b/examples/hellolibvirt/hellolibvirt.c
@@ -2,8 +2,6 @@
  * hypervisor and gather a few bits of information about domains.
  * Similar API's exist for storage pools, networks, and interfaces. */

-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <libvirt/libvirt.h>
diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c
index 6694d3dffc..53d95b10d0 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -1,5 +1,3 @@
-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/examples/openauth/openauth.c b/examples/openauth/openauth.c
index eef46d5f52..efd21c374f 100644
--- a/examples/openauth/openauth.c
+++ b/examples/openauth/openauth.c
@@ -1,8 +1,6 @@
 /* This is a copy of the hellolibvirt example demonstaring how to use
  * virConnectOpenAuth with a custom auth callback */

-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/examples/rename/rename.c b/examples/rename/rename.c
index c64dd5baa3..85f18e9df3 100644
--- a/examples/rename/rename.c
+++ b/examples/rename/rename.c
@@ -16,8 +16,6 @@
  * <http://www.gnu.org/licenses/>.
  */

-#include <config.h>
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <libvirt/libvirt.h>
-- 
2.20.1

--
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]

  Powered by Linux