Compiling ScummVM/Windows CE

So you want to roll your own binary for the ScummVM Windows CE port?
The first thing to ask yourself is do you really need to compile it?
The official ScummVM for Windows CE binaries are "good enough" for more than the average user.
Also, bear in mind that the compilation procedure is seldom as simple as
unpack-build and that, probably, you'll have to know your way around
makefiles and editing appropriately the source files.
Still reading? Good :-)
Many people are put off by the sheer volume of work which has to take place
in order to get a successful build.
Things are not that bad though as, hopefully, this document tries to describe.
More than often you may find that once you set up you build environment
right, there's only minimal work to be done to build any version of ScummVM for Windows CE.
Alright, ready? Let's go :-)

Version 1.0 and newer use the mingw32ce GCC cross compiler. This is only compiler being supported now. You may succeed in compiling with VS2005, but this is beyond the scope of these instructions.

Why all these compiler changes? There are absolutely critical reasons for switching between them.
For example, the migration from evc to VS is mandatory, as C++ templates introduced
through core code evolution in the trunk of ScummVM
cause the evc compilers to crash with 'Internal compiler error'.
Unfortunately the migration is not completely successful as VS2005 (no service packs) introduces
incorrect optimization in release builds,
leading to workarounds in the source and compilation of specific files with
no optimizations at all.
Also, note that Visual Studio Express (which is free) does
not support Windows CE (at least at the time of writing this).
Further, the change from our semi-custom VLC GCC port to cegcc was mandated because building dlls which are required by the plugins is broken in the former. Finally we have switched to mingw32ce, which does not use the unix compatibility layer which cegcc brings along as we don't need it.

Libraries

ScummVM depends on quite a few external libraries to handle content.
These are:

Arisme and Knakos have done an excellent job in porting all these libraries to Windows CE, along the process of porting ScummVM itself. Lately, this job is being done by CeRiAl.

Furthermore, the libraries need to be patched in order to successfully compile.
The patches are available here and are accumulated.
This means that are direct patches to the original source versions of the libraries,
that they include Arisme's, Knakos' and CeRiAl's patches and are not incremental to them.
A precompiled lib/header pack is available as well and
you can find it right here.

Please note that some of those libraries have been officially ported to WinCE
after the work done by Arisme/Knakos/CeRiAl or, newer versions are available for them.
We generally cannot comment on how well they will work with ScummVM.
The more adventurous of you may want to give them a shot, but we find
that these work well enough for our purposes.

Compiling using the mingw32ce GCC toolchain

First, you need to download and install the mingw32ce cross compiler. More specifically, you need the mingw32ce variety (without the posix layer emulation that is). You may optionally also download a working gdb debugger there for debugging the applications. Version 0.59.1 is the recommended version, your milage may vary with other versions. It's also recommended, though not mandatory, to install the toolchain to /opt/mingw32ce (in the following example we use this directory).

ScummVM

Here is the procedure for building ScummVM:

Build libraries from source

You may skip this step if you downloaded the prebuilt library package.
Download the original library source tarballs.
Download the patches from here and patch the libraries.
Please note that there is no patch available for zlib 1.2.5 as patching it is not needed any more (yay!).
You need to configure and make each library,
except for the SDL and Tremolo libraries which both sport a customly created (and lame :-) )
Makefile.
It should be sufficient to set the PATH to the following to make the toolchain usable:

Please note that it may be needed to change the line "_host_alias=arm-wince-mingw32ce" to "_host_alias=arm-mingw32ce" in the ScummVM configure script if the compiler is not found.
For ScummVM we recommend a so called "out of source tree" build, so change to the ScummVM source directory and create a directory for that and run the configure script as following: