Difference between revisions of "Windows CE build instructions"

From Ultronomicon
Jump to navigation Jump to search
Line 272: Line 272:
 
Example shortcut file:
 
Example shortcut file:
 
  21#"\SD Card\uqm\uqm" -l uqm_log.txt
 
  21#"\SD Card\uqm\uqm" -l uqm_log.txt
 +
 +
== Notes ==
 +
* Netplay is not yet supported
 +
* OpenGL is not yet supported
  
 
== Gotchas ==
 
== Gotchas ==

Revision as of 17:48, 24 December 2007

The Ur-Quan Masters running on Dell Axim x51v

Set up environment variables

export CROSS_ROOT=/opt/cegcc
export PRJ=$HOME/wince
export PATH=$CROSS_ROOT/bin:$PRJ/bin:/bin:/usr/bin

Create workspace directories

mkdir $PRJ
mkdir $PRJ/lib
mkdir $PRJ/pkg
mkdir $PRJ/bin

Install cegcc

  • Version 0.50 of cegcc was used. Several patches were submitted to cegcc team and the patches were committed to svn. If using version other than 0.50, ensure that the patches are there.
  • Download mandriva-cegcc-cegcc-0.50.tar.gz from http://cegcc.sourceforge.net/
  • Uncompress mandriva-cegcc-cegcc-0.50.tar.gz to /

Apply cegcc patches

  • Apply the followign to /opt/cegcc/arm-wince-cegcc/include/w32api/winuser.h:
Index: winuser.h
===================================================================
--- winuser.h   (revision 1066)
+++ winuser.h   (revision 1094)
@@ -1962,6 +1962,12 @@
 #endif
 #define VK_OEM_2       0xBF
 #define VK_OEM_3       0xC0
+#define VK_APP1        0xC1
+#define VK_APP2        0xC2
+#define VK_APP3        0xC3
+#define VK_APP4        0xC4
+#define VK_APP5        0xC5
+#define VK_APP6        0xC6
 #define VK_OEM_4       0xDB
 #define VK_OEM_5       0xDC
 #define VK_OEM_6       0xDD
  • Apply the following to /opt/cegcc/arm-wince-cegcc/include/sys/dirent.h
Index: sys/dirent.h
===================================================================
--- sys/dirent.h        (revision 80)
+++ sys/dirent.h        (revision 1100)
@@ -36,6 +36,8 @@
 extern void rewinddir(DIR *dir);
 extern int  closedir(DIR *dir);

+extern int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
+
 #ifdef __cplusplus
 };
 #endif

Create cegcc symlinks

Create symbolic links to cegcc binaries. There are ways to avoid this step, and given more time it should be retired, but for now:

cd /opt/cegcc/bin
ls arm-wince-cegcc-* | while read line; do
    new_name=`echo $line | sed "s/arm-wince-cegcc-//g"`
    ln -s $line $new_name
    ln -s $line arm-wince-pe-$new_name
done

Build required libraries

SDL

cd $PRJ/pkg
wget http://www.libsdl.org/release/SDL-1.2.12.tar.gz
cd $PRJ
tar xvf pkg/SDL-1.2.12.tar.gz
  • Build SDL.dll using Visual Studio on win32 (having trouble cross-compiling in linux, hopefully will resolve shortly)...
  • Place SDL.dll that was built using Visual Studio to $PRJ/lib
  • Create $PRJ/bin/sdl-config:
#!/bin/sh
if [ "$1" = "--version" ]; then
	echo "1.2.12"
elif [ "$1" = "--cflags" ]; then
	echo "-I${PRJ}/SDL-1.2.12/include"
elif [ "$1" = "--libs" ]; then
	echo "-L${PRJ}/lib -lSDL"
else
	exit 1
fi
exit 0

Patch headers

--- orig/SDL-1.2.12/include/SDL_config_minimal.h        2007-07-20 01:52:44.000000000 -0400
+++ wince/SDL-1.2.12/include/SDL_config_minimal.h       2007-12-24 11:50:58.000000000 -0500
@@ -36,7 +36,9 @@
 typedef signed int int32_t;
 typedef unsigned int uint32_t;
 typedef unsigned int size_t;
+#ifndef __CEGCC__
 typedef unsigned long uintptr_t;
