[vlc-devel] [PATCH 1/7] configure: detect if we can run win32 executables

Steve Lhomme robux4 at ycbcr.xyz
Tue May 12 12:28:02 CEST 2020


It is possible to run win32 executables when cross compiling with mingw64. It's
even mandatory to build contribs as it needs to call fxc.exe (currently
hardcoded to use wine).

Whether it's in WSL, msys2 or wine, we can run them.
---
 configure.ac | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/configure.ac b/configure.ac
index 4b13af45e46a..19e3f8aed7a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,6 +140,7 @@ case "${host_cpu}" in
         ;;
 esac
 
+RUN_HOST_CMD=
 case "${host_os}" in
   "")
     SYS=unknown
@@ -1291,6 +1292,33 @@ if test "${ac_cv_c_attribute_packed}" != "no"; then
   AC_DEFINE(HAVE_ATTRIBUTE_PACKED, 1, Support for __attribute__((packed)) for structs)
 fi
 
+AS_IF([test "${SYS}" = "mingw32"], [
+    dnl
+    dnl Detect if we can call windows apps
+    dnl
+    AC_MSG_CHECKING([whether we can call win32 executables])
+    AC_TRY_LINK([#include <stdio.h>], [char buf[100]; fgets(buf, sizeof(buf), stdin);], [
+      win32_run_cmd=no
+      for run_win in "" "wine"
+      do
+        ac_try="$run_win ./conftest$ac_exeext"
+        (eval "$ac_try") 2>&5
+        ac_status=$?
+        if test $ac_status = 0; then
+          win32_run_cmd=$run_win
+          break
+        fi
+      done
+      AS_IF([test "x${win32_run_cmd}" != "xno"],[
+        HAVE_RUN_HOST="1"
+        RUN_HOST_CMD=${win32_run_cmd}
+        AC_MSG_RESULT([using '${win32_run_cmd} app.exe'])
+      ],[
+        AC_MSG_RESULT([not found])
+      ])
+    ])
+])
+
 dnl
 dnl  Check the CPU
 dnl
@@ -1307,6 +1335,8 @@ case "${host_cpu}" in
     ;;
 esac
 
+AC_SUBST([RUN_HOST_CMD])
+
 dnl Check for backtrace() support
 AC_CHECK_HEADERS([execinfo.h])
 AC_CHECK_FUNCS([backtrace])
-- 
2.26.2



More information about the vlc-devel mailing list