Lets see if basing WINDOWS_SDK_BINDIR_NO_ARCH on WINDOWS_SDK_HOME works better

...than basing it on naked winsdktest, even though both should be effectively
equivalent modulo Windows pathname normalization voodoo.  But at least the
Win-x86@62-TDF bot complained after a4d1ed6ba2a81b4284cd360f44b6723bc9bfaf85
"Adapt to Windows SDK 10.0.15063" with

> configure: setting up the build environment variables...
> cygpath: cannot create short name of C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\x86
> configure: error: path conversion failed for "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\/Bin/x86".

presumably because that path does not exist, so pathmunge() -> PathFormat() ->
cygpath can't generate a short 8.1 DOS form for it (and maybe with the already
voodoo'ed WINDOWS_SDK_HOME that happened to work nevertheless, because voodoo?).

Unfortunately, this requires to move the whole "Check for the Windows SDK" block
further up---but the block itself left unchanged except for splitting the part
out that uses WINDOWS_SDK_BINDIR_NO_ARCH.

Change-Id: I13a369ba34b63392ec42333dbc1e538b49a24ca1
Reviewed-on: https://gerrit.libreoffice.org/36481
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
diff --git a/configure.ac b/configure.ac
index 16b3517..505c15d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5316,6 +5316,119 @@ find_msvc_x64_dlls()
    done
}

