Received: from eggs.gnu.org ([2001:4830:134:3::10]:55795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcSs2-0004kZ-9h for qemu-devel@nongnu.org; Wed, 24 Aug 2016 03:45:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcSrz-0006Nt-3A for qemu-devel@nongnu.org; Wed, 24 Aug 2016 03:45:10 -0400 Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:34469) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1bcSry-0006G0-NV for qemu-devel@nongnu.org; Wed, 24 Aug 2016 03:45:07 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 24 Aug 2016 01:44:44 -0600 From: Evan Hunter Message-ID: Subject: [Qemu-devel] Patch to add support for building in MSYS2 on Windows List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Weil Hi, I noticed that QEMU would not compile on Windows in the MSYS2 environment. Here is a patch that adds a check for it to the configure script and amended some ifdefs so it now builds. At the bottom of this email is a build script I made for building under MSYS2, however I am not sure if it is suitable merging nor where it should go. Regards, Evan Hunter ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- MSYS2 Patch: From 81eee3b9c0722b054852d002b605d55b0530a4ce Mon Sep 17 00:00:00 2001 From: Evan Hunter Date: Sun, 21 Aug 2016 17:27:46 +0100 Subject: [PATCH 1/2] Add support for building on Windows in MSYS2 Signed-off-by: Evan Hunter --- block.c | 2 +- configure | 12 +++++++++++- net/tap-bsd.c | 4 ++-- os-posix.c | 6 +++--- qga/channel-posix.c | 2 +- slirp/slirp.h | 2 +- util/compatfd.c | 2 ++ util/qemu-openpty.c | 2 +- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/block.c b/block.c index 30d64e6..534039d 100644 --- a/block.c +++ b/block.c @@ -44,7 +44,7 @@ #ifdef CONFIG_BSD #include #include -#ifndef __DragonFly__ +#if !defined(__DragonFly__) && !defined(__MSYS__) #include #endif #endif diff --git a/configure b/configure index 4b808f9..11ba495 100755 --- a/configure +++ b/configure @@ -566,6 +566,10 @@ MINGW32*) audio_drv_list="" fi ;; +MSYS_NT-*) + bsd="yes" + audio_drv_list="dsound" +;; GNU/kFreeBSD) bsd="yes" audio_drv_list="oss" @@ -680,7 +684,13 @@ esac if [ "$bsd" = "yes" ] ; then if [ "$darwin" != "yes" ] ; then - bsd_user="yes" + case $targetos in + MSYS_NT-*) + ;; + *) + bsd_user="yes" + ;; + esac fi fi diff --git a/net/tap-bsd.c b/net/tap-bsd.c index c506ac3..de68d67 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -42,7 +42,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int fd; #ifdef TAPGIFNAME struct ifreq ifr; -#else +#elif !defined(__MSYS__) char *dev; struct stat s; #endif @@ -83,7 +83,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, return -1; } pstrcpy(ifname, ifname_size, ifr.ifr_name); -#else +#elif !defined(__MSYS__) if (fstat(fd, &s) < 0) { error_setg_errno(errp, errno, "could not stat %s", dname); return -1; diff --git a/os-posix.c b/os-posix.c index c6ddb7d..af86512 100644 --- a/os-posix.c +++ b/os-posix.c @@ -329,12 +329,12 @@ bool is_daemonized(void) int os_mlock(void) { - int ret = 0; - + int ret = -ENOSYS;; +#ifndef __MSYS__ ret = mlockall(MCL_CURRENT | MCL_FUTURE); if (ret < 0) { perror("mlockall"); } - +#endif return ret; } diff --git a/qga/channel-posix.c b/qga/channel-posix.c index bb65d8b..aa58fec 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -130,7 +130,7 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod switch (c->method) { case GA_CHANNEL_VIRTIO_SERIAL: { int fd = qemu_open(path, O_RDWR | O_NONBLOCK -#ifndef CONFIG_SOLARIS +#if !defined(CONFIG_SOLARIS) && !defined(__MSYS__) | O_ASYNC #endif ); diff --git a/slirp/slirp.h b/slirp/slirp.h index a1f3139..0dc6dfa 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -15,7 +15,7 @@ typedef char *caddr_t; # include #else -# if !defined(__HAIKU__) +# if !defined(__HAIKU__) && !defined(__MSYS__) # define O_BINARY 0 # endif #endif diff --git a/util/compatfd.c b/util/compatfd.c index 9a43042..0cf4afd 100644 --- a/util/compatfd.c +++ b/util/compatfd.c @@ -18,7 +18,9 @@ #include "qemu/compatfd.h" #include "qemu/thread.h" +#ifndef __MSYS__ #include +#endif struct sigfd_compat_info { diff --git a/util/qemu-openpty.c b/util/qemu-openpty.c index 2e8b43b..99e6a5b 100644 --- a/util/qemu-openpty.c +++ b/util/qemu-openpty.c @@ -35,7 +35,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#if defined(__GLIBC__) +#if defined(__GLIBC__) || defined(__MSYS__) # include #elif defined CONFIG_BSD # include -- 1.9.5.msysgit.0 ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------- MSYS2 Build Script: #!/bin/bash # # Script for building QEMU on Windows in MSYS2 environment # set -e uname_output=`uname` if [ $uname_output != MSYS_NT-6.1 ]; then echo "This script is only for building under MSYS2" exit 1 fi package_list="python2 make pkg-config gcc zlib-devel glib2-devel autoconf bison automake1.10 libtool libutil-linux-devel" if ! pacman -Q $package_list > /dev/null; then echo "Missing dependencies. Please run:" echo "pacman -S $package_list" exit 1 fi echo "Configuring..." mkdir -p build cd build CC=/usr/bin/gcc ../configure --python=/usr/bin/python2 2>&1 | tee build.log echo "Building..." make -j6 2>&1 | tee -a build.log echo "Done"