]> xenbits.xensource.com Git - libvirt.git/commitdiff
domtop: Fix build on mingw
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 21 Jul 2014 15:26:57 +0000 (17:26 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 22 Jul 2014 07:53:18 +0000 (09:53 +0200)
Firstly, there's no sigaction() nor struct sigaction on mingw. We have
to use the one implemented by gnulib (and hence link with gnulib).
Then, for some reason one header file from windows defines ERROR
symbol. Yes it does. Sigh.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
examples/domtop/Makefile.am
examples/domtop/domtop.c

index c5cb6c73b4fed180ba286bf3554dec822135b854..dbebb4638b347bebd7afeab0a71fa0d820972999 100644 (file)
 ## License along with this library.  If not, see
 ## <http://www.gnu.org/licenses/>.
 
-INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
+INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
+           -I$(top_builddir)/gnulib/lib -I$(top_srcdir)/gnulib/lib \
+           -I$(top_srcdir)
 LDADDS = $(STATIC_BINARIES) $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \
-       $(COVERAGE_LDFLAGS)
+         $(top_builddir)/gnulib/lib/libgnu.la $(COVERAGE_LDFLAGS)
 
 noinst_PROGRAMS=domtop
 
index 4ac7889221cd417645e4fcc65d457ceac8b0530c..af5da4625b516ef7632a4cfe6acfb811c22a121b 100644 (file)
@@ -20,6 +20,8 @@
  * Author: Michal Privoznik <mprivozn@redhat.com>
  */
 
+#include <config.h>
+
 #include <errno.h>
 #include <getopt.h>
 #include <libvirt/libvirt.h>
 static bool debug;
 static bool run_top;
 
+/* On mingw, there's a header file that poisons the well:
+ *
+ *
+ *  CC       domtop.o
+ *domtop.c:40:0: warning: "ERROR" redefined [enabled by default]
+ * #define ERROR(...)                                              \
+ * ^
+ *In file included from /usr/i686-w64-mingw32/sys-root/mingw/include/windows.h:71:0,
+ *                 from /usr/i686-w64-mingw32/sys-root/mingw/include/winsock2.h:23,
+ *                 from ../../gnulib/lib/unistd.h:48,
+ *                 from domtop.c:35:
+ * /usr/i686-w64-mingw32/sys-root/mingw/include/wingdi.h:75:0: note: this is the location of the previous definition
+ * #define ERROR 0
+ */
+#undef ERROR
 #define ERROR(...)                                              \
 do {                                                            \
     fprintf(stderr, "ERROR %s:%d : ", __FUNCTION__, __LINE__);  \