shithub: flite

Download patch

ref: df846b08571664c312fa3c5e316db8ca24ba4d80
parent: d673f65b2c4a8cd3da7447079309a6dc4bcf1a5e
author: Kubo Takehiro <kubo@jiubao.org>
date: Sun Jun 24 14:53:37 EDT 2018

Fix configure when using mingw32 gcc.

1. Set MINGWPREF by checking the CC variable value.
2. Include windows.h when checking mmsystem.h header.
3. Use wince audio driver when mmsystem.h is available.

--- a/configure
+++ b/configure
@@ -4080,11 +4080,17 @@
                 # For the Windows under mingw32 environment
                 # http://www.mingw.org
 		shared=false
-     	        CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32 -shared"
-                MINGWPREF="i386-mingw32-"
-                CC="${MINGWPREF}gcc"
-                RANLIB="${MINGWPREF}ranlib"
-                AR="${MINGWPREF}ar"
+     	        CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32"
+                PREFLEN=`expr match "$CC" ".*-gcc"`
+                if expr $PREFLEN != 0 > /dev/null; then
+                    # When $CC includes "-gcc", use the preceding
+                    # charactors + '-' as MINGPREF.
+                    # for example:
+                    #   CC=x86_64-w64-mingw32-gcc.exe
+                    #   --> MINGWPREF=x86_64-w64-mingw32-
+                    PREFLEN=`expr $PREFLEN - 3`
+                    MINGPREF=`expr substr $CC 1 $PREFLEN`
+                fi
                 WINDRES="${MINGWPREF}windres"
                 DLLTOOL="${MINGWPREF}dlltool"
                 DLLWRAP="${MINGWPREF}dllwrap"
@@ -4355,7 +4361,8 @@
 fi
 
 
-ac_fn_c_check_header_mongrel "$LINENO" "mmsystem.h" "ac_cv_header_mmsystem_h" "$ac_includes_default"
+ac_fn_c_check_header_compile "$LINENO" "mmsystem.h" "ac_cv_header_mmsystem_h" "#include <windows.h>
+"
 if test "x$ac_cv_header_mmsystem_h" = xyes; then :
   AUDIODRIVER="wince"
 	       AUDIODEFS=-DCST_AUDIO_WINCE
@@ -4368,11 +4375,6 @@
      wince*)
         AUDIODRIVER="wince"
         AUDIODEFS=-DCST_AUDIO_WINCE
-        AUDIOLIBS=
-     ;;
-     mingw*)
-        AUDIODRIVER="none"
-        AUDIODEFS=-DCST_AUDIO_NONE
         AUDIOLIBS=
      ;;
      android*)
--- a/configure.in
+++ b/configure.in
@@ -136,11 +136,17 @@
                 # For the Windows under mingw32 environment
                 # http://www.mingw.org
 		shared=false
-     	        CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32 -shared"
-                MINGWPREF="i386-mingw32-"
-                CC="${MINGWPREF}gcc"
-                RANLIB="${MINGWPREF}ranlib"
-                AR="${MINGWPREF}ar"
+     	        CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32"
+                PREFLEN=`expr match "$CC" ".*-gcc"`
+                if expr $PREFLEN != 0 > /dev/null; then
+                    # When $CC includes "-gcc", use the preceding
+                    # charactors + '-' as MINGPREF.
+                    # for example:
+                    #   CC=x86_64-w64-mingw32-gcc.exe
+                    #   --> MINGWPREF=x86_64-w64-mingw32-
+                    PREFLEN=`expr $PREFLEN - 3`
+                    MINGPREF=`expr substr $CC 1 $PREFLEN`
+                fi
                 WINDRES="${MINGWPREF}windres"
                 DLLTOOL="${MINGWPREF}dlltool"
                 DLLWRAP="${MINGWPREF}dllwrap"
@@ -387,7 +393,9 @@
 AC_CHECK_HEADER(mmsystem.h,
 	      [AUDIODRIVER="wince"
 	       AUDIODEFS=-DCST_AUDIO_WINCE
-	       AUDIOLIBS=-lwinmm])
+	       AUDIOLIBS=-lwinmm],
+	      [],
+	      [#include <windows.h>])
 
 dnl I don't care what you ask for, for wince you get wince
 case "$target_os" in
@@ -394,11 +402,6 @@
      wince*)
         AUDIODRIVER="wince"
         AUDIODEFS=-DCST_AUDIO_WINCE
-        AUDIOLIBS=
-     ;;
-     mingw*)
-        AUDIODRIVER="none"
-        AUDIODEFS=-DCST_AUDIO_NONE
         AUDIOLIBS=
      ;;
      android*)
--- a/windows/Makefile
+++ b/windows/Makefile
@@ -40,7 +40,7 @@
 ##  Also an example command line program                                 ## 
 ##                                                                       ##
 ##  At top level                                                         ##
-##      ./configure --target=i386-mingw32                                ##
+##      ./configure                                                      ##
 ##      make                                                             ##
 ##                                                                       ##
 ###########################################################################