Fix Mingw32 compilation
Unified · Split
| @@ -4080,11 +4080,17 @@ case "$target_os" in · 4079 unmodified lines | |||
| 4080 | # For the Windows under mingw32 environment | 4080 | # For the Windows under mingw32 environment |
| 4081 | # http://www.mingw.org | 4081 | # http://www.mingw.org |
| 4082 | shared=false | 4082 | shared=false |
| 4083 | CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32 -shared" | 4083 | CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32" |
| 4084 | MINGWPREF="i386-mingw32-" | 4084 | PREFLEN=`expr match "$CC" ".*-gcc"` |
| 4085 | CC="${MINGWPREF}gcc" | 4085 | if expr $PREFLEN != 0 > /dev/null; then |
| 4086 | RANLIB="${MINGWPREF}ranlib" | 4086 | # When $CC includes "-gcc", use the preceding |
| 4087 | AR="${MINGWPREF}ar" | 4087 | # charactors + '-' as MINGPREF. |
| 4088 | # for example: | ||
| 4089 | # CC=x86_64-w64-mingw32-gcc.exe | ||
| 4090 | # --> MINGWPREF=x86_64-w64-mingw32- | ||
| 4091 | PREFLEN=`expr $PREFLEN - 3` | ||
| 4092 | MINGPREF=`expr substr $CC 1 $PREFLEN` | ||
| 4093 | fi | ||
| 4088 | WINDRES="${MINGWPREF}windres" | 4094 | WINDRES="${MINGWPREF}windres" |
| 4089 | DLLTOOL="${MINGWPREF}dlltool" | 4095 | DLLTOOL="${MINGWPREF}dlltool" |
| 4090 | DLLWRAP="${MINGWPREF}dllwrap" | 4096 | DLLWRAP="${MINGWPREF}dllwrap" |
| @@ -4355,7 +4361,8 @@ if test "x$ac_cv_header_alsa_asoundlib_h" = xyes; then : · 264 unmodified lines | |||
| 4355 | fi | 4361 | fi |
| 4356 | 4362 | ||
| 4357 | 4363 | ||
| 4358 | ac_fn_c_check_header_mongrel "$LINENO" "mmsystem.h" "ac_cv_header_mmsystem_h" "$ac_includes_default" | 4364 | ac_fn_c_check_header_compile "$LINENO" "mmsystem.h" "ac_cv_header_mmsystem_h" "#include <windows.h> |
| 4365 | " | ||
| 4359 | if test "x$ac_cv_header_mmsystem_h" = xyes; then : | 4366 | if test "x$ac_cv_header_mmsystem_h" = xyes; then : |
| 4360 | AUDIODRIVER="wince" | 4367 | AUDIODRIVER="wince" |
| 4361 | AUDIODEFS=-DCST_AUDIO_WINCE | 4368 | AUDIODEFS=-DCST_AUDIO_WINCE |
| @@ -4370,11 +4377,6 @@ case "$target_os" in · 8 unmodified lines | |||
| 4370 | AUDIODEFS=-DCST_AUDIO_WINCE | 4377 | AUDIODEFS=-DCST_AUDIO_WINCE |
| 4371 | AUDIOLIBS= | 4378 | AUDIOLIBS= |
| 4372 | ;; | 4379 | ;; |
| 4373 | mingw*) | ||
| 4374 | AUDIODRIVER="none" | ||
| 4375 | AUDIODEFS=-DCST_AUDIO_NONE | ||
| 4376 | AUDIOLIBS= | ||
| 4377 | ;; | ||
| 4378 | android*) | 4380 | android*) |
| 4379 | AUDIODRIVER="none" | 4381 | AUDIODRIVER="none" |
| 4380 | AUDIODEFS=-DCST_AUDIO_NONE | 4382 | AUDIODEFS=-DCST_AUDIO_NONE |
| @@ -136,11 +136,17 @@ dnl ;; · 135 unmodified lines | |||
| 136 | # For the Windows under mingw32 environment | 136 | # For the Windows under mingw32 environment |
| 137 | # http://www.mingw.org | 137 | # http://www.mingw.org |
| 138 | shared=false | 138 | shared=false |
| 139 | CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32 -shared" | 139 | CFLAGS="$CFLAGS -DCST_NO_SOCKETS -DUNDER_WINDOWS -DWIN32" |
| 140 | MINGWPREF="i386-mingw32-" | 140 | PREFLEN=`expr match "$CC" ".*-gcc"` |
| 141 | CC="${MINGWPREF}gcc" | 141 | if expr $PREFLEN != 0 > /dev/null; then |
| 142 | RANLIB="${MINGWPREF}ranlib" | 142 | # When $CC includes "-gcc", use the preceding |
| 143 | AR="${MINGWPREF}ar" | 143 | # charactors + '-' as MINGPREF. |
| 144 | # for example: | ||
| 145 | # CC=x86_64-w64-mingw32-gcc.exe | ||
| 146 | # --> MINGWPREF=x86_64-w64-mingw32- | ||
| 147 | PREFLEN=`expr $PREFLEN - 3` | ||
| 148 | MINGPREF=`expr substr $CC 1 $PREFLEN` | ||
| 149 | fi | ||
| 144 | WINDRES="${MINGWPREF}windres" | 150 | WINDRES="${MINGWPREF}windres" |
| 145 | DLLTOOL="${MINGWPREF}dlltool" | 151 | DLLTOOL="${MINGWPREF}dlltool" |
| 146 | DLLWRAP="${MINGWPREF}dllwrap" | 152 | DLLWRAP="${MINGWPREF}dllwrap" |
| @@ -387,7 +393,9 @@ AC_CHECK_HEADER(alsa/asoundlib.h, · 240 unmodified lines | |||
| 387 | AC_CHECK_HEADER(mmsystem.h, | 393 | AC_CHECK_HEADER(mmsystem.h, |
| 388 | [AUDIODRIVER="wince" | 394 | [AUDIODRIVER="wince" |
| 389 | AUDIODEFS=-DCST_AUDIO_WINCE | 395 | AUDIODEFS=-DCST_AUDIO_WINCE |
| 390 | AUDIOLIBS=-lwinmm]) | 396 | AUDIOLIBS=-lwinmm], |
| 397 | [], | ||
| 398 | [#include <windows.h>]) | ||
| 391 | 399 | ||
| 392 | dnl I don't care what you ask for, for wince you get wince | 400 | dnl I don't care what you ask for, for wince you get wince |
| 393 | case "$target_os" in | 401 | case "$target_os" in |
| @@ -396,11 +404,6 @@ case "$target_os" in · 2 unmodified lines | |||
| 396 | AUDIODEFS=-DCST_AUDIO_WINCE | 404 | AUDIODEFS=-DCST_AUDIO_WINCE |
| 397 | AUDIOLIBS= | 405 | AUDIOLIBS= |
| 398 | ;; | 406 | ;; |
| 399 | mingw*) | ||
| 400 | AUDIODRIVER="none" | ||
| 401 | AUDIODEFS=-DCST_AUDIO_NONE | ||
| 402 | AUDIOLIBS= | ||
| 403 | ;; | ||
| 404 | android*) | 407 | android*) |
| 405 | AUDIODRIVER="none" | 408 | AUDIODRIVER="none" |
| 406 | AUDIODEFS=-DCST_AUDIO_NONE | 409 | AUDIODEFS=-DCST_AUDIO_NONE |
| @@ -101,7 +101,13 @@ int cst_sprintf(char *s, const char *fmt, ...); · 100 unmodified lines | |||
| 101 | #ifdef _WIN32 | 101 | #ifdef _WIN32 |
| 102 | #define snprintf c99_snprintf | 102 | #define snprintf c99_snprintf |
| 103 | 103 | ||
| 104 | __inline int c99_vsnprintf(char* str, size_t size, const char* format, | 104 | #ifdef __GNUC__ |
| 105 | #define INLINE static inline | ||
| 106 | #else | ||
| 107 | #define INLINE __inline | ||
| 108 | #endif | ||
| 109 | |||
| 110 | INLINE int c99_vsnprintf(char* str, size_t size, const char* format, | ||
| 105 | va_list ap) { | 111 | va_list ap) { |
| 106 | int count = -1; | 112 | int count = -1; |
| 107 | if (size != 0) | 113 | if (size != 0) |
| @@ -110,7 +116,7 @@ va_list ap) { · 2 unmodified lines | |||
| 110 | count = _vscprintf(format, ap); | 116 | count = _vscprintf(format, ap); |
| 111 | return count; | 117 | return count; |
| 112 | } | 118 | } |
| 113 | __inline int c99_snprintf(char* str, size_t size, const char* format, ...) | 119 | INLINE int c99_snprintf(char* str, size_t size, const char* format, ...) |
| 114 | { | 120 | { |
| 115 | int count; | 121 | int count; |
| 116 | va_list ap; | 122 | va_list ap; |
| @@ -130,7 +130,7 @@ cst_tokenstream *ts_open_generic(const char *filename, · 129 unmodified lines | |||
| 130 | int (*getc)(cst_tokenstream *ts)); | 130 | int (*getc)(cst_tokenstream *ts)); |
| 131 | void ts_close(cst_tokenstream *ts); | 131 | void ts_close(cst_tokenstream *ts); |
| 132 | 132 | ||
| 133 | #ifdef _WIN32 | 133 | #if defined(_WIN32) && !defined(__GNUC__) |
| 134 | __inline int ts_utf8_sequence_length(char c0); | 134 | __inline int ts_utf8_sequence_length(char c0); |
| 135 | #else | 135 | #else |
| 136 | int ts_utf8_sequence_length(char c0); | 136 | int ts_utf8_sequence_length(char c0); |
| @@ -43,6 +43,10 @@ · 42 unmodified lines | |||
| 43 | #include "cst_audio.h" | 43 | #include "cst_audio.h" |
| 44 | #include "cst_alloc.h" | 44 | #include "cst_alloc.h" |
| 45 | 45 | ||
| 46 | #ifndef MAXULONG_PTR | ||
| 47 | #define DWORD_PTR DWORD | ||
| 48 | #endif | ||
| 49 | |||
| 46 | typedef struct au_wince_pdata_struct { | 50 | typedef struct au_wince_pdata_struct { |
| 47 | HWAVEOUT wo; | 51 | HWAVEOUT wo; |
| 48 | HANDLE bevt; | 52 | HANDLE bevt; |
| @@ -84,7 +88,7 @@ static void finish_header(HWAVEOUT drvr, WAVEHDR *hdr) · 35 unmodified lines | |||
| 84 | } | 88 | } |
| 85 | 89 | ||
| 86 | static void CALLBACK sndbuf_done(HWAVEOUT drvr, UINT msg, | 90 | static void CALLBACK sndbuf_done(HWAVEOUT drvr, UINT msg, |
| 87 | DWORD udata, DWORD param1, DWORD param2) | 91 | DWORD_PTR udata, DWORD_PTR param1, DWORD_PTR param2) |
| 88 | { | 92 | { |
| 89 | WAVEHDR *hdr = (WAVEHDR *)param1; | 93 | WAVEHDR *hdr = (WAVEHDR *)param1; |
| 90 | cst_audiodev *ad = (cst_audiodev *)udata; | 94 | cst_audiodev *ad = (cst_audiodev *)udata; |
| @@ -137,7 +141,7 @@ cst_audiodev *audio_open_wince(int sps, int channels, int fmt) · 46 unmodified lines | |||
| 137 | wfx.nBlockAlign = wfx.nChannels*wfx.wBitsPerSample/8; | 141 | wfx.nBlockAlign = wfx.nChannels*wfx.wBitsPerSample/8; |
| 138 | wfx.nAvgBytesPerSec = wfx.nSamplesPerSec*wfx.nBlockAlign; | 142 | wfx.nAvgBytesPerSec = wfx.nSamplesPerSec*wfx.nBlockAlign; |
| 139 | err = waveOutOpen(&wo,WAVE_MAPPER,&wfx, | 143 | err = waveOutOpen(&wo,WAVE_MAPPER,&wfx, |
| 140 | (DWORD)sndbuf_done,(DWORD)ad, | 144 | (DWORD_PTR)sndbuf_done,(DWORD_PTR)ad, |
| 141 | CALLBACK_FUNCTION); | 145 | CALLBACK_FUNCTION); |
| 142 | if (err != MMSYSERR_NOERROR) | 146 | if (err != MMSYSERR_NOERROR) |
| 143 | { | 147 | { |
| @@ -266,7 +266,7 @@ static void get_token_sub_part(cst_tokenstream *ts, · 265 unmodified lines | |||
| 266 | (*buffer)[p] = '\0'; | 266 | (*buffer)[p] = '\0'; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | #ifdef _WIN32 | 269 | #if defined _WIN32 && !defined(__GNUC__) |
| 270 | __inline int ts_utf8_sequence_length(char c0) | 270 | __inline int ts_utf8_sequence_length(char c0) |
| 271 | #else | 271 | #else |
| 272 | int ts_utf8_sequence_length(char c0) | 272 | int ts_utf8_sequence_length(char c0) |
| @@ -40,7 +40,7 @@ · 39 unmodified lines | |||
| 40 | ## Also an example command line program ## | 40 | ## Also an example command line program ## |
| 41 | ## ## | 41 | ## ## |
| 42 | ## At top level ## | 42 | ## At top level ## |
| 43 | ## ./configure --target=i386-mingw32 ## | 43 | ## ./configure ## |
| 44 | ## make ## | 44 | ## make ## |
| 45 | ## ## | 45 | ## ## |
| 46 | ########################################################################### | 46 | ########################################################################### |