* How to build with Google's Android SDK:
*  This assumes you are on linux and the current version which is revision 12 for the sdk and revision 6 for the ndk (you can modify it for windows as necessary)
*  You can go to http://developer.android.com/sdk/index.html and download the appropriate android sdk bins for your OS
*  You can go to http://developer.android.com/sdk/ndk/index.html and download the appropriate android ndk bins for your OS
*  
*  - To work with the SDK you need to have Java JDK installed: http://java.sun.com/javase/downloads/index.jsp

  1. Setup the Android environment:
      - wget http://dl.google.com/android/android-sdk_r12-linux_x86.tgz
      - tar xzvf android-sdk_r12-linux_x86.tgz
      - cd android-sdk-linux_x86/tools
      - ./android
            - Select the "Installed packages" on the right column and under "Description" hit "Update All..."
                - A dialog should pop up for choosing packages, hit the radial "Accept All" and hit "Install" (this may take some time)
      - cd ../../
      - ln -s android-sdk-linux_x86 /opt/android-sdk
      - wget http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2
      - tar xvjf android-ndk-r6-linux-x86.tar.bz2
      - ln -s android-ndk-r6 /opt/android
      
  
  2. Install and/or compile requisite libraries:
      - Get freetype:
        - git clone https://github.com/cdave1/freetype2-android
        - cd freetype2-android/Android/jni
        - Edit Application.mk and change android-8 to android-9
        - /opt/android/ndk-build freetype2-static
        - ln -s freetype2-android/include/ft2build.h /opt/android/platforms/android-9/arch-arm/usr/include/
        - ln -s freetype2-android/include/freetype/ /opt/android/platforms/android-9/arch-arm/usr/include/freetype
        - ln -s freetype2-android/Android/obj/local/armeabi/libfreetype2-static.a /opt/android/platforms/android-9/arch-arm/usr/lib/

      - Get libpng
        - git clone https://github.com/julienr/libpng-android.git
        - cd libpng-android/jni
        - Edit Application.mk and add:
            APP_PLATFORM := android-9
        - /opt/android/ndk-build
        - ln -s libpng-android/jni/png.h /opt/android/platforms/android-9/arch-arm/usr/include/
        - ln -s libpng-android/jni/pngconf.h /opt/android/platforms/android-9/arch-arm/usr/include/
        - ln -s libpng-android/obj/local/armeabi/libpng.a /opt/android/platforms/android-9/arch-arm/usr/lib/

      - Get SDL:
        - hg clone http://hg.libsdl.org/SDL
        - cd SDL/android-project/jni
        - ln -s ../.. SDL
        - cp SDL/include/SDL_config_android.h SDL/include/SDL_config.h
        * Patch the source
        - patch -p1 < misc/SDL-android.diff
        - /opt/android/ndk-build -j 2 TARGET_PLATFORM=android-9 SDL
        - ln -s SDL/include/ /opt/android/platforms/android-9/arch-arm/usr/include/SDL
        - ln -s SDL/android-project/libs/armeabi/libSDL.so /opt/android/platforms/android-9/arch-arm/usr/lib/

  3. Make a standalone version of the ndk
    - cd /opt/android
    - ./build/tools/make-standalone-toolchain.sh --package-dir=/opt/android
    - tar -xf arm-linux-androideabi-4.4.3.tar.bz2
      
  4. Set the build type environment variable to 'android' and build paintown:
      - export android=1
      - cd /path/to/paintown
      - make
  
  5. Copy over paintown, create android emulator and build java applet
      - Create android emulator (android-9 platform):
        - /opt/android-sdk/tools/android create avd -n paintown -t 5 
      - cp /path/to/paintown/paintown src/android/libs/armeabi/libpaintown.so
      - cp /opt/android/platforms/android-9/arch-arm/usr/lib/libSDL.so src/android/libs/armeabi/
      - cd src/android
      - Update the project:
        - /opt/android-sdk/tools/android update project -p . -s
      - Build the project (release requires a signature):
        - ant debug
      - Install in emulator (you may need two terminals for this):
        - /opt/android-sdk/tools/android
            Start paintown avd (this takes a while to boot)
        - /opt/android-sdk/platform-tools/adb install bin/Paintown-debug.apk
        - Navigate to the apps in android and launch Paintown
      
