examples: Avoid gnulib, have standalone examples

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 -llibgnu.la, making all of the
examples truly standalone.

Signed-off-by: Eric Blake <eblake@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Eric Blake 2019-01-07 22:15:48 -06:00
parent 6933ebc497
commit acf522e85a
15 changed files with 3 additions and 31 deletions

View File

@ -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 \

View File

@ -1,5 +1,3 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <libvirt/libvirt.h>

View File

@ -1,5 +1,4 @@
#include <config.h>
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

View File

@ -1,5 +1,3 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <libvirt/libvirt-admin.h>

View File

@ -1,5 +1,3 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

View File

@ -1,5 +1,3 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <libvirt/libvirt-admin.h>

View File

@ -1,5 +1,3 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

View File

@ -1,5 +1,3 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <libvirt/libvirt-admin.h>

View File

@ -20,8 +20,6 @@
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <libvirt/libvirt.h>

View File

@ -19,8 +19,6 @@
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <errno.h>
#include <getopt.h>
#include <libvirt/libvirt.h>

View File

@ -18,8 +18,6 @@
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <errno.h>
#include <getopt.h>
#include <libvirt/libvirt.h>

View File

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

View File

@ -1,5 +1,3 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

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

View File

@ -16,8 +16,6 @@
* <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <libvirt/libvirt.h>