+#endif
 
 /* Enable the dummy audio driver (src/audio/dummy/\*.c) */
 #define SDL_AUDIO_DRIVER_DUMMY 1
--- orig/SDL-1.2.12/./include/SDL_keysym.h      2007-07-20 01:52:44.000000000 -0400
+++ wince/SDL-1.2.12/./include/SDL_keysym.h     2007-12-23 20:16:11.000000000 -0500
@@ -282,6 +282,12 @@
        SDLK_UNDO               = 322,          /* Atari keyboard has Undo */
 
        /* Add any other keys here */
+       SDLK_APP1               = 323,
+       SDLK_APP2               = 324,
+       SDLK_APP3               = 325,
+       SDLK_APP4               = 326,
+       SDLK_APP5               = 327,
+       SDLK_APP6               = 328,
 
        SDLK_LAST
 } SDLKey;
--- orig/SDL-1.2.12/include/SDL_stdinc.h        2007-07-20 01:52:44.000000000 -0400
+++ wince/SDL-1.2.12/include/SDL_stdinc.h       2007-12-24 11:53:11.000000000 -0500
@@ -57,13 +57,15 @@
 # endif
 # include <string.h>
 #endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
-#elif defined(HAVE_STDINT_H)
-# include <stdint.h>
+#ifndef __CEGCC__
+# ifdef HAVE_STRINGS_H
+#  include <strings.h>
+# endif
+# if defined(HAVE_INTTYPES_H)
+#  include <inttypes.h>
+# elif defined(HAVE_STDINT_H)
+#  include <stdint.h>
+# endif
 #endif
 #ifdef HAVE_CTYPE_H
 # include <ctype.h>
--- sdlorig/SDL-1.2.12/./src/video/windib/SDL_dibevents.c       2007-07-20 01:52:19.000000000 -0400
+++ wince/SDL-1.2.12/./src/video/windib/SDL_dibevents.c 2007-12-23 20:14:55.000000000 -0500
@@ -430,6 +430,13 @@
        VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
        VK_keymap[VK_CANCEL] = SDLK_BREAK;
        VK_keymap[VK_APPS] = SDLK_MENU;
+
+       VK_keymap[VK_APP1] = SDLK_APP1;
+       VK_keymap[VK_APP2] = SDLK_APP2;
+       VK_keymap[VK_APP3] = SDLK_APP3;
+       VK_keymap[VK_APP4] = SDLK_APP4;
+       VK_keymap[VK_APP5] = SDLK_APP5;
+       VK_keymap[VK_APP6] = SDLK_APP6;
 }

Tremor

cd $PRJ
svn co -r14321 http://svn.xiph.org/branches/lowmem-branch/Tremor
ln -s Tremor tremor
cd Tremor
./autogen.sh --host arm-wince-pe
./configure --host arm-wince-pe
./make
arm-wince-cegcc-gcc -shared *.o -o libvorbisidec.dll
cp libvorbisidec.dll $PRJ/lib

zlib

cd $PRJ/pkg
wget http://www.zlib.net/zlib-1.2.3.tar.gz
cd $PRJ
tar xvf zlib-1.2.3.tar.gz
cd $PRJ/zlib-1.2.3
export CC=arm-wince-cegcc-gcc
./configure
./make
arm-wince-cegcc-gcc -shared adler32.o compress.o crc32.o deflate.o gzio.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o -o z.dll
cp z.dll $PRJ/lib
cd $PRJ/lib
ln -s z.dll zdll.dll

libpng

cd $PRJ/pkg
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.24.tar.bz2
cd $PRJ
tar xvf libpng-1.2.24.tar.bz2
cd $PRJ/libpng-1.2.24
export CFLAGS=-I$PRJ/zlib-1.2.3
export LDFLAGS="-L$PRJ/lib"
./configure --host arm-wince-pe
./make
arm-wince-cegcc-gcc -shared libpng12*.o -L$PRJ/lib -lz -o libpng.dll
cp libpng.dll $PRJ/pkg

SDL_image

