Updates for building on Windows CE using mingw32ce cross compiler: SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Thu, 03 Jan 2008 06:19:07 +0000
branchSDL-1.2
changeset 413431c7c57af8a4
parent 4133 2130d625816f
child 4135 cd98d1dc385c
Updates for building on Windows CE using mingw32ce cross compiler:
http://sourceforge.net/mailarchive/forum.php?thread_name 0703291652.38437.jwalt%40garni.ch&forum_name=cegcc-devel

Hi!

I just managed to compile SDL for Windows CE using the "mingw32ce"
configuration of http://cegcc.sourceforge.net. Test programs work as expected
(except for those using signals -- no POSIX on mingw32ce), and I didn't yet
encounter any problem.

While it was a pain to get everything compiled and running, the changes to
SDL are actually quite small (see attached SDL-ce.diff).

Unfortunately, the win32 headers shipped with cegcc are not 100% correct, and
it feels quite messy to work around them in SDL code, so those headers will
also need to be patched. (Attachment: win32api-ce.diff)

Since I had to apply the libtool patch from the cegcc patch, I have also ad ded
my copy of aclocal.m4 for SDL. I had to modify the cegcc libtool patch to
use "lt_cv_deplibs_check_method=pass_all" for mingw32ce, otherwise libtool
would not recognize the import libraries as valid for dynamic linking.

All these changes should not affect non-WinCE builds, so they could be
included in mainline SDL.

If you need some docs, you can use this description for a cross-compilation
README:

