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