cd $PRJ/pkg
wget http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.6.tar.gz
cd $PRJ
tar xvf pkg/SDL_image-1.2.6.tar.gz
cd $PRJ/SDL_image-1.2.6
export CFLAGS="-I$PRJ/SDL-1.2.12/include -I$PRJ/libpng-1.2.24 -I$PRJ/zlib-1.2.3"
export LDFLAGS="-L$PRJ/lib -lpng"
./configure --enable-shared=yes --host arm-wince-pe
./make
gcc -shared IMG*.o -L$PRJ/lib -lSDL -lpng -o SDL_image.dll
cp SDL_image.dll $PRJ/lib

Check out The Ur-Quan Masters sources

cd $PRJ
svn co -N https://sc2.svn.sourceforge.net/svnroot/sc2/trunk/sc2
cd sc2
svn up build doc src

Note: trunk is used in this example. Use whatever tag is appropriate.

Configure The Ur-Quan Masters build scripts

To configure The Ur-Quan Masters the following needs to be performed:

export BUILD_HOST=CEGCC
unset ENV BASH_ENV
export CFLAGS="-I$PRJ/libvorbis-1.2.0/include -I$PRJ/libogg-1.1.3/include -I$PRJ/zlib-1.2.3 -I$PRJ/SDL-1.2.12/include -I$PRJ/zlib-1.2.3 -I$PRJ/SDL_image-1.2.6 -UUNICODE -I$PRJ -D_SYS_TYPES_FD_SET -DHAVE_STRING_H -D_WIN32_WCE"
export LDFLAGS="-L$PRJ/zlib-1.2.3 -L$PRJ/lib -L$PRJ/libogg-1.1.3/src/.libs -L$PRJ/libvorbis-1.2.0/lib/.libs -laygshell"
export MAKE_VERBOSE=1
./build.sh uqm config

Run ./build.sh uqm config and set options to the following:

 1. Type of build                        Optimised release build
 2. OpenGL graphics support              Don't include OpenGL graphics support
 3. Sound backend                        Use MixSDL for sound (internal)
 4. Tracker music support                Included libmikmod
 5. Ogg Vorbis codec                     Tremor (avoids floating point math)
 6. Network Supermelee support           disabled
 7. Joystick support                     disabled
 8. Supported file i/o methods           Direct & .zip file i/o
 9. Graphics/Sound optimizations         Platform acceleration (asm, etc.)

Build The Ur-Quan Masters

Run ./build.sh uqm

Installing to WM device

For the purposes of this guide, $UQM_DIR denotes the directory where you want to install UQM (for example "/SD Card/uqm")

  1. Create the following directories:
    • $UQM_DIR/
    • $UQM_DIR/content/
    • $UQM_DIR/content/packages
  2. Place "uqm" executable into $UQM_DIR
  3. Place shared libraries into $UQM_DIR:
    • $PRJ/libpng.dll
    • $PRJ/libvorbisidec.dll
    • $PRJ/SDL.dll
    • $PRJ/SDL_image.dll
    • $PRJ/z.dll
    • /opt/cegcc/arm-wince-cegcc/lib/device/cegcc.dll
  4. Place "version" file into $UQM_DIR/content
  5. Place main content file (for example uqm-0.6.0-content.uqm) into $UQM_DIR/content/packages
  6. Place any content patches / addon files into $UQM_DIR/content/packages
  7. Place wince addon file (for example uqm-0.6.0-~~wince_20071223.2200.zip) into $UQM_dir/content/packages

Adding The Ur-Quan Masters command-line arguments

  1. In WM5 file explorer, press on "uqm" and hold until pop-up menu appears.
  2. Select "Copy" menu item
  3. Press and hold in the file explorer window until pop-up menu appears.
  4. Select "Paste Shortcut" menu item
  5. Rename the newly created shortcut to "uqm_shortcut"
  6. Open "uqm_shortcut.lnk" in a text editor of choice and add command line arguments

Example shortcut file:

21#"\SD Card\uqm\uqm" -l uqm_log.txt

Notes

  • Netplay is not yet supported
  • OpenGL is not yet supported

Gotchas

Headers

Always use same header files to build everything, doing otherwise brings chaos and is extremely difficult to debug

Missing DLLs

The following message usually means that your executable is unable to find a .dll:

The file 'uqm' cannot be opened. Either it is not sighed with a trusted certificate, or one of its components cannot be found. You might need to reinstall or restore this file.

To find out what dlls you are missing, run "arm-wince-gcc-objdump -p uqm" (or any of it's libraries)