1) get cegcc from http://cegcc.sourceforge.net
2) build and install the "mingw32ce" variant (see cegcc installation docs)
3) patch w32api-headers (if not yet included in cegcc)
4) setup environment (customize the first three lines as you like):
PREFIX=/opt/mingw32ce
TARGET=arm-wince-mingw32ce
BUILD=`uname -m`-pc-linux-gnu
export PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PREFIX/local/bin:$PATH"
export CFLAGS="${CFLAGS:- -O2 -g} -I$PREFIX/local/include"
export CPPFLAGS="${CPPFLAGS:- -O2 -g} -I$PREFIX/local/include"
export CXXFLAGS="${CXXFLAGS:- -O2 -g} -I$PREFIX/local/include"
export LDFLAGS="${LDFLAGS:- -O2 -g} -L$PREFIX/local/lib"
export HOST_CC="gcc"
export CC="$PREFIX/bin/$TARGET-gcc"
export CXX="$PREFIX/bin/$TARGET-g++"
export LD="$PREFIX/bin/$TARGET-ld"
export AS="$PREFIX/bin/$TARGET-as"
export AR="$PREFIX/bin/$TARGET-ar"
export RANLIB="$PREFIX/bin/$TARGET-ranlib"
export CONFIG_SHELL="/bin/sh"
5) build and install
./configure --target=$TARGET --host=$TARGET --build=$BUILD
make
make install
6) use (4) and (5) for any SDL-using software you want to cross-compile
7) copy $PREFIX/local/bin/SDL-1-2-0.dll into your executable directory on the WinCE machine
build-scripts/config.sub
configure.in
src/video/gapi/SDL_gapivideo.c
src/video/gapi/SDL_gapivideo.h
src/video/windib/SDL_dibvideo.c
     1.1 --- a/build-scripts/config.sub	Thu Jan 03 06:06:06 2008 +0000
     1.2 +++ b/build-scripts/config.sub	Thu Jan 03 06:19:07 2008 +0000
     1.3 @@ -1296,6 +1296,9 @@
     1.4          -os400*)
     1.5  		os=-os400
     1.6  		;;
     1.7 +	-cegcc*)
     1.8 +		os=-cegcc
     1.9 +		;;
    1.10  	-wince*)
    1.11  		os=-wince
    1.12  		;;
     2.1 --- a/configure.in	Thu Jan 03 06:06:06 2008 +0000
     2.2 +++ b/configure.in	Thu Jan 03 06:19:07 2008 +0000
     2.3 @@ -2456,6 +2456,49 @@
     2.4          SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
     2.5          SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
     2.6          ;;
     2.7 +    *-wince*)
     2.8 +        ARCH=win32
     2.9 +        CheckDummyVideo
    2.10 +        CheckDiskAudio
    2.11 +        CheckDummyAudio
    2.12 +        CheckWIN32
    2.13 +        CheckNASM
    2.14 +        SOURCES="$SOURCES $srcdir/src/video/gapi/*.c"
    2.15 +        EXTRA_CFLAGS="$EXTRA_CFLAGS -D_WIN32_WCE=0x420"
    2.16 +        if test x$enable_audio = xyes; then
    2.17 +            AC_DEFINE(SDL_AUDIO_DRIVER_WAVEOUT)
    2.18 +            SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
    2.19 +            have_audio=yes
    2.20 +        fi
    2.21 +        # Set up files for the thread library
    2.22 +        if test x$enable_threads = xyes; then
    2.23 +            AC_DEFINE(SDL_THREAD_WIN32)
    2.24 +            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_sysmutex.c"
    2.25 +            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_syssem.c"
    2.26 +            SOURCES="$SOURCES $srcdir/src/thread/win32/SDL_systhread.c"
    2.27 +            SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
    2.28 +            have_threads=yes
    2.29 +        fi
    2.30 +        # Set up files for the timer library
    2.31 +        if test x$enable_timers = xyes; then
    2.32 +            AC_DEFINE(SDL_TIMER_WINCE)
    2.33 +            SOURCES="$SOURCES $srcdir/src/timer/wince/*.c"
    2.34 +            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lmmtimer"
    2.35 +            have_timers=yes
    2.36 +        fi
    2.37 +        # Set up files for the shared object loading library
    2.38 +        if test x$enable_loadso = xyes; then
    2.39 +            AC_DEFINE(SDL_LOADSO_WIN32)
    2.40 +            SOURCES="$SOURCES $srcdir/src/loadso/win32/*.c"
    2.41 +            have_loadso=yes
    2.42 +        fi
    2.43 +        # Set up the system libraries we need
    2.44 +        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lcoredll -lcommctrl"
    2.45 +        # The Win32 platform requires special setup
    2.46 +        SDLMAIN_SOURCES="$srcdir/src/main/win32/*.c"
    2.47 +        SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main -D_WIN32_WCE=0x420"
    2.48 +        SDL_LIBS="-lSDLmain $SDL_LIBS"
    2.49 +        ;;
    2.50      *-*-beos*)
    2.51          ARCH=beos
    2.52          ac_default_prefix=/boot/develop/tools/gnupro
     3.1 --- a/src/video/gapi/SDL_gapivideo.c	Thu Jan 03 06:06:06 2008 +0000
     3.2 +++ b/src/video/gapi/SDL_gapivideo.c	Thu Jan 03 06:19:07 2008 +0000
     3.3 @@ -71,6 +71,14 @@
     3.4  #pragma message("Warning: Using GapiEmu in release build. I assume you'd like to set USE_GAPI_EMU to zero.")
     3.5  #endif
     3.6  
     3.7 +#ifndef _T
     3.8 +#define _T(x) L##x
     3.9 +#endif
    3.10 +
    3.11 +#ifndef ASSERT
    3.12 +#define ASSERT(x)
    3.13 +#endif
    3.14 +
    3.15  // defined and used in SDL_sysevents.c
    3.16  extern HINSTANCE aygshell;
    3.17  extern void SDL_UnregisterApp();
     4.1 --- a/src/video/gapi/SDL_gapivideo.h	Thu Jan 03 06:06:06 2008 +0000
     4.2 +++ b/src/video/gapi/SDL_gapivideo.h	Thu Jan 03 06:19:07 2008 +0000
     4.3 @@ -132,13 +132,13 @@
     4.4  #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
     4.5      int SDL_nummodes[NUM_MODELISTS];
     4.6      SDL_Rect **SDL_modelist[NUM_MODELISTS];
     4.7 -	enum SDL_ScreenOrientation userOrientation;
     4.8 +	SDL_ScreenOrientation userOrientation;
     4.9  	int invert;
    4.10  	char hiresFix; // using hires mode without defining hires resource
    4.11  // --------------
    4.12  	int useGXOpenDisplay; /* use GXOpenDispplay */
    4.13      int w, h;
    4.14 -	enum SDL_ScreenOrientation gapiOrientation;
    4.15 +	SDL_ScreenOrientation gapiOrientation;
    4.16  
    4.17      void *buffer; // may be 8, 16, 24, 32 bpp
    4.18  	PIXEL *videoMem;
    4.19 @@ -146,7 +146,7 @@
    4.20  	struct GXKeyList keyList;
    4.21  	struct GapiFunc gxFunc;
    4.22  	struct GXDisplayProperties gxProperties;
    4.23 -	enum GAPIVideoMode videoMode;
    4.24 +	GAPIVideoMode videoMode;
    4.25  	int colorscale;
    4.26  	int dstLineStep;  // in bytes
    4.27  	int dstPixelStep; // in bytes
     5.1 --- a/src/video/windib/SDL_dibvideo.c	Thu Jan 03 06:06:06 2008 +0000
     5.2 +++ b/src/video/windib/SDL_dibvideo.c	Thu Jan 03 06:19:07 2008 +0000
     5.3 @@ -41,6 +41,26 @@
     5.4  #include "../wincommon/SDL_wingl_c.h"
     5.5  
     5.6  #ifdef _WIN32_WCE
     5.7 +
     5.8 +#ifndef DM_DISPLAYORIENTATION
     5.9 +#define DM_DISPLAYORIENTATION 0x00800000L
    5.10 +#endif
    5.11 +#ifndef DM_DISPLAYQUERYORIENTATION 
    5.12 +#define DM_DISPLAYQUERYORIENTATION 0x01000000L
    5.13 +#endif
    5.14 +#ifndef DMDO_0
    5.15 +#define DMDO_0      0
    5.16 +#endif
    5.17 +#ifndef DMDO_90
    5.18 +#define DMDO_90     1
    5.19 +#endif
    5.20 +#ifndef DMDO_180
    5.21 +#define DMDO_180    2
    5.22 +#endif
    5.23 +#ifndef DMDO_270
    5.24 +#define DMDO_270    4
    5.25 +#endif
    5.26 +
    5.27  #define NO_GETDIBITS
    5.28  #define NO_GAMMA_SUPPORT
    5.29    #if _WIN32_WCE < 420