From af3ab2e2e3c63d6412d70d1f2c75c10c54253b95 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 4 Jun 2025 11:52:59 +0200 Subject: configure: [Windows] Add --with-winver option to specify minimum Windows version This effectively defines WINVER and _WIN32_WINNT to the specified value which will compile the code with that minimum supported Windows version instead of the compiler/SDK default. The passed value is expected to be in hex (like 0x0600) or decimal, so passing --with-winver=0x0600 is a valid accepted input. See https://learn.microsoft.com/cpp/porting/modifying-winver-and-win32-winnt for the values of different Windows versions. --- configure.ac | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0f0a755..5471ad3 100644 --- a/configure.ac +++ b/configure.ac @@ -71,7 +71,24 @@ case ${host_os} in *mingw32*|*cygwin*) AC_MSG_RESULT([${host_os}]) win32=true - AC_DEFINE(WINVER, 0x0501, [minimum Windows version]) + AC_ARG_WITH([winver], + [AS_HELP_STRING([--with-winver], [Set the minimum windows version])], + [ + AS_CASE([${withval}], + [0x[[0-9A-Fa-f]]|0x[[0-9A-Fa-f]]*[[0-9A-Fa-f]]], [VAL=${withval}], + ['' | *[[!0123456789]]*], [VAL=""], + [[[!0]]*], [VAL=${withval}], + [VAL=""] + ) + AS_IF([test "x$VAL" != "x"], [ + AC_DEFINE_UNQUOTED(WINVER, ${VAL}, [minimum Windows version]) + AC_DEFINE_UNQUOTED(_WIN32_WINNT, ${VAL}, [minimum Windows version]) + ], [ + AC_MSG_ERROR([--with-winver expects a hexadecimal value like 0x0600, or a decimal, and must not be 0]) + ]) + ], + [] + ) ;; darwin*) AC_MSG_RESULT([${host_os}]) -- cgit v1.1-32-gdbae