Difference between revisions of "Compiling ScummVM/iPhone"

From ScummVM :: Wiki
Jump to navigation Jump to search
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This page explains how to compile your own version of [[ScummVM]] using the [[iPhone]] backend.
This page explains how to compile your own version of [[ScummVM]] using the [[iPhone]] backend.


= Using XCode =


== Setup ==
'''TODO:''' Describe how to use XCode and create_project to compile for iOS using the official Apple toolchain.


=== Toolchain ===
= Cross-Compilation =
First, you'll need to set up the [http://code.google.com/p/iphone-dev/ toolchain]. We recommend 0.3 (which is the newest version at time of writing), any other and you might have to do some manual modifications to the build process.


Important: If you want to compile the ARM ASM optimizations for SMUSH and sound (and otherwise you'll have to manually change the configure script to remove them), you'll have to apply a patch to the toolchain before compiling/installing it (so it can handle our asm files).
Please note binaries generated with these instructions only work with jailbroken devices.


Download the patch [http://worldsmainorganization.org/scummvm/index.php?dir=iphone%2F&download=iphone-toolkit-scummvm-1.patch here].
== Toolchain Setup ==


Apply it in the iphone-dev directory like so:
=== Toolchain ===
patch -p0 < iphone-toolkit-scummvm-1.patch


This simply allows ".ifdef" statements to appear in the assembly source files, and won't affect the toolchain in any other way (the .ifdef will automatically evaluate to false at the moment).
First you need to set up a toolchain for cross-compilation. On our buildbot we use [https://github.com/lordhoto/ios-toolchain this toolchain]. It is based on LLVM/Clang and contains instructions on how to set it up.


=== External libs ===
=== External libs ===
Then, set up any of the external libs you might want. Meaning libMAD for MP3 playback, libFLAC for FLAC support and/or Tremor for Ogg support. You can add mpeg2dec as well, but it's only used for MPEG2 BS1/2 cutscene support and you really should be using the DXA versions instead (can be downloaded from [http://scummvm.org/downloads.php ScummVM's download page].


Note that you only need to add these if you need support for those filetypes, ScummVM will run fine without them.
In the previously linked toolchain a script to compile all libraries used by the iOS version of ScummVM is contained. Please refer to the toolchain's README file on how to build them.
 
== Building ScummVM ==
 
=== Configuration ===


The below script is what I use to configure these libraries:
Before we can compile ScummVM we need to configure the source tree for building. This is usually only required once or when you want to alter build options.


#!/bin/bash
==== Choosing an iOS target ====
export CC='/usr/local/bin/arm-apple-darwin-gcc -v'
export CXX='/usr/local/bin/arm-apple-darwin-g++'
export LD=$CC
export LDFLAGS="-L/usr/local/arm-apple-darwin/lib/ -Wl,-lstdc++,-lgcc_s.1"
./configure --host=arm-darwin --prefix=/usr/local/arm-apple-darwin/


After that, 'make' and 'make install' should do the trick.
We feature two different iOS backends:
* ''iphone'': Our legacy iOS backend, which supports all iOS3+ devices.
* ''ios7'': Our modern iOS7+ backend, which only supports iOS7+ devices but features better integration for these.


=== ScummVM ===
Depending on which backend you use you will need to use a different value for the ''TARGET'' environment variable.


Then, we need to configure ScummVM itself.
* For ''iphone'' use:
<source lang="bash">
export TARGET=arm-apple-darwin9
</source>


Below is the script I use for this:
* For ''ios7'' use:
#!/bin/bash
<source lang="bash">
export CC='/usr/local/bin/arm-apple-darwin-gcc -v'
export TARGET=arm-apple-darwin11
export CXX='/usr/local/bin/arm-apple-darwin-g++'
</source>
export LD=$CC
export LDFLAGS="-L/usr/local/arm-apple-darwin/lib/ -Wl,-lstdc++,-lgcc_s.1"
export CXXFLAGS="-Wl,-lstdc++,-lgcc_s.1 -I/usr/local/arm-apple-darwin/include/"
export OBJCFLAGS="-I/usr/local/arm-apple-darwin/include/"
./configure --host=iphone --disable-mt32emu --disable-scalers  --enable-release --with-flac-prefix=/usr/local/arm-apple-darwin/


Note that the --with-flac-prefix is only necessary if you want to include FLAC support.
==== Setting up the Environment ====


If you've installed the external libs in any other place than /usr/local/arm-apple/darwin, you need to tell ScummVM where to find them at this point as well (additional flags to ./configure).
<source lang="bash">
export PATH="$IOS_TOOLCHAIN_BASE/bin:$IOS_TOOLCHAIN_BASE/$TARGET/bin:$IOS_TOOLCHAIN_BASE/$TARGET/usr/bin:$PATH"
export CPPFLAGS="-isystem $IOS_TOOLCHAIN_BASE/$TARGET/usr/include"
export LDFLAGS="-L$IOS_TOOLCHAIN_BASE/$TARGET/usr/lib"
</source>
Where ''IOS_TOOLCHAIN_BASE'' contains the directory where you installed the toolchain. And ''TRAGET'' has been setup from the previous step.


== Compiling ==
'''NOTE''': If you quit the shell you are using when configuring ScummVM and pick up compilation later, you will need to re-export only the ''PATH'' variable like described above.


First, you need to specify which assembler to use, since ScummVM's configure system currently doesn't do this automatically for us.
==== Configuring the Build ====


export AS=/usr/local/bin/arm-apple-darwin-as
Then configure ScummVM for the iOS version you want to target.


Then, we can start the compile:
First, navigate to a path where you want your build files to be located (this can be the ScummVM root directory but does not have to be).
Then run the following:
<source lang="bash">
./path/to/scummvm/configure --host=ios7 --with-staticlib-prefix=$IOS_TOOLCHAIN_BASE/$TARGET/usr
</source>
Replace ''ios7'' with ''iphone'' if you want to build the older version of our iOS backend.


make iphone
=== Compilation ===


Lastly, we want to make a ScummVM.app bundle:
You can compile ScummVM with running make:
<source lang="bash">
make iphone
</source>
If you simply want to test whether changes you made compile but do not plan to use the binary for deployment you can also simply run ''make''.


make iphonebundle
Please note that if you want to deploy ScummVM on your iOS device you will need to generate a bundle file. For this run either:
<source lang="bash">
make ios7bundle
</source>
for the ''ios7'' backend. Or
<source lang="bash">
make iphonebundle
</source>
for the ''iphone'' backend.


Then simply upload the whole ScummVM.app directory to your device under the /Applications folder, and you're done!
Then simply upload the whole ScummVM.app directory to your device under the /Applications folder, and you're done!

Revision as of 16:09, 30 March 2016

This page explains how to compile your own version of ScummVM using the iPhone backend.

Using XCode

TODO: Describe how to use XCode and create_project to compile for iOS using the official Apple toolchain.

Cross-Compilation

Please note binaries generated with these instructions only work with jailbroken devices.

Toolchain Setup

Toolchain

First you need to set up a toolchain for cross-compilation. On our buildbot we use this toolchain. It is based on LLVM/Clang and contains instructions on how to set it up.

External libs

In the previously linked toolchain a script to compile all libraries used by the iOS version of ScummVM is contained. Please refer to the toolchain's README file on how to build them.

Building ScummVM

Configuration

Before we can compile ScummVM we need to configure the source tree for building. This is usually only required once or when you want to alter build options.

Choosing an iOS target

We feature two different iOS backends:

  • iphone: Our legacy iOS backend, which supports all iOS3+ devices.
  • ios7: Our modern iOS7+ backend, which only supports iOS7+ devices but features better integration for these.

Depending on which backend you use you will need to use a different value for the TARGET environment variable.

  • For iphone use:
export TARGET=arm-apple-darwin9
  • For ios7 use:
export TARGET=arm-apple-darwin11

Setting up the Environment

export PATH="$IOS_TOOLCHAIN_BASE/bin:$IOS_TOOLCHAIN_BASE/$TARGET/bin:$IOS_TOOLCHAIN_BASE/$TARGET/usr/bin:$PATH"
export CPPFLAGS="-isystem $IOS_TOOLCHAIN_BASE/$TARGET/usr/include"
export LDFLAGS="-L$IOS_TOOLCHAIN_BASE/$TARGET/usr/lib"

Where IOS_TOOLCHAIN_BASE contains the directory where you installed the toolchain. And TRAGET has been setup from the previous step.

NOTE: If you quit the shell you are using when configuring ScummVM and pick up compilation later, you will need to re-export only the PATH variable like described above.

Configuring the Build

Then configure ScummVM for the iOS version you want to target.

First, navigate to a path where you want your build files to be located (this can be the ScummVM root directory but does not have to be). Then run the following:

./path/to/scummvm/configure --host=ios7 --with-staticlib-prefix=$IOS_TOOLCHAIN_BASE/$TARGET/usr

Replace ios7 with iphone if you want to build the older version of our iOS backend.

Compilation

You can compile ScummVM with running make:

make iphone

If you simply want to test whether changes you made compile but do not plan to use the binary for deployment you can also simply run make.

Please note that if you want to deploy ScummVM on your iOS device you will need to generate a bundle file. For this run either:

make ios7bundle

for the ios7 backend. Or

make iphonebundle

for the iphone backend.

Then simply upload the whole ScummVM.app directory to your device under the /Applications folder, and you're done!