diff mbox

[v4,1/2] qga: add additional win32 cflags and libraries

Message ID 1433184977-20001-2-git-send-email-kallan@suse.com
State New
Headers show

Commit Message

Kirk Allan June 1, 2015, 6:56 p.m. UTC
Test if –-extra-cflags is being used to include flags such as
_WIN32_WINVER and WINVER to gain additional functionality offered
by Windows Vista/2008 and newer.  If not, default WINVER to 0x501.

Add the iphlpapi library to use APIs such as GetAdaptersInfo and
GetAdaptersAddresses.

Signed-off-by: Kirk Allan <kallan@suse.com>
---
 configure | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Eric Blake June 1, 2015, 7 p.m. UTC | #1
On 06/01/2015 12:56 PM, Kirk Allan wrote:
> Test if –-extra-cflags is being used to include flags such as

Something in your workflow is substituting UTF-8 characters instead of
ASCII '-'.  s/–-/--/

> _WIN32_WINVER and WINVER to gain additional functionality offered
> by Windows Vista/2008 and newer.  If not, default WINVER to 0x501.
> 
> Add the iphlpapi library to use APIs such as GetAdaptersInfo and
> GetAdaptersAddresses.
> 
> Signed-off-by: Kirk Allan <kallan@suse.com>
> ---
>  configure | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 4e2f78a..67bd9af 100755
> --- a/configure
> +++ b/configure
> @@ -708,7 +708,12 @@ fi
>  if test "$mingw32" = "yes" ; then
>    EXESUF=".exe"
>    DSOSUF=".dll"
> -  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
> +  # --extra-cflags can be used to set flags such as -DWINVER and
> +  # -D_WIN32_WINNT.  If -DWINVER has not be set, default to XP (0x501).

s/be/been/

However, I'm not all that fluent in Windows compilation, so I'll let
others do the actual technical review.
Paolo Bonzini June 1, 2015, 8:24 p.m. UTC | #2
On 01/06/2015 20:56, Kirk Allan wrote:
> Test if –-extra-cflags is being used to include flags such as
> _WIN32_WINVER and WINVER to gain additional functionality offered
> by Windows Vista/2008 and newer.  If not, default WINVER to 0x501.
> 
> Add the iphlpapi library to use APIs such as GetAdaptersInfo and
> GetAdaptersAddresses.
> 
> Signed-off-by: Kirk Allan <kallan@suse.com>

Elsewhere on the list, we've discussed putting extra cflags _after_ the
configure-detected QEMU_CFLAGS.  This would fix the issue in the first
part of this patch too.

Is iphlpapi available on Windows XP?

Paolo

> ---
>  configure | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/configure b/configure
> index 4e2f78a..67bd9af 100755
> --- a/configure
> +++ b/configure
> @@ -708,7 +708,12 @@ fi
>  if test "$mingw32" = "yes" ; then
>    EXESUF=".exe"
>    DSOSUF=".dll"
> -  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
> +  # --extra-cflags can be used to set flags such as -DWINVER and
> +  # -D_WIN32_WINNT.  If -DWINVER has not be set, default to XP (0x501).
> +  if [ "$QEMU_CFLAGS" = "${QEMU_CFLAGS%-DWINVER=*}" ] ; then
> +    QEMU_CFLAGS="-DWINVER=0x501 $QEMU_CFLAGS"
> +  fi
> +  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN $QEMU_CFLAGS"
>    # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
>    QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
>    LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
> @@ -724,7 +729,7 @@ if test "$mingw32" = "yes" ; then
>    sysconfdir="\${prefix}"
>    local_statedir=
>    confsuffix=""
> -  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
> +  libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi $libs_qga"
>  fi
>  
>  werror=""
>
Kirk Allan June 1, 2015, 9:19 p.m. UTC | #3
>>>

> 
> On 01/06/2015 20:56, Kirk Allan wrote:
>> Test if *-extra-cflags is being used to include flags such as
>> _WIN32_WINVER and WINVER to gain additional functionality offered
>> by Windows Vista/2008 and newer.  If not, default WINVER to 0x501.
>> 
>> Add the iphlpapi library to use APIs such as GetAdaptersInfo and
>> GetAdaptersAddresses.
>> 
>> Signed-off-by: Kirk Allan <kallan@suse.com>
> 
> Elsewhere on the list, we've discussed putting extra cflags _after_ the
> configure-detected QEMU_CFLAGS.  This would fix the issue in the first
> part of this patch too.

By the time this portion of the configure script executes, any --extra-cflags have already been rolled into the QEMU_CFLAGS.  Here I'm just checking if WINVER is already contained in QEMU_CFLAGS.  If it is not, then add WINVER=0x501 to the flags as it was done before.  If it's already contained in the QEMU_CFLAGS, just use what's there.  The only ordering difference would be WINVER now comes before  WIN32_LEAN_AND_MEAN.

> 
> Is iphlpapi available on Windows XP?

Yes

