Difference between revisions of "Compiling ScummVM/Wii"

From ScummVM :: Wiki
Jump to navigation Jump to search
m
(then again, this isn't really required)
 
(7 intermediate revisions by the same user not shown)
Line 2: Line 2:


This page describes how you build a Wii or Gamecube binary from the ScummVM source tree.
This page describes how you build a Wii or Gamecube binary from the ScummVM source tree.
First, you have to choose how to obtain the sources:
* a downloaded [http://scummvm.org/downloads.php#source sources archive]
* a [https://sourceforge.net/svn/?group_id=37116 SVN] checkout (latest is ''trunk'')


Required tools and/or libraries might change at times, and differences for various ScummVM versions are pointed out when necessary.
Required tools and/or libraries might change at times, and differences for various ScummVM versions are pointed out when necessary.
Line 14: Line 10:
* libogc and libfat
* libogc and libfat


The latter two libraries are part of devkitPPC and are already installed with it. However, official ScummVM Wii and Gamecube binaries use unofficial versions, available via [http://git.or.cz/ git] [http://git.hackmii.com/ here].
The latter two libraries are part of devkitPPC and are already installed with it. However, official ScummVM Wii and Gamecube binaries use unofficial versions, available via [http://git.or.cz/ git] [http://repo.or.cz/w/libogc.git here] and [http://repo.or.cz/w/libfat.git here].
 
Reasons:
 
* libogc's <tt>malloc()</tt> has been [http://git.hackmii.com/git.php?tag=ce9b85c1fa659d39ac26b72b82e31844c50bfdf6&p=libogc.git&a=commitdiff&h=ce9b85c1fa659d39ac26b72b82e31844c50bfdf6&hb=28e632dab2820a98ea3399e3090761581f034df7&tm=1366734 modfied] to utilize [http://wiibrew.org/wiki/Memory_Map MEM2]. Without this patch, a single binary with all game engines won't be able to run all games (like COMI) due to memory limits
* libfat gained a read-ahead cache, without it video sequences will stutter
 
If you're going to use the git repository, use my branches (''origin/dhewg'') for now, that's what i'm using.
 
Nevertheless, ScummVM should build just fine with either versions.


== Versions differences ==
== Versions differences ==


* v0.12.0 (first official version) is built with devkitPPC r15
* v0.12.0 (first official version) is built with devkitPPC r15
* ''trunk'' (and eventually v0.13.0) changed to devkitPPC r16
* starting with v0.13.0, devkitPPC r16 is used
* starting with revision 44189, [http://repo.or.cz/w/libgxflux.git libgxflux] in mandatory


= Optional libraries =
= Optional libraries =
Line 76: Line 64:
=== Tremor ===
=== Tremor ===


Get a SVN checkout (rev 15592 as of this writing):
Get a SVN checkout (r16259 as of this writing):


  svn co http://svn.xiph.org/branches/lowmem-branch/Tremor
  svn co http://svn.xiph.org/trunk/Tremor


patch it:
patch it:
Line 88: Line 76:
   #include <sys/types.h>
   #include <sys/types.h>
   
   
  -#if 0
  -#if BYTE_ORDER==LITTLE_ENDIAN
  +#if BYTE_ORDER==LITTLE_ENDIAN
  +#if 0
   union magic {
   union magic {
     struct {
     struct {
Line 97: Line 85:
   #endif
   #endif
   
   
  -#if 1
  -#if BYTE_ORDER==BIG_ENDIAN
  +#if BYTE_ORDER==BIG_ENDIAN
  +#if 1
   union magic {
   union magic {
     struct {
     struct {
Line 153: Line 141:
= Compiling =
= Compiling =


This port doesn't utilize ScummVM's <tt>configure</tt> system, instead it comes with a simple Makefile. The port code can be found in two directories:
== 1.0.0 and greater ==
 
The Wii and Gamecube port can be compiled with the <tt>configure</tt> script. The most basic way to accomplish this is to run:
 
./configure --host=wii
make
 
If you want to build a Gamecube binary, just use
 
./configure --host=gamecube
make
 
instead.
 
The script supports various arguments, which you can use to en- or disable features, see <tt>./configure --help</tt>.
 
Two of the [[#Optional libraries|optional libraries]] are already part of libogc:
* zlib, used to (de-)compress save games. It gets automatically detected with a recent libogc version.
* libmad, used for MP3 playback. It gets automatically detected with a recent libogc version.
 
Others are not, and if you want support for it, you need cross-compiled binaries:
* libFLAC, used for FLAC lossless audio playback. Use the ''--with-flac-prefix=<directory>'' argument.
* Tremor, used for OGG audio playback.  Use the ''--with-tremor-prefix=<directory>'' argument.
 
If you followed the [[#Optional libraries|above description]] and have those libraries in <tt>$DEVKITPRO/3rd/wii</tt>, the <tt>configure</tt> command line would look like this:
 
./configure --host=wii --with-flac-prefix=$DEVKITPRO/3rd/wii --with-tremor-prefix=$DEVKITPRO/3rd/wii
 
Additionally, there're a few make targets for your convenience:
 
* <tt>make wiiload</tt> - uploads a compiled Wii binary over TCP/IP.
* <tt>make geckoupload</tt> - uploads a compiled binary over a USBGecko device.
* <tt>make wiidist</tt> - copies all required files for the Wii into the ''dist'' subdirectory, read to copy onto your SD card for the Homebrew Channel.
* <tt>make gcdist</tt> - same for Gamecube.
* <tt>make wiigdb</tt> - starts GDB and loads your compiled binary, ready to debug.
* <tt>make wiidebug</tt> - starts GDB with your binary and attaches remotely to the Wii via a USBGecko device.
 
== v0.13.x and below ==
 
This port doesn't utilize ScummVM's <tt>configure</tt> system for v0.12.0, instead it comes with a simple Makefile. The port code can be found in two directories:


  ./backends/fs/wii/
  ./backends/fs/wii/
Line 163: Line 190:


* There is no support for dynamic libraries on the Wii or Gamecube, keep an engine toggle at <tt>STATIC_PLUGIN</tt> or disable it by just commenting that line
* There is no support for dynamic libraries on the Wii or Gamecube, keep an engine toggle at <tt>STATIC_PLUGIN</tt> or disable it by just commenting that line
* Vanilla scalers do not work, the code is i386 only
* Vanilla scalers are not supported by the Wii port
* [http://www.zlib.net/ zlib] and [http://www.underbit.com/products/mad/ MAD] are part of libogc
* [http://www.zlib.net/ zlib] and [http://www.underbit.com/products/mad/ MAD] are part of libogc
* MPEG2 support has been dropped from the Wii port, if you want support for it, you have to cross compile [http://libmpeg2.sourceforge.net/ libmpeg2]
* MPEG2 support has been dropped from the Wii port, if you want support for it, you have to cross compile [http://libmpeg2.sourceforge.net/ libmpeg2]

Latest revision as of 19:40, 18 February 2011

Compiling ScummVM for Wii or Gamecube

This page describes how you build a Wii or Gamecube binary from the ScummVM source tree.

Required tools and/or libraries might change at times, and differences for various ScummVM versions are pointed out when necessary.

Mandatory tools and libraries

  • devkitPPC as a build environment, please refer to its documentation how to set it up
  • libogc and libfat

The latter two libraries are part of devkitPPC and are already installed with it. However, official ScummVM Wii and Gamecube binaries use unofficial versions, available via git here and here.

Versions differences

  • v0.12.0 (first official version) is built with devkitPPC r15
  • starting with v0.13.0, devkitPPC r16 is used
  • starting with revision 44189, libgxflux in mandatory

Optional libraries

  • Tremor (lowmem branch) to play .ogg audio files
  • FLAC to play lossless .flac files

Again, you have two options:

Precompiled binaries

Get this archive and extract it in $DEVKITPRO/3rd/ you just created. The directory structure should look like

$DEVKITPRO/3rd/wii/include
$DEVKITPRO/3rd/wii/lib

and so on. The binaries will work on Wii and Gamecube.

Build the libraries yourself

These steps require some patching and fiddling with the required autotools and problems may arise (depending on your OS). Works for me (tm), good luck :P

Here's a a simple script to set up a shell for crosscompiling:

#!/bin/sh

PREFIX=${DEVKITPPC}/bin/powerpc-gekko-
export CC=${PREFIX}gcc
export CXX=${PREFIX}g++
export AS=${PREFIX}gcc
export LD=${PREFIX}gcc
export AR=${PREFIX}ar cru
export RANLIB=${PREFIX}ranlib
export STRIP=${PREFIX}strip
export OBJCOPY=${PREFIX}objcopy
export MACHDEP="-g -Os -Wall -DGEKKO -mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections -fmodulo-sched"
export CFLAGS="${MACHDEP}"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="${MACHDEP}"

echo "./configure --host=ppc --disable-shared --prefix=${DEVKITPRO}/3rd/wii"

Save it to a file (like gekkoenv.sh) and run

. ./gekkoenv.sh

in your shell. Build systems should now use the correct tools.

Tremor

Get a SVN checkout (r16259 as of this writing):

svn co http://svn.xiph.org/trunk/Tremor

patch it:

--- Tremor-vanilla/misc.h   2008-12-20 17:09:56.000000000 +0100
+++ Tremor/misc.h       2008-12-23 22:44:58.000000000 +0100
@@ -48,7 +48,7 @@

 #include <sys/types.h>

-#if BYTE_ORDER==LITTLE_ENDIAN
+#if 0
 union magic {
   struct {
     ogg_int32_t lo;
@@ -58,7 +58,7 @@
 };
 #endif

-#if BYTE_ORDER==BIG_ENDIAN
+#if 1
 union magic {
   struct {
     ogg_int32_t hi;

configure it:

./autogen.sh --host=ppc --disable-shared --prefix=${DEVKITPRO}/3rd/wii --enable-low-accuracy

and finally build & install it:

make
make install

FLAC

Get a tarball of the latest stable version here (v1.2.1 as of this writing), extract it, patch it:

diff -ur flac-1.2.1-vanilla/src/libFLAC/bitreader.c flac-1.2.1/src/libFLAC/bitreader.c
--- flac-1.2.1-vanilla/src/libFLAC/bitreader.c  2007-09-11 06:48:55.000000000 +0200
+++ flac-1.2.1/src/libFLAC/bitreader.c  2008-12-23 23:14:00.000000000 +0100
@@ -42,7 +42,7 @@
 #elif defined __MINGW32__
 #include <winsock.h> /* for ntohl() */
 #else
-#include <netinet/in.h> /* for ntohl() */
+//#include <netinet/in.h> /* for ntohl() */
 #endif
 #include "private/bitmath.h"
 #include "private/bitreader.h"
diff -ur flac-1.2.1-vanilla/src/libFLAC/bitwriter.c flac-1.2.1/src/libFLAC/bitwriter.c
--- flac-1.2.1-vanilla/src/libFLAC/bitwriter.c  2007-09-11 01:08:38.000000000 +0200
+++ flac-1.2.1/src/libFLAC/bitwriter.c  2008-12-23 23:13:59.000000000 +0100
@@ -42,7 +42,7 @@
 #elif defined __MINGW32__
 #include <winsock.h> /* for ntohl() */
 #else
-#include <netinet/in.h> /* for ntohl() */
+//#include <netinet/in.h> /* for ntohl() */
 #endif
 #if 0 /* UNUSED */
 #include "private/bitmath.h"

configure it:

./configure --host=ppc --disable-shared --prefix=${DEVKITPRO}/3rd/wii --disable-doxygen-docs --disable-xmms-plugin --disable-ogg --disable-oggtest --disable-rpath

and build & install the required parts:

make -C src/libFLAC
make -C src/libFLAC install
make -C include install

Compiling

1.0.0 and greater

The Wii and Gamecube port can be compiled with the configure script. The most basic way to accomplish this is to run:

./configure --host=wii
make

If you want to build a Gamecube binary, just use

./configure --host=gamecube
make

instead.

The script supports various arguments, which you can use to en- or disable features, see ./configure --help.

Two of the optional libraries are already part of libogc:

  • zlib, used to (de-)compress save games. It gets automatically detected with a recent libogc version.
  • libmad, used for MP3 playback. It gets automatically detected with a recent libogc version.

Others are not, and if you want support for it, you need cross-compiled binaries:

  • libFLAC, used for FLAC lossless audio playback. Use the --with-flac-prefix=<directory> argument.
  • Tremor, used for OGG audio playback. Use the --with-tremor-prefix=<directory> argument.

If you followed the above description and have those libraries in $DEVKITPRO/3rd/wii, the configure command line would look like this:

./configure --host=wii --with-flac-prefix=$DEVKITPRO/3rd/wii --with-tremor-prefix=$DEVKITPRO/3rd/wii

Additionally, there're a few make targets for your convenience:

  • make wiiload - uploads a compiled Wii binary over TCP/IP.
  • make geckoupload - uploads a compiled binary over a USBGecko device.
  • make wiidist - copies all required files for the Wii into the dist subdirectory, read to copy onto your SD card for the Homebrew Channel.
  • make gcdist - same for Gamecube.
  • make wiigdb - starts GDB and loads your compiled binary, ready to debug.
  • make wiidebug - starts GDB with your binary and attaches remotely to the Wii via a USBGecko device.

v0.13.x and below

This port doesn't utilize ScummVM's configure system for v0.12.0, instead it comes with a simple Makefile. The port code can be found in two directories:

./backends/fs/wii/
./backends/platform/wii/

The former is a unified filesystem interface for ScummVM, the more interesting code is in the latter.

Change your working directory to the latter and open the Makefile in a editor. You'll find some variables on top of that file, adjust those to your liking. Everything should be self-explanatory, some are even documented. Here are some random hints:

  • There is no support for dynamic libraries on the Wii or Gamecube, keep an engine toggle at STATIC_PLUGIN or disable it by just commenting that line
  • Vanilla scalers are not supported by the Wii port
  • zlib and MAD are part of libogc
  • MPEG2 support has been dropped from the Wii port, if you want support for it, you have to cross compile libmpeg2

When you're done with the Makefile, save it and run make (GNU version). That's it, the build system is now building an .elf and a .dol.

Test the .dol by uploading it using wiiload via:

make upload

If you want to copy your compiled binary to SD, use the command

make dist

which generates the folder dist with all the required files to run it.