dnl =========================================
dnl Check for the Windows  SDK.
dnl =========================================
if test "$_os" = "WINNT"; then
    AC_MSG_CHECKING([for Windows SDK])
    if test "$build_os" = "cygwin"; then
        find_winsdk
        WINDOWS_SDK_HOME=$winsdktest

        # normalize if found
        if test -n "$WINDOWS_SDK_HOME"; then
            WINDOWS_SDK_HOME=`cygpath -d "$WINDOWS_SDK_HOME"`
            WINDOWS_SDK_HOME=`cygpath -u "$WINDOWS_SDK_HOME"`
        fi

        WINDOWS_SDK_LIB_SUBDIR=$winsdklibsubdir
    fi

    if test -n "$WINDOWS_SDK_HOME"; then
        # Remove a possible trailing backslash
        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`

        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
            have_windows_sdk_headers=yes
        elif test -f "$WINDOWS_SDK_HOME/Include/um/adoint.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/um/SqlUcode.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/um/usp10.h"; then
            have_windows_sdk_headers=yes
        elif test -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/adoint.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/SqlUcode.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/usp10.h"; then
            have_windows_sdk_headers=yes
        else
            have_windows_sdk_headers=no
        fi

        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
            have_windows_sdk_libs=yes
        elif test -f "$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WINDOWS_SDK_ARCH/user32.lib"; then
            have_windows_sdk_libs=yes
        else
            have_windows_sdk_libs=no
        fi

        if test $have_windows_sdk_headers = no -o $have_windows_sdk_libs = no; then
            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
the  Windows SDK are installed.])
        fi
    fi

    if test -z "$WINDOWS_SDK_HOME"; then
        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway!?])
    elif echo $WINDOWS_SDK_HOME | grep "v7.1" >/dev/null 2>/dev/null; then
        WINDOWS_SDK_VERSION=70
        AC_MSG_RESULT([found Windows SDK 7 ($WINDOWS_SDK_HOME)])
    elif echo $WINDOWS_SDK_HOME | grep "8.0" >/dev/null 2>/dev/null; then
        WINDOWS_SDK_VERSION=80
        AC_MSG_RESULT([found Windows SDK 8.0 ($WINDOWS_SDK_HOME)])
        dnl compatibility warning if not explicitly choosing the 80 SDK:
        if test -z "$with_windows_sdk"; then
            AC_MSG_WARN([If a build should run on Windows XP,])
            AC_MSG_WARN([use --with-windows-sdk=7.1A])
            add_warning "If a build should run on Windows XP,"
            add_warning "use --with-windows-sdk=7.1A"
        fi
    elif echo $WINDOWS_SDK_HOME | grep "8.1" >/dev/null 2>/dev/null; then
        WINDOWS_SDK_VERSION=81
        AC_MSG_RESULT([found Windows SDK 8.1 ($WINDOWS_SDK_HOME)])
    elif echo $WINDOWS_SDK_HOME | grep "/10" >/dev/null 2>/dev/null; then
        WINDOWS_SDK_VERSION=10
        AC_MSG_RESULT([found Windows SDK 10.0 ($WINDOWS_SDK_HOME)])
    else
        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
    fi
    PathFormat "$WINDOWS_SDK_HOME"
    WINDOWS_SDK_HOME="$formatted_path"
    if test "$build_os" = "cygwin"; then
        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/Include"
        if test -d "$WINDOWS_SDK_HOME/include/um"; then
            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include/um -I$WINDOWS_SDK_HOME/include/shared"
        elif test -d "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um"; then
            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/shared"
        fi
    fi

    dnl TODO: solenv/bin/modules/installer/windows/msiglobal.pm wants to use a
    dnl WiLangId.vbs that is included only in some SDKs (e.g., included in v7.1
    dnl but not in v8.0), so allow this to be overridden with a
    dnl WINDOWS_SDK_WILANGID for now; a full-blown --with-windows-sdk-wilangid
    dnl and configuration error if no WiLangId.vbs is found would arguably be
    dnl better, but I do not know under which conditions exactly it is needed by
    dnl msiglobal.pm:
    if test -z "$WINDOWS_SDK_WILANGID" -a -n "$WINDOWS_SDK_HOME"; then
        WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/Samples/sysmgmt/msi/scripts/WiLangId.vbs
        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
            WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/bin/$WINDOWS_SDK_ARCH/WiLangId.vbs
        fi
        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
            WINDOWS_SDK_WILANGID=$(cygpath -sm "C:/Program Files (x86)/Windows Kits/8.1/bin/$WINDOWS_SDK_ARCH/WiLangId.vbs")
        fi
        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
            AC_MSG_WARN([WiLangId.vbs not found - building translated packages will fail])
            add_warning "WiLangId.vbs not found - building translated packages will fail"
        fi
    fi
fi
AC_SUBST(WINDOWS_SDK_HOME)
AC_SUBST(WINDOWS_SDK_LIB_SUBDIR)
AC_SUBST(WINDOWS_SDK_VERSION)
AC_SUBST(WINDOWS_SDK_WILANGID)

if test "$build_os" = "cygwin"; then
    dnl Check midl.exe; this being the first check for a tool in the SDK bin
    dnl dir, it also determines that dir's path w/o an arch segment if any,
@@ -5326,14 +5439,14 @@ if test "$build_os" = "cygwin"; then
    if test -n "$winsdkbinsubdir" \
        -a -f "$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH/midl.exe"
    then
        WINDOWS_SDK_BINDIR_NO_ARCH=$winsdktest/Bin/$winsdkbinsubdir
        MIDL_PATH=$WINDOWS_SDK_BINDIR_NO_ARCH/$WINDOWS_SDK_ARCH
        MIDL_PATH=$winsdktest/Bin/$winsdkbinsubdir/$WINDOWS_SDK_ARCH
        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin/$winsdkbinsubdir
    elif test -f "$winsdktest/Bin/$WINDOWS_SDK_ARCH/midl.exe"; then
        WINDOWS_SDK_BINDIR_NO_ARCH=$winsdktest/Bin
        MIDL_PATH=$WINDOWS_SDK_BINDIR_NO_ARCH/$WINDOWS_SDK_ARCH
        MIDL_PATH=$winsdktest/Bin/$WINDOWS_SDK_ARCH
        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin
    elif test -f "$winsdktest/Bin/midl.exe"; then
        WINDOWS_SDK_BINDIR_NO_ARCH=$winsdktest/Bin
        MIDL_PATH=$WINDOWS_SDK_BINDIR_NO_ARCH
        MIDL_PATH=$winsdktest/Bin
        WINDOWS_SDK_BINDIR_NO_ARCH=$WINDOWS_SDK_HOME/Bin
    fi
    if test ! -f "$MIDL_PATH/midl.exe"; then
        AC_MSG_ERROR([midl.exe not found in $winsdktest/Bin/$WINDOWS_SDK_ARCH, Windows SDK installation broken?])
@@ -5344,6 +5457,18 @@ if test "$build_os" = "cygwin"; then
    # Convert to posix path with 8.3 filename restrictions ( No spaces )
    MIDL_PATH=`win_short_path_for_make "$MIDL_PATH"`

    if test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msiinfo.exe" \
         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msidb.exe" \
         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/uuidgen.exe" \
         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msitran.exe"; then :
    elif test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msiinfo.exe" \
         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msidb.exe" \
         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
         -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msitran.exe"; then :
    else
        AC_MSG_ERROR([Some (all?) Windows Installer tools in the Windows SDK are missing, please install.])
    fi

    dnl Check csc.exe
    AC_MSG_CHECKING([for csc.exe])
    find_csc
@@ -9565,131 +9690,6 @@ if test "$_os" = "Linux"; then
fi

dnl =========================================
dnl Check for the Windows  SDK.
dnl =========================================
if test "$_os" = "WINNT"; then
    AC_MSG_CHECKING([for Windows SDK])
    if test "$build_os" = "cygwin"; then
        find_winsdk
        WINDOWS_SDK_HOME=$winsdktest

        # normalize if found
        if test -n "$WINDOWS_SDK_HOME"; then
            WINDOWS_SDK_HOME=`cygpath -d "$WINDOWS_SDK_HOME"`
            WINDOWS_SDK_HOME=`cygpath -u "$WINDOWS_SDK_HOME"`
        fi

        WINDOWS_SDK_LIB_SUBDIR=$winsdklibsubdir
    fi

    if test -n "$WINDOWS_SDK_HOME"; then
        # Remove a possible trailing backslash
        WINDOWS_SDK_HOME=`echo $WINDOWS_SDK_HOME | $SED 's/\/$//'`

        if test -f "$WINDOWS_SDK_HOME/Include/adoint.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/SqlUcode.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/usp10.h"; then
            have_windows_sdk_headers=yes
        elif test -f "$WINDOWS_SDK_HOME/Include/um/adoint.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/um/SqlUcode.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/um/usp10.h"; then
            have_windows_sdk_headers=yes
        elif test -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/adoint.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/SqlUcode.h" \
             -a -f "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um/usp10.h"; then
            have_windows_sdk_headers=yes
        else
            have_windows_sdk_headers=no
        fi

        if test -f "$WINDOWS_SDK_HOME/lib/user32.lib"; then
            have_windows_sdk_libs=yes
        elif test -f "$WINDOWS_SDK_HOME/lib/$winsdklibsubdir/um/$WINDOWS_SDK_ARCH/user32.lib"; then
            have_windows_sdk_libs=yes
        else
            have_windows_sdk_libs=no
        fi

        if test $have_windows_sdk_headers = no -o $have_windows_sdk_libs = no; then
            AC_MSG_ERROR([Some (all?) Windows SDK files not found, please check if all needed parts of
the  Windows SDK are installed.])
        fi

        if test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msiinfo.exe" \
             -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msidb.exe" \
             -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/uuidgen.exe" \
             -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/msitran.exe"; then :
        elif test -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msiinfo.exe" \
             -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msidb.exe" \
             -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/uuidgen.exe" \
             -a -f "$WINDOWS_SDK_BINDIR_NO_ARCH/x86/msitran.exe"; then :
        else
            AC_MSG_ERROR([Some (all?) Windows Installer tools in the Windows SDK are missing, please install.])
        fi
    fi

    if test -z "$WINDOWS_SDK_HOME"; then
        AC_MSG_RESULT([no, hoping the necessary headers and libraries will be found anyway!?])
    elif echo $WINDOWS_SDK_HOME | grep "v7.1" >/dev/null 2>/dev/null; then
        WINDOWS_SDK_VERSION=70
        AC_MSG_RESULT([found Windows SDK 7 ($WINDOWS_SDK_HOME)])
    elif echo $WINDOWS_SDK_HOME | grep "8.0" >/dev/null 2>/dev/null; then
        WINDOWS_SDK_VERSION=80
        AC_MSG_RESULT([found Windows SDK 8.0 ($WINDOWS_SDK_HOME)])
        dnl compatibility warning if not explicitly choosing the 80 SDK:
        if test -z "$with_windows_sdk"; then
            AC_MSG_WARN([If a build should run on Windows XP,])
            AC_MSG_WARN([use --with-windows-sdk=7.1A])
            add_warning "If a build should run on Windows XP,"
            add_warning "use --with-windows-sdk=7.1A"
        fi
    elif echo $WINDOWS_SDK_HOME | grep "8.1" >/dev/null 2>/dev/null; then
        WINDOWS_SDK_VERSION=81
        AC_MSG_RESULT([found Windows SDK 8.1 ($WINDOWS_SDK_HOME)])
    elif echo $WINDOWS_SDK_HOME | grep "/10" >/dev/null 2>/dev/null; then
        WINDOWS_SDK_VERSION=10
        AC_MSG_RESULT([found Windows SDK 10.0 ($WINDOWS_SDK_HOME)])
    else
        AC_MSG_ERROR([Found legacy Windows Platform SDK ($WINDOWS_SDK_HOME)])
    fi
    PathFormat "$WINDOWS_SDK_HOME"
    WINDOWS_SDK_HOME="$formatted_path"
    if test "$build_os" = "cygwin"; then
        SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include -I$COMPATH/Include"
        if test -d "$WINDOWS_SDK_HOME/include/um"; then
            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/include/um -I$WINDOWS_SDK_HOME/include/shared"
        elif test -d "$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um"; then
            SOLARINC="$SOLARINC -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/um -I$WINDOWS_SDK_HOME/Include/$winsdklibsubdir/shared"
        fi
    fi

    dnl TODO: solenv/bin/modules/installer/windows/msiglobal.pm wants to use a
    dnl WiLangId.vbs that is included only in some SDKs (e.g., included in v7.1
    dnl but not in v8.0), so allow this to be overridden with a
    dnl WINDOWS_SDK_WILANGID for now; a full-blown --with-windows-sdk-wilangid
    dnl and configuration error if no WiLangId.vbs is found would arguably be
    dnl better, but I do not know under which conditions exactly it is needed by
    dnl msiglobal.pm:
    if test -z "$WINDOWS_SDK_WILANGID" -a -n "$WINDOWS_SDK_HOME"; then
        WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/Samples/sysmgmt/msi/scripts/WiLangId.vbs
        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
            WINDOWS_SDK_WILANGID=$WINDOWS_SDK_HOME/bin/$WINDOWS_SDK_ARCH/WiLangId.vbs
        fi
        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
            WINDOWS_SDK_WILANGID=$(cygpath -sm "C:/Program Files (x86)/Windows Kits/8.1/bin/$WINDOWS_SDK_ARCH/WiLangId.vbs")
        fi
        if ! test -e "$WINDOWS_SDK_WILANGID" ; then
            AC_MSG_WARN([WiLangId.vbs not found - building translated packages will fail])
            add_warning "WiLangId.vbs not found - building translated packages will fail"
        fi
    fi
fi
AC_SUBST(WINDOWS_SDK_HOME)
AC_SUBST(WINDOWS_SDK_LIB_SUBDIR)
AC_SUBST(WINDOWS_SDK_VERSION)
AC_SUBST(WINDOWS_SDK_WILANGID)

dnl =========================================
dnl Check for uuidgen
dnl =========================================
if test "$_os" = "WINNT" -a "$cross_compiling" != "yes"; then