> 
> Paolo
> 
>> ---
>>  configure | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>> 
>> diff --git a/configure b/configure
>> index 4e2f78a..67bd9af 100755
>> --- a/configure
>> +++ b/configure
>> @@ -708,7 +708,12 @@ fi
>>  if test "$mingw32" = "yes" ; then
>>    EXESUF=".exe"
>>    DSOSUF=".dll"
>> -  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
>> +  # --extra-cflags can be used to set flags such as -DWINVER and
>> +  # -D_WIN32_WINNT.  If -DWINVER has not be set, default to XP (0x501).
>> +  if [ "$QEMU_CFLAGS" = "${QEMU_CFLAGS%-DWINVER=*}" ] ; then
>> +    QEMU_CFLAGS="-DWINVER=0x501 $QEMU_CFLAGS"
>> +  fi
>> +  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN $QEMU_CFLAGS"
>>    # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
>>    QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
>>    LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
>> @@ -724,7 +729,7 @@ if test "$mingw32" = "yes" ; then
>>    sysconfdir="\${prefix}"
>>    local_statedir=
>>    confsuffix=""
>> -  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
>> +  libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi $libs_qga"
>>  fi
>>  
>>  werror=""
>>
Paolo Bonzini June 2, 2015, 2:08 p.m. UTC | #4
On 01/06/2015 23:19, Kirk Allan wrote:
>> Elsewhere on the list, we've discussed putting extra cflags
>> _after_ the configure-detected QEMU_CFLAGS.  This would fix the
>> issue in the first part of this patch too.
> 
> By the time this portion of the configure script executes, any
> --extra-cflags have already been rolled into the QEMU_CFLAGS.  Here
> I'm just checking if WINVER is already contained in QEMU_CFLAGS.  If
> it is not, then add WINVER=0x501 to the flags as it was done before.
> If it's already contained in the QEMU_CFLAGS, just use what's there.
> The only ordering difference would be WINVER now comes before
> WIN32_LEAN_AND_MEAN.

If the extra cflags come last, they override the -DWINVER=0x501 that
configure adds, and this patch isn't necessary anymore.

Paolo
Kirk Allan June 2, 2015, 3:30 p.m. UTC | #5
>>>

> 
> On 01/06/2015 23:19, Kirk Allan wrote:
>>> Elsewhere on the list, we've discussed putting extra cflags
>>> _after_ the configure-detected QEMU_CFLAGS.  This would fix the
>>> issue in the first part of this patch too.
>> 
>> By the time this portion of the configure script executes, any
>> --extra-cflags have already been rolled into the QEMU_CFLAGS.  Here
>> I'm just checking if WINVER is already contained in QEMU_CFLAGS.  If
>> it is not, then add WINVER=0x501 to the flags as it was done before.
>> If it's already contained in the QEMU_CFLAGS, just use what's there.
>> The only ordering difference would be WINVER now comes before
>> WIN32_LEAN_AND_MEAN.
> 
> If the extra cflags come last, they override the -DWINVER=0x501 that
> configure adds, and this patch isn't necessary anymore.

I was assuming that if you set _WIN32_WINNT=0x0600 (needed to gain access to the OnLinkPrefixLength field when running on Windows Vista/2008 and greater) you would also want to set WINVER=0x600 to match.  Having WINVER in the flags as both 501 and 600 causes configure errors.

Testing with _WIN32_WINNT=0x0600 and WINVER=0x501 seems to be ok.

I'll remove the first portion of the patch and just leave adding -liphlpapi.

> 
> Paolo
Paolo Bonzini June 2, 2015, 7:41 p.m. UTC | #6
On 02/06/2015 17:30, Kirk Allan wrote:
> I was assuming that if you set _WIN32_WINNT=0x0600 (needed to gain
> access to the OnLinkPrefixLength field when running on Windows
> Vista/2008 and greater) you would also want to set WINVER=0x600 to
> match.  Having WINVER in the flags as both 501 and 600 causes
> configure errors.

Hmm, right.  It gives a "redefined" warning as if you had #define.  And
the warning is fatal.  So

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

> Testing with _WIN32_WINNT=0x0600 and WINVER=0x501 seems to be ok.
diff mbox

Patch

diff --git a/configure b/configure
index 4e2f78a..67bd9af 100755
--- a/configure
+++ b/configure
@@ -708,7 +708,12 @@  fi
 if test "$mingw32" = "yes" ; then
   EXESUF=".exe"
   DSOSUF=".dll"
-  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS"
+  # --extra-cflags can be used to set flags such as -DWINVER and
+  # -D_WIN32_WINNT.  If -DWINVER has not be set, default to XP (0x501).
+  if [ "$QEMU_CFLAGS" = "${QEMU_CFLAGS%-DWINVER=*}" ] ; then
+    QEMU_CFLAGS="-DWINVER=0x501 $QEMU_CFLAGS"
+  fi
+  QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN $QEMU_CFLAGS"
   # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later)
   QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS"
   LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS"
@@ -724,7 +729,7 @@  if test "$mingw32" = "yes" ; then
   sysconfdir="\${prefix}"
   local_statedir=
   confsuffix=""
-  libs_qga="-lws2_32 -lwinmm -lpowrprof $libs_qga"
+  libs_qga="-lws2_32 -lwinmm -lpowrprof -liphlpapi $libs_qga"
 fi
 
 werror=""