From: Viktor Szakats Date: Thu, 16 Jan 2025 15:47:15 +0000 (+0100) Subject: autotools: add support for mingw UWP builds X-Git-Tag: curl-8_12_0~105 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7bb6c1f64049dcdaee970de6759db6f8597879e;p=thirdparty%2Fcurl.git autotools: add support for mingw UWP builds To match cmake builds. - GHA/windows: allow autotools UWP builds. - detect UWP and add to `buildinfo.txt`. Consider it enabled if `CPPFLAGS` contains `-DWINSTORECOMPAT`. - disable telnet with UWP. - enable Unicode with UWP. - do not use `wldap32` with UWP. - do not enable `USE_WIN32_CRYPTO` with UWP. - make sure to link to `ws2_32` in UWP builds. To fix `undefined reference to `in6addr_any'` when linking `tests/server` programs. More in the comment. Closes #16020 --- diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 38ca501580..c4d0951aa7 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -169,17 +169,18 @@ jobs: strategy: matrix: include: - - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !1233', config: '--enable-debug --disable-threaded-resolver --disable-proxy', name: '!proxy' } - - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --disable-threaded-resolver', name: 'default' } + - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !1233', config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-proxy', name: '!proxy' } + - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --with-openssl --disable-threaded-resolver', name: 'default' } - { build: 'cmake' , sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '-DENABLE_DEBUG=ON -DENABLE_THREADED_RESOLVER=OFF', name: 'default' } - - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '', name: 'default R' } - - { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --disable-threaded-resolver --disable-curldebug --enable-static=no --without-zlib', name: 'default' } - - { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: '' , config: '--enable-debug --enable-windows-unicode --enable-ares', name: 'c-ares U' } + - { build: 'autotools', sys: 'msys' , env: 'x86_64' , tflags: '!19 !504 !704 !705 !1233', config: '--with-openssl', name: 'default R' } + - { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '--enable-debug --with-openssl --disable-threaded-resolver --disable-curldebug --enable-static=no --without-zlib', name: 'default' } + - { build: 'autotools', sys: 'mingw64', env: 'x86_64' , tflags: '' , config: '--enable-debug --with-openssl --enable-windows-unicode --enable-ares', name: 'c-ares U' } # FIXME: WebSockets test results ignored due to frequent failures on native Windows: - { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: '' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_ARES=ON', type: 'Debug', name: 'schannel c-ares U' } - { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DENABLE_CURLDEBUG=ON', type: 'Release', name: 'schannel R TrackMemory' } - { build: 'cmake' , sys: 'clang64', env: 'clang-x86_64', tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=OFF -DCURL_USE_OPENSSL=ON -DENABLE_UNICODE=OFF', type: 'Release', name: 'openssl' } - { build: 'cmake' , sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON', type: 'Release', test: 'uwp', name: 'schannel' } + # { build: 'autotools', sys: 'ucrt64' , env: 'ucrt-x86_64' , tflags: 'skiprun' , config: '--without-debug --with-schannel --enable-shared', type: 'Release', test: 'uwp', name: 'schannel' } - { build: 'cmake' , sys: 'mingw64', env: 'x86_64' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=ON -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON -DCMAKE_VERBOSE_MAKEFILE=ON', type: 'Debug', cflags: '-DCURL_SCHANNEL_DEV_DEBUG', name: 'schannel dev debug' } - { build: 'cmake' , sys: 'mingw32', env: 'i686' , tflags: 'skiprun' , config: '-DENABLE_DEBUG=OFF -DBUILD_SHARED_LIBS=ON -DCURL_USE_SCHANNEL=ON -DENABLE_UNICODE=ON', type: 'Release', name: 'schannel R' } fail-fast: false @@ -228,33 +229,34 @@ jobs: - name: 'configure' timeout-minutes: 5 run: | + if [ '${{ matrix.test }}' = 'uwp' ]; then + CPPFLAGS='-DWINSTORECOMPAT -DWINAPI_FAMILY=WINAPI_FAMILY_APP' + if [[ '${{ matrix.env }}' != 'clang'* ]]; then + specs="$(realpath gcc-specs-uwp)" + gcc -dumpspecs | sed -e 's/-lmingwex/-lwindowsapp -lmingwex -lwindowsapp/' -e 's/-lmsvcrt/-lucrtapp/' > "${specs}" + CFLAGS="-specs=${specs}" + CFLAGS_CMAKE="-specs=$(cygpath -w "${specs}")" + fi + fi if [ '${{ matrix.build }}' = 'cmake' ]; then if [[ '${{ matrix.env }}' = 'clang'* ]]; then options='-DCMAKE_C_COMPILER=clang' else options='-DCMAKE_C_COMPILER=gcc' fi - if [ '${{ matrix.test }}' = 'uwp' ]; then - options+=' -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0' - cflags='-DWINSTORECOMPAT -DWINAPI_FAMILY=WINAPI_FAMILY_APP' - if [[ '${{ matrix.env }}' != 'clang'* ]]; then - specs="$(realpath gcc-specs-uwp)" - gcc -dumpspecs | sed -e 's/-lmingwex/-lwindowsapp -lmingwex -lwindowsapp/' -e 's/-lmsvcrt/-lucrtapp/' > "${specs}" - cflags+=" -specs=$(cygpath -w "${specs}")" - fi - fi + [ '${{ matrix.test }}' = 'uwp' ] && options+=' -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0' [ '${{ matrix.type }}' = 'Debug' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=' [ '${{ matrix.type }}' = 'Release' ] && options+=' -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=' cmake -B bld -G Ninja ${options} \ - "-DCMAKE_C_FLAGS=${{ matrix.cflags }} ${cflags}" \ + "-DCMAKE_C_FLAGS=${{ matrix.cflags }} ${CFLAGS_CMAKE} ${CPPFLAGS}" \ '-DCMAKE_BUILD_TYPE=${{ matrix.type }}' \ -DCMAKE_UNITY_BUILD=ON -DCURL_TEST_BUNDLES=ON \ -DCURL_WERROR=ON \ ${{ matrix.config }} else + export CFLAGS CPPFLAGS mkdir bld && cd bld && ../configure --enable-unity --enable-test-bundles --enable-warnings --enable-werror \ --prefix="${HOME}"/install \ - --with-openssl \ --with-libssh2 \ --disable-dependency-tracking \ ${{ matrix.config }} diff --git a/acinclude.m4 b/acinclude.m4 index 3ca9cdf2b3..d368a1db31 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1413,7 +1413,7 @@ AC_DEFUN([CURL_CHECK_WIN32_CRYPTO], [ AC_REQUIRE([CURL_CHECK_NATIVE_WINDOWS])dnl AC_MSG_CHECKING([whether build target supports Win32 crypto API]) curl_win32_crypto_api="no" - if test "$curl_cv_native_windows" = "yes"; then + if test "$curl_cv_native_windows" = "yes" -a "$curl_cv_winuwp" != "yes"; then AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ #undef inline @@ -1536,6 +1536,9 @@ AC_DEFUN([CURL_PREPARE_BUILDINFO], [ curl_pflags="${curl_pflags} BSD";; esac fi + if test "$curl_cv_winuwp" = 'yes'; then + curl_pflags="${curl_pflags} UWP" + fi if test "$curl_cv_cygwin" = 'yes'; then curl_pflags="${curl_pflags} CYGWIN" fi diff --git a/configure.ac b/configure.ac index fb5824375d..db06693773 100644 --- a/configure.ac +++ b/configure.ac @@ -492,6 +492,12 @@ dnl ********************************************************************** CURL_CHECK_COMPILER CURL_CHECK_NATIVE_WINDOWS + +curl_cv_winuwp='no' +case $CPPFLAGS in + *-DWINSTORECOMPAT*) curl_cv_winuwp='yes';; +esac + CURL_SET_COMPILER_BASIC_OPTS CURL_SET_COMPILER_DEBUG_OPTS CURL_SET_COMPILER_OPTIMIZE_OPTS @@ -873,6 +879,11 @@ AS_HELP_STRING([--disable-telnet],[Disable TELNET support]), AC_MSG_RESULT(yes) ) +if test "$curl_cv_winuwp" = 'yes'; then + AC_DEFINE(CURL_DISABLE_TELNET, 1, [to disable TELNET]) + CURL_DISABLE_TELNET=1 +fi + AC_MSG_CHECKING([whether to support tftp]) AC_ARG_ENABLE(tftp, AS_HELP_STRING([--enable-tftp],[Enable TFTP support]) @@ -1146,7 +1157,9 @@ if test "$HAVE_GETHOSTBYNAME" != "1"; then ]) fi -if test "$HAVE_GETHOSTBYNAME" != "1"; then +# In UWP mode gethostbyname gets detected via the core libs, but some +# code (in6addr_any) still need ws2_32, so let us detect and add it. +if test "$HAVE_GETHOSTBYNAME" != "1" -o "$curl_cv_winuwp" = "yes"; then dnl This is for Winsock systems if test "$curl_cv_native_windows" = "yes"; then winsock_LIB="-lws2_32" @@ -1590,7 +1603,7 @@ if test x$CURL_DISABLE_LDAP != x1; then CURL_CHECK_HEADER_LDAP_SSL if test -z "$LDAPLIBNAME"; then - if test "$curl_cv_native_windows" = "yes"; then + if test "$curl_cv_native_windows" = "yes" -a "$curl_cv_winuwp" != "yes"; then dnl Windows uses a single and unique LDAP library name LDAPLIBNAME="wldap32" LBERLIBNAME="no" @@ -2595,22 +2608,29 @@ dnl ---------------------------- want_winuni="no" if test "$curl_cv_native_windows" = "yes"; then - AC_MSG_CHECKING([whether to enable Windows Unicode (Windows native builds only)]) - AC_ARG_ENABLE(windows-unicode, + if test "$curl_cv_winuwp" = 'yes'; then + want_winuni="yes" + else + AC_MSG_CHECKING([whether to enable Windows Unicode (Windows native builds only)]) + AC_ARG_ENABLE(windows-unicode, AS_HELP_STRING([--enable-windows-unicode],[Enable Windows Unicode]) AS_HELP_STRING([--disable-windows-unicode],[Disable Windows Unicode (default)]), - [ case "$enableval" in - yes) - CPPFLAGS="${CPPFLAGS} -DUNICODE -D_UNICODE" - want_winuni="yes" - AC_MSG_RESULT([yes]) - ;; - *) - AC_MSG_RESULT([no]) - ;; - esac ], - AC_MSG_RESULT([no]) - ) + [ case "$enableval" in + yes) + want_winuni="yes" + AC_MSG_RESULT([yes]) + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac ], + AC_MSG_RESULT([no]) + ) + fi + + if test "$want_winuni" = "yes"; then + CPPFLAGS="${CPPFLAGS} -DUNICODE -D_UNICODE" + fi fi AM_CONDITIONAL([USE_UNICODE], [test "$want_winuni" = "yes"])