From 54aee1f627272fbd0d5b7b261b1568a3cac7b73f Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 18 Jul 2017 22:19:54 +0800 Subject: [PATCH] Meson: Set _WIN32_WINNT to 0x0601 (Windows 7) We want to set _WIN32_WINNT so that functions will be properly found in the headers, to target the NT6.1+ (Windows 7+) APIs. Also improve the checks for if_nametoindex() and if_indextoname() on Windows as they are supported in Windows Vista+, but they have to be checked by linking against iphlpapi.lib (or -liphlpapi). On other platforms, they are still checked as they were before. https://bugzilla.gnome.org/show_bug.cgi?id=783270 --- config.h.meson | 2 +- gio/meson.build | 2 +- meson.build | 27 +++++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/config.h.meson b/config.h.meson index 9be790187..ac0b5e0b7 100644 --- a/config.h.meson +++ b/config.h.meson @@ -768,7 +768,7 @@ /* Define for large files, on AIX-style hosts. */ #mesondefine _LARGE_FILES -/* Target the Windows XP API */ +/* Target the Windows 7 API */ #mesondefine _WIN32_WINNT /* Needed to get declarations for msg_control and msg_controllen on Solaris */ diff --git a/gio/meson.build b/gio/meson.build index 8f6ed1bbd..eae9bada8 100644 --- a/gio/meson.build +++ b/gio/meson.build @@ -369,7 +369,7 @@ if host_system == 'windows' contenttype_sources += ['gcontenttype-win32.c'] platform_deps += [cc.find_library('shlwapi'), cc.find_library('dnsapi'), - cc.find_library('iphlpapi'), + iphlpapi_dep, winsock2] win32_sources += [ 'gwin32registrykey.c', diff --git a/meson.build b/meson.build index 3cd2fbe1b..f29af7ebc 100644 --- a/meson.build +++ b/meson.build @@ -255,6 +255,11 @@ foreach m : struct_members endif endforeach +# Windows Support (Vista+) +if host_system == 'windows' + glib_conf.set('_WIN32_WINNT', '0x0601') +endif + functions = [ 'alloca', 'mmap', @@ -311,8 +316,6 @@ functions = [ 'kqueue', 'kevent', 'endservent', - 'if_indextoname', - 'if_nametoindex', 'sendmmsg', 'recvmmsg', ] @@ -328,6 +331,25 @@ else have_func_statfs = false endif +if host_system == 'windows' + iphlpapi_dep = cc.find_library('iphlpapi') + iphlpapi_funcs = ['if_nametoindex', 'if_indextoname'] + foreach ifunc : iphlpapi_funcs + if cc.has_function(ifunc, + prefix : '#define _WIN32_WINNT 0x0601\n#include \n#include ', + dependencies : iphlpapi_dep) + idefine = 'HAVE_' + ifunc.underscorify().to_upper() + glib_conf.set(idefine, 1) + glib_conf_prefix = glib_conf_prefix + '#define @0@ 1\n'.format(idefine) + set_variable('have_func_' + ifunc, true) + else + set_variable('have_func_' + ifunc, false) + endif + endforeach +else + functions += ['if_indextoname', 'if_nametoindex'] +endif + # AIX splice is something else if host_system != 'aix' functions += ['splice'] @@ -674,6 +696,7 @@ endif # AC_FUNC_PRINTF_UNIX98 # Nothing uses HAVE_UNIX98_PRINTF + # Check for nl_langinfo and CODESET # FIXME: Check for HAVE_BIND_TEXTDOMAIN_CODESET if cc.links('''#include