History

Merge pull request #15 from kubo/mingw32

Fix Mingw32 compilation

Kevin Lenzo committed 6 years ago

Commit d8826b02 parents 6bc1cdd 3b16ff87 files · +44 −29Browse files

Unified · Split

7 files
  1. configure +13 −11
  2. configure.in +14 −11
  3. include/cst_file.h +8 −2
  4. include/cst_tokenstream.h +1 −1
  5. src/audio/au_wince.c +6 −2
  6. src/utils/cst_tokenstream.c +1 −1
  7. windows/Makefile +1 −1
configure+13−11
@@ -4080,11 +4080,17 @@ case "$target_os" in · 4079 unmodified lines
40804080 # For the Windows under mingw32 environment
40814081 # http://www.mingw.org
40824082 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
40884094 WINDRES="${MINGWPREF}windres"
40894095 DLLTOOL="${MINGWPREF}dlltool"
40904096 DLLWRAP="${MINGWPREF}dllwrap"
@@ -4355,7 +4361,8 @@ if test "x$ac_cv_header_alsa_asoundlib_h" = xyes; then : · 264 unmodified lines
43554361 fi
43564362
43574363
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+"
43594366 if test "x$ac_cv_header_mmsystem_h" = xyes; then :
43604367 AUDIODRIVER="wince"
43614368 AUDIODEFS=-DCST_AUDIO_WINCE
@@ -4370,11 +4377,6 @@ case "$target_os" in · 8 unmodified lines
43704377 AUDIODEFS=-DCST_AUDIO_WINCE
43714378 AUDIOLIBS=
43724379 ;;
4373− mingw*)
4374− AUDIODRIVER="none"
4375− AUDIODEFS=-DCST_AUDIO_NONE
4376− AUDIOLIBS=
4377− ;;
43784380 android*)
43794381 AUDIODRIVER="none"
43804382 AUDIODEFS=-DCST_AUDIO_NONE
configure.in+14−11
@@ -136,11 +136,17 @@ dnl ;; · 135 unmodified lines
136136 # For the Windows under mingw32 environment
137137 # http://www.mingw.org
138138 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
144150 WINDRES="${MINGWPREF}windres"
145151 DLLTOOL="${MINGWPREF}dlltool"
146152 DLLWRAP="${MINGWPREF}dllwrap"
@@ -387,7 +393,9 @@ AC_CHECK_HEADER(alsa/asoundlib.h, · 240 unmodified lines
387393 AC_CHECK_HEADER(mmsystem.h,
388394 [AUDIODRIVER="wince"
389395 AUDIODEFS=-DCST_AUDIO_WINCE
390− AUDIOLIBS=-lwinmm])
396+ AUDIOLIBS=-lwinmm],
397+ [],
398+ [#include <windows.h>])
391399
392400 dnl I don't care what you ask for, for wince you get wince
393401 case "$target_os" in
@@ -396,11 +404,6 @@ case "$target_os" in · 2 unmodified lines
396404 AUDIODEFS=-DCST_AUDIO_WINCE
397405 AUDIOLIBS=
398406 ;;
399− mingw*)
400− AUDIODRIVER="none"
401− AUDIODEFS=-DCST_AUDIO_NONE
402− AUDIOLIBS=
403− ;;
404407 android*)
405408 AUDIODRIVER="none"
406409 AUDIODEFS=-DCST_AUDIO_NONE
include/cst_file.h+8−2
@@ -101,7 +101,13 @@ int cst_sprintf(char *s, const char *fmt, ...); · 100 unmodified lines
101101 #ifdef _WIN32
102102 #define snprintf c99_snprintf
103103
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,
105111 va_list ap) {
106112 int count = -1;
107113 if (size != 0)
@@ -110,7 +116,7 @@ va_list ap) { · 2 unmodified lines
110116 count = _vscprintf(format, ap);
111117 return count;
112118 }
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, ...)
114120 {
115121 int count;
116122 va_list ap;
include/cst_tokenstream.h+1−1
@@ -130,7 +130,7 @@ cst_tokenstream *ts_open_generic(const char *filename, · 129 unmodified lines
130130 int (*getc)(cst_tokenstream *ts));
131131 void ts_close(cst_tokenstream *ts);
132132
133−#ifdef _WIN32
133+#if defined(_WIN32) && !defined(__GNUC__)
134134 __inline int ts_utf8_sequence_length(char c0);
135135 #else
136136 int ts_utf8_sequence_length(char c0);
src/audio/au_wince.c+6−2
@@ -43,6 +43,10 @@ · 42 unmodified lines
4343 #include "cst_audio.h"
4444 #include "cst_alloc.h"
4545
46+#ifndef MAXULONG_PTR
47+#define DWORD_PTR DWORD
48+#endif
49+
4650 typedef struct au_wince_pdata_struct {
4751 HWAVEOUT wo;
4852 HANDLE bevt;
@@ -84,7 +88,7 @@ static void finish_header(HWAVEOUT drvr, WAVEHDR *hdr) · 35 unmodified lines
8488 }
8589
8690 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)
8892 {
8993 WAVEHDR *hdr = (WAVEHDR *)param1;
9094 cst_audiodev *ad = (cst_audiodev *)udata;
@@ -137,7 +141,7 @@ cst_audiodev *audio_open_wince(int sps, int channels, int fmt) · 46 unmodified lines
137141 wfx.nBlockAlign = wfx.nChannels*wfx.wBitsPerSample/8;
138142 wfx.nAvgBytesPerSec = wfx.nSamplesPerSec*wfx.nBlockAlign;
139143 err = waveOutOpen(&wo,WAVE_MAPPER,&wfx,
140− (DWORD)sndbuf_done,(DWORD)ad,
144+ (DWORD_PTR)sndbuf_done,(DWORD_PTR)ad,
141145 CALLBACK_FUNCTION);
142146 if (err != MMSYSERR_NOERROR)
143147 {
src/utils/cst_tokenstream.c+1−1
@@ -266,7 +266,7 @@ static void get_token_sub_part(cst_tokenstream *ts, · 265 unmodified lines
266266 (*buffer)[p] = '\0';
267267 }
268268
269− #ifdef _WIN32
269+ #if defined _WIN32 && !defined(__GNUC__)
270270 __inline int ts_utf8_sequence_length(char c0)
271271 #else
272272 int ts_utf8_sequence_length(char c0)
windows/Makefile+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 ## Also an example command line program ##
4141 ## ##
4242 ## At top level ##
43−## ./configure --target=i386-mingw32 ##
43+## ./configure ##
4444 ## make ##
4545 ## ##
4646 ###########################################################################

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t