#summary Instructions for building Hedgewars for Android = Hedgewars for Android = == Introduction == This guide will take you through the steps needed to succesfully compile Hedgewars for Android ==Download== We need to download these packages: * [http://code.google.com/p/hedgewars/ Hedgewars Source]
* [http://developer.android.com/sdk/index.html Android SDK] (Latest version will do)
* [http://developer.android.com/sdk/ndk/index.html Android NDK] (current version is r5b but anything up will probably work)
* [http://freepascal.org/down/source/sources.var FreePascal] (Latest (stable) version will do)
* [http://ant.apache.org/ Ant] (Linux distro should just use their package manager to get it, version isn't really important)
* Java compiler, make sure you get JDK (not JRE) version 6 and up ==Hedgewars Source== Using mercurial you can pull the hedgeroid branch using {{{ hg clone https://hedgewars.googlecode.com/hg/ hedgewars }}} ==Android SDK== Download the latest version using the link above. And unzip it at a place you can remember, I’ll refer to the location with `<`SDK`>`. Once you’ve unzipped/extracted the tar navigate to `<`SDK`>`/tools and execute ‘android’. This should bring up a GUI select ‘Available packages’, then ‘Android Repository’ and check atleast SDK Platform Android 1.6 / 2.1 / 2.2. I would recommend checking all of them, but it’s up to you. Next select ‘Install Selected’ press ‘Next’ a couple of times and you should have the SDK installed. Optionally you could permanently add `<`SDK`>`/platform-tools to your $PATH, this makes it easier to use ‘adb’. Adb is the main program to communicate with Android, think logging/pushing and pulling files/shell. If you do not have a real android device you can create an emulator if you do I’d skip this and continue at Android NDK You can use either the GUI, run android and follow the signs or from cli {{{ android create avd -n -t 4 }}} -n is a name of your choice -t stands for the target ID See this for more information To run the emulator navigate to `<`SDK`>`/tools and run {{{emulator -avd }}} where `<`name`>` is the same name as when you created it with the line above. ==Android NDK== Download and untar it, ill refer to the ndk as `<`NDK`>`. That’s it :) ==!FreePascal == We need to download the sources from the Freepascal website and compile the crosscompiler. I have grabbed the latest stable release 2.4.4 , though any version will work. Once downloaded, extract the tar/zip and place the files in a known directory. I will refer to the directory with `<`fpc`>` from now on. Next navigate to the `<`fpc`>` directory and compile it, for this various tools are needed, ‘make’ for instance. But also a fpc compiler for your system. Some apt-get/aptitude magic will solve these problems, make a comment if you run in to problems. Use this to compile the crosscompiler: {{{ make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin OPT=-dFPC_ARMEL BINUTILSPREFIX=arm-linux-androideabi- INSTALL_PREFIX=/fpc_install }}} ==Final== We will generate the Makefile.android, which is needed to compile hedgewars, download SDL and you’ll need to make sure cmake knows where all the compilers are 1.
Add `<`NDK`>`:`<`SDK`>`/platform-tools:`<`FPC`>`/compiler to your path, on debian based system I would do it as follows: {{{ export PATH=$PATH:/home/xeli/SoftDev/android/ndk export PATH=$PATH:/home/xeli/SoftDev/android/sdk/platform-tools export PATH=$PATH:/home/xeli/SoftDev/android/fpc-2.4.4/compiler }}} (Check google on how to do it for your specific OS if you don't know how) 2.
Now we're gonna download sdl and a couple of its libraries, if you're on linux there's a script you can use {{{ cd /project_files/Android-build chmod +x download_libs.sh (might not be needed) ./download_libs.sh }}} This will download and unzip sdl to the expected folders TODO: make script for windows and verify if it works for osx 3.
Finally you can use cmake to create the scripts {{{ cd cmake . -DBUILD_ANDROID_PORT=1 }}} And that’s it. To compile: {{{ cd /project_files/Android-build/ make -f Makefile.android }}} and it should be installed on your emulator/device if it was connected. On the device/emulator you can start the application up :) TODO verify that it works on Windows and OS X add dependency list of utilities (ant, fpc compiler for host, make